I have a stored procedure on a MSSQL2K server that will perform 2 processes. I am doing a check of the processes and will return an int value which specifies whether the processes completed properly, i.e.
return val - Meaning
0 - both processes failed
1 - the first process completed but the second failed
10 - the second completed but the first failed
11 - indicates both passed
The SP uses the return keyword as in:
using following the TSQL string in query analyzer returns the results correctly:Code:USE myDB IF EXISTS (SELECT name FROM sysobjects WHERE name = 'updatedata' AND type = 'P') DROP PROCEDURE updatedata GO USE myDB GO CREATE PROCEDURE updatedata @n1 decimal, @n2 decimal, @n3 varchar(25), AS set nocount on DECLARE @m1 int DECLARE @m2 int ... do initial process .... select @m1 = (select count(*) from table where params match) // @m1 should = 1 ... do second process ... select @m2 = 10 * (select count(*) from table where params match) // @m2 should = 10 return (@md + @mdh) // should return 11 to calling app GO
In VC/C++, I am using ADO and the open function to call the SP. I need to know how to format the syntax so the return value is returned to be evaluated.Code:declare @val int exec @val = updatedata 101002, 105041, 'some part number' select @val as 'val'
Considering using this function:
How can I change this to get the data returned correctly?Code:// RS1 is the recordset object char rsSQL[256]; sprintf(rsSQL,"exec updateData %d, %d, %s", (long)tme, (long)jdt, cmLITM); RS1->Open(rsSQL, vtMissing, adOpenKeyset, adLockBatchOptimistic, -1);
Thanks in advance.




Reply With Quote