BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Stored procedure 0 result mystery

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
RobGeezer
Guest





PostPosted: Thu Jan 12, 2006 11:15 am    Post subject: Stored procedure 0 result mystery Reply with quote



We have to use InterBase via ODBC for this project. Using ADO the
stored procedure returns 0. Testing using InterBase components
directly, the stored procedure gives the right value. ADO does call
the procedure - just loses the result. Has anyone solved this problem
please?

Delphi 2005, MDAC 2.8, Easysoft ODBC 4.0.0.7, InterBase 7.5

Stored procedure/generator SQL:
CREATE GENERATOR CALLREF_GENERATOR;
SET GENERATOR CALLREF_GENERATOR TO 1

CREATE PROCEDURE GETNEWCALLREF RETURNS (
RETURNVALUE INTEGER
) AS
begin
RETURNVALUE = gen_id(CALLREF_GENERATOR, 1);
end

Delphi 2005 code:
procedure TForm1.btnAdoClick(Sender: TObject);
var
number: integer;
begin
ADOStoredProc1.Parameters.Clear;
ADOStoredProc1.Parameters.CreateParameter('RETURNVALUE', ftInteger,
pdOutput{pdReturnValue}, 4, 0);
ADOStoredProc1.ExecProc;
number := ADOStoredProc1.Parameters.ParamByName('RETURNVALUE').Value;
memo1.Lines.Add('Returns=' + inttostr(number));
end;
// Using pdReturnValue causes exception "parameter mismatch"

procedure TForm1.btnInterBaseClick(Sender: TObject);
var
number: integer;
begin
IBStoredProc1.Params.Clear;
IBStoredProc1.Params.CreateParam(ftInteger, 'RETURNVALUE',
{ptResult}ptOutput);
IBStoredProc1.ExecProc;
number := IBStoredProc1.ParamByName('RETURNVALUE').Value;
memo2.Lines.Add('Returns=' + inttostr(number));
end;
// using ptResult causes InterBase to return 0 as well!!

Back to top
RobGeezer
Guest





PostPosted: Thu Jan 12, 2006 11:36 am    Post subject: Re: Stored procedure 0 result mystery Reply with quote



Hi. There's a typographical error. The ADO example function should be
as follows:
ADOStoredProc1.Parameters.CreateParameter('RETURNVALUE', ftInteger,
{pdOutput}pdReturnValue, 4, 0);
and:
// Using pdOutput causes exception "parameter mismatch"

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.