Teradata / PyTd

A Python Module to make it easy to script powerful interactions with Teradata Database in a DevOps friendly way.
MIT License
108 stars 43 forks source link

Can not pass a NULL INPUT parameter to stored procedure #58

Closed alokagg closed 7 years ago

alokagg commented 7 years ago

I have a need to pass a 'NULL' parameter to my stored procedure, called from python code. The Python native null object , named 'None' doesn't seem to be recognized by the Teradata Python module. code snippet:

vjobid = raw_input("Job ID : ") vjobnm = raw_input("Job Name : ") vstarttm = raw_input("Enter Start Time : ") vnull = None

udaexec = teradata.UdaExec () with udaexec.connect("MYTD") as session: results = session.callproc("MYDB.MYPROC", (teradata.OutParam("resultcode1"), teradata.OutParam("resultstate1"), teradata.OutParam("resultmsg1"), teradata.InOutParam(vnull,"inout_schid"), vjobid,vjobnm,1,vstarttm,"N","N")) print(results.resultcode1) print(results.resultstate1) print(results.resultmsg1)

Got error in log, as follows

AttributeError: 'NoneType' object has no attribute 'raw'

escheie commented 7 years ago

I am able to reproduce the problem. I will release a fix shortly. Thanks for reporting.

escheie commented 7 years ago

Reopening issue as even though the error described above is resolved, when None is passed as an INOUT parameter to stored procedure the value is passed to the SP as 0 or an empty string and not NULL.