Delphi and Interbase stored proc problem

I have the following stored procedure which appears to give sensible answers.

SET TERM !! ;
CREATE PROCEDURE gettransdets (jobid integer)
RETURNS  
(
dpexps             decimal (12,2) ,
execexps       decimal (12,2) ,
fieldexps       decimal (12,2) ,
otherexps       decimal (12,2) ,
sales             decimal (12,2) ,
trandate       date
)
as begin
for SELECT
            DPEXPS,
            EXECEXPS,
            FIELDEXPS,
            OTHEREXPS,
            SALES,
            TRANDATE
FROM
 TRANS
where jobid = :jobid

      into
:DPEXPS,
:EXECEXPS,
:FIELDEXPS,
:OTHEREXPS,
:SALES,
:TRANDATE
      do
      suspend;
END !!
SET TERM ; !!


If I run
select * from gettransdets(9000) in the WISQL window I get sensible answers

I am now trying to get delphi to control the query with a Tquery which says

Select * from Gettransdets where jobid =:numb

and then

query1.close
query1.parambyname('numb').asinteger := 9000;
query1.open;


This fails every time with a message about parameter mismatch.

Can any kind sould tell me what it is I'm doing wrong and perhaps more to the point how to correct it


Thank you

jbehAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
karooConnect With a Mentor Commented:
glad to have helped:)
0
 
karooCommented:
hi jbeh,

this works:

procedure OpenTrans(jobid: Integer);
begin
  Query1.Close;
  Query1.SQL.Clear;
  Query1.SQL.Add('Select * from gettransdets(' +IntToStr(jobid) +')';
  Query1.Open;
end;

the paramcheck of Query1 is set to false.

there is a couple of other ways but this is the easiest one because you can expand your Parameters easily if necesary.

Regards  Ben:)
0
 
jbehAuthor Commented:
So I'm circumventing the normal way of passing parameters to a Delphi query.......

Interesting - I'll try it and see what happens and get back to you

Thank you

0
 
karooCommented:
jbeh,

I would say the normal way a SP works is when the result returned is a singular result set(input and output params), in your case it is not.

Youre query could just as well work if youre Query SQL for the Query is:
SELECT Fields...
FROM TRANS
WHERE JOBID =:jobparam

In this case you would use:
query1.close
query1.parambyname('jobparam').asinteger := 9000;
query1.open;

it would work just as well.
0
 
jbehAuthor Commented:
Yes - I totally agree that I could do it that way ..

However I wanted to see how to do it - This was my first experiment of this nature and i was getting very frustrated with it..

Presumably the SP method will in principle be marginally faster.


Anyhow if you'd do the necessary bits and pieces at your end I'll happily release the points

Thanks a lot




0
All Courses

From novice to tech pro — start learning today.