Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored procedure returning multiple rows

Status
Not open for further replies.

ROBLEMMENS

Programmer
Feb 20, 2003
12
SE
hi, im using Delphi6 and Interbase 6, i need a stored procedure that returns more than one row but whenever i try to create the procedure it says token unknown ; ?
This is my procedure:

CREATE PROCEDURE TEST_PROC(DOC_NR INTEGER)
RETURNS
AS
BEGIN
SELECT *
FROM DOCUMENT
WHERE NR = :DOC_NR;
END!!

i think that isql expects the INTO clausule but i read in the ib documentation that INTO can only be used for a singleton select. How do i make a procedure returning multiple rows? I can't use a query because it would be executed on the client side and we need it to execute on the server.
 
Here is a small example:

SET TERM ^ ;
CREATE PROCEDURE "INQUIRE"
(
"CNT" SMALLINT
)
RETURNS
(
"ID" INTEGER,
"NAME" VARCHAR(30)
)
AS
begin
for select ID, NAME from TABLE into :ID, :NAME do begin
suspend;
CNT=CNT-1;
if (CNT<=0) then exit;
end
end
^

SET TERM ; ^
COMMIT WORK;

 
you can write your stored procedure like that:
SET TERM !!;
CREATE PROCEDURE TEST_PROC(DOC_NR INTEGER)
AS
BEGIN
SELECT * FROM DOCUMENT WHERE
NR=:DOC_NR;
END;!!
SET TERM ;!!
but i advice you to use a query instead is the best choice i think.
 
hi,

I miss the returning parameter(s)

CREATE PROCEDURE TEST_PROC(DOC_NR INTEGER)
RETURNS
(Param1 as Integer)
AS
BEGIN
for
SELECT Param1
FROM DOCUMENT
WHERE NR = :DOC_NR into :param1 do
begin
suspend;
end
END

You cannot use *, you always have to define the parameters.

But I also have problems with a correct working sp (in Delphi, via bde) with crystal reports.

I always get an error (tolken unkown, line 20 char0)

Raja
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top