Skip to content
Advertisement

Python script to move data from a SQL server db to an oracle db keeps giving ‘ORA-01036: illegal variable name/number’

So I am using python to pull data from a sql server with a simple select that grabs 15 columns. The data looks like this

The columns on the oracle table are all number except for the first column which is date. The sizes are all correct.

After I get all the data i run it through this little function to get rid of the pyodbc.row types.

I get a list of tuples.

Then to write to the oracle table I wrote this function that takes in the list of tuples.

I make the oracle connection like this

The connection works fine. But when the line trgtcrsr.executemany(None, recordsToWrite) is executed it gives me a 'ORA-01036: illegal variable name/number' error

I have another script that uses the same method of writing a list of tuples to an oracle table with the trgtcrsr.prepare(SQL)/trgtcrsr.executemany(None, recordsToWrite) method and it works fine (granted its oracle to oracle) writing to oracle so I am not sure why I keep getting this error. I have tried changing data types and googling the error but cant find anything similar.

Any ideas?

Advertisement

Answer

rec[7] appears twice in the function BuildBindList().

I’m guessing this will cause the insert to fail as you passed it 16 columns to instantiate 15 bind variables in the insert statement.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement