dbTalk Databases Forums  

Using Dynamic SQL Method 2(C Embedded SQL) for calling stored procedure

comp.databases.sybase comp.databases.sybase


Discuss Using Dynamic SQL Method 2(C Embedded SQL) for calling stored procedure in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Martin
 
Posts: n/a

Default 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?

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.