jbeh
asked on
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
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')
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
ASKER
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
Interesting - I'll try it and see what happens and get back to you
Thank you
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('jobpar am').asint eger := 9000;
query1.open;
it would work just as well.
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('jobpar
query1.open;
it would work just as well.
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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:)