stored proc RETURN_VALUE.... there it is, I want to use it !!!



so... here I have a stored procedure...

CREATE PROCEDURE dbo.getPayments @meetingCode char(6), @guestid char(10) AS
return (select sum(a.amount) as payments from dbo.payments a
where (A.meetingCode= @meetingCode) and (a.guestid = @guestid)
group by a.guestid
)
GO

here I call it...
with ADODataSet1 do
begin
prepared := false;
CommandType := cmdStoredProc;
CommandText := 'getPayments';
Parameters.CreateParameter('guestID',ftString, pdInput, 10,
adodsGuests.FieldValues['guestid']);
Parameters.CreateParameter('meetingCode',ftString, pdInput, 6,
adodsGuests.FieldValues['meetingCode']);
Parameters.CreateParameter('RETURN_VALUE',ftCurrency, pdOutput, 4, 0);
prepared := true;
open;
getPayments := Parameters.ParamByName('RETURN_VALUE').Value;
close;
end;

I'm anticipating the 'return' of the stored proc to be available in the
'RETURN_VALUE' of the dataset parameter.

***
I know that I could just run it and read the resulting fieldvalue... never
mind all of this return() and return_value business... but I saw it there
and want to use it (whine!). Am I just not thinking clearly? I saw in the
sql help that it states that stored procedures don't return values??? But
then I see that there is the 'return' ?call? available that is suppose to
return a value...??? and I see the 'RETURN_VALUE' output parameter that just
kind of plunks itself there whenever you use a stored procedure... and I'm
thinking... here's a handy little gizmo, I should figure out how to make use
of it... failing miserably... can anyone set me straight?

AND... how come when I plunk down a stored procedure or set my dataset
component to call a stored procedure that it knows the parameters BUT when I
change the name of the stored procedure during runtime I have to 'create'
the parameters? Am I missing something there as well? (whine again... they
need to turn on the air conditioning here, sorry!)

thanx much!
b


.



Relevant Pages