Return values/output parameters from an anonymous block of t-sql

Return values/output parameters from an anonymous block of t-sql

Post by Ole Strandenge » Fri, 15 Nov 2002 21:51:15

Is it possible to have return/output variables from an anonymous block of
T-sql using ODBC.

I am able to execute a block of sql statements from ODBC. To check the
result of the
block, I need to have three counters (integers) returned in addition to an
error variable in case of failure.

I have tried to bind variables like we do for a stored procedure, but with
little success.

Program is written in C using ODBC.


1. Returning values from an anonymous block

Hi all,
I have a situation where I (from my client-application) want to
 - insert a row into a table with a sequence generated PK
 - retrieve that PK back to my application for further use

I want this to happen in one roundtrip to the db server.
I know I should use a proc to do this, but that is not an option.

I have tried with
"DECLARE a number(5); BEGIN INSERT INTO table (...) values (seq.nextval...);
SELECT seq.currval INTO a FROM dual; END;"

"INSERT INTO table ..... RETURNING..."

but don't know how to return the bind variables to the application.

Anyone who could shed some light on this?


2. Set password in data control

3. Stored procedure returning empty output parameters or return value

4. SCALA5 Mailing List Available!

5. Return result set and return value/output parameter

6. Need to interview DBAs for Sr. project

7. How to capture the return value and output parameter value of a stored procedure in VB

8. NULL value comparisions

9. Return output parameters from EXEC('tsql')

10. Retrieve Values from an anonymous Oracle PL/SQL block with Delphi 4

11. Output parameter not returning value?

12. Returning value of COMPUTE as OUTPUT parameter

13. JDBC: return values and output parameters from stored procedures