I'm reviewing the data contained in the Serial table using Python and the ODBC driver. From the metadata table I expect that serial.InStockCode would take the following values:
if( (InvNum = 0) and (SONum = 0) then StockCode else NULL)
In the cases where this evaluates to StockCode, I'm seeing additional characters insert into the record. The addition of the characters causes the StockCode length to be truncated. Here is one example record.
I've tried to format the data in such a way that the hidden characters can be seen.
I expected this field to just contain a StockCode but that doesn't seem to be the case.
Here's a minimum working example of the code.
conn = pyodbc.connect("DSN=Atrex-RO")
atrex = conn.cursor()
statement = "SELECT * FROM serial WHERE InStockCode is not null"
atrex.execute(statement)
columns = [x[0] for x in atrex.description]
for row in atrex.fetchall():
row = {k: v for k, v in zip(columns, row)}
print(row)
for k, v in row.items():
if k in ('InStockCode', 'StockCode'):
print(f"{k}: {v}")
print("\tEncoded as UTF-8: ", v.encode())
print("\tCharacters as Unicode Numbers: ", [ord(c) for c in v])
atrex.close()