Using Dynamic SQL Method 2(C Embedded SQL) for calling stored procedure -
05-27-2004
, 05:39 AM
I am writing a C++ application which supports dynamic sql. I use
different method for SQL, PL/SQL block.
For UPDATE/INSERT/DELETE and Stored Procedure I use method 1 "execute
immediate" while I use method 4 for SELECT. It works well.
However, I am not able to get output parameters using method 1 for
Stored Procedure. I think I should use method 2 with descriptor.
strcpy(sqlStatement, "declare @passwd varchar(8) begin exec
getPassword 'EurHSales', @passwd end")
EXEC SQL SET CHAINED OFF;
EXEC SQL BEGIN TRANSACTION;
EXEC SQL PREPARE STATE_SP FROM :sqlStatement;
EXEC SQL ALLOCATE DESCRIPTOR SPDES with max :SQLCount;
EXEC SQL DESCRIBE OUTPUT STATE_SP USING SQL DESCRIPTOR SPDES :SQLCount
= count;
EXEC SQL EXEC STATE_SP USING SQL DESCRIPTOR SPDES;
..
..
EXEC SQL AT COMMIT TRANSACTION;
EXEC SQL SET CHAINED ON;
However when i call a stored procedure which has output parameters, i
am not able to get an expected SQLCount after executing the statement.
SQLCount is always 0, I expect 1. Could anyone tell me what's wrong
with my program? |