How to access a returned output from SP run in SQL Server environment
I am migrating our db from Oracle (12c) to SQL Server (2019) but I am new to SQL Server, and I am on CF 2016. One stored procedure that runs just fine in Oracle is giving me trouble. It’s a SP developed by someone and I don’t have control over, but I know it basically generates a primary key from a table and returns an integer (only one number). In Oracle environment I would use:
<cfstoredproc procedure="mySP" datasource="#dsn#">
<cfprocparam cfsqltype="cf_sql_numeric" type="out" name=”next_pk”>
</cfstoredproc>
Then I can access the value of #next_pk# and insert it into a table for a new record.
In SQL Server environment, if I use the same code, it says “has too many arguments”. I saw someone said we can’t use type=”out” in SQL Server. So I use:
<cfstoredproc procedure="mySP" datasource="#dsn#">
<cfprocresult resultset="1" name="next_pk">
</cfstoredproc>
and try to output #next_pk#, it says next_pk is undefined.
If I try to output #next_pk.UseKey#, it says “UseKey” is undefined in next_pk. (“UseKey” is the name of the only output variable by the stored procedure. I remember someone said the output is like a cfquery and you can call the column directly.)
I bet this is not a new issue and I must have missed something. Can someone help me out or give me a pointer? Thanks a lot.
