I am doing an insert into a database via a call to a stored proceedure in SQL server.
I am running the following piece of code:
BBTID = fpmi.db.runUpdateQueryGetKey("exec dbo.usp_BBTCreateRecord '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'" % (dt,dd,mm,yy,brand,tank,dest,cond))
It is doing the insert into the database and everything seems fine, but the value for BBTID is None after running this. I am expecting the record key for the insert that was done by the routine.
Am I am not sure if I am using the call incorrectly, or if the fact that it is a proceedure is messing things up?
Yeah, I doubt that stored procedures participate in the “returning auto-generated keys” feature of JDBC (although this is theoretically driver-specific).
You’re probably only going to get a key back on a true INSERT query - wrapping it up in a stored proc is masking the fact that you’re doing an INSERT to the driver. Could you simply have the stored procedure return the new key?
I went ahead and took your advice and just altered the proceedure so that it now return the key value. I guess sometimes I don’t look at the simplest solutions.
Thanks for the help.
No problem, glad its working.