Subject | Re: [firebird-support] Re: Create procedure -- newbie coming from ms sql server |
---|---|
Author | Helen Borrie |
Post date | 2003-06-19T05:54:33Z |
At 05:25 AM 19/06/2003 +0000, you wrote:
Don't use EXECUTE on a "selectable stored procedure" - that's the kind Tim
and I showed you. Use SELECT for any SP that outputs more than one
row. If Quickdesk has a way to show you return parameters, you could test
the syntax for singleton output if your table had a primary key. Let's say
that, instead of loading 1 into your Field1, you'd used a generator and a
trigger to get a unique number (pretty limited with SmallInt, yeah!):
CREATE PROCEDURE SecondProcedure
returns FirstName varchar(50)
AS
BEGIN
select FirstName from TBLMARTIN
where Field1 = 2
into :FirstName;
END
You don't need a suspend here because there's only one row. You can call
EXECUTE on this without getting an error. (You can also use SELECT on it
if you like, since it returns something). The result will be returned to
the client in the XSQLDA structure. EMS would show you this in some kind
of "Return values" display, I suppose.
In practice, we use "executable procedures" to perform DML that doesn't
return output, and "selectable procedures" when the SP is designed to
return a result set.
heLen
>Hi tim,Yup. "Multiple rows in singleton select" or something similar?
>
>Thanks for that and the quick response.
>the stored procedure worked (you'll be amazed to know :) )
>although i did find the syntax a little odd.
>
>I am using EMS interbase/firebird manager to connect to the database.
>I tried running the stored procedure in the sql editor by typing
>
>EXECUTE FIRSTPROCEDURE
>
>but it gave me an error. any clues??
Don't use EXECUTE on a "selectable stored procedure" - that's the kind Tim
and I showed you. Use SELECT for any SP that outputs more than one
row. If Quickdesk has a way to show you return parameters, you could test
the syntax for singleton output if your table had a primary key. Let's say
that, instead of loading 1 into your Field1, you'd used a generator and a
trigger to get a unique number (pretty limited with SmallInt, yeah!):
CREATE PROCEDURE SecondProcedure
returns FirstName varchar(50)
AS
BEGIN
select FirstName from TBLMARTIN
where Field1 = 2
into :FirstName;
END
You don't need a suspend here because there's only one row. You can call
EXECUTE on this without getting an error. (You can also use SELECT on it
if you like, since it returns something). The result will be returned to
the client in the XSQLDA structure. EMS would show you this in some kind
of "Return values" display, I suppose.
In practice, we use "executable procedures" to perform DML that doesn't
return output, and "selectable procedures" when the SP is designed to
return a result set.
heLen