Subject Re: Messing with SPs...
Author Marco Menardi <mmenaz@lycosmail.com>
--- In ib-support@yahoogroups.com, "Pirtea Calin Iancu" <pcalin@r...>
wrote:
> ----- Original Message -----
> From: "The DeerBear"
>
> > Hello,
> >
> > Look at this:
> >
> > ---------- STATEMENT ----------
> >
> > CREATE PROCEDURE NEW_PROCEDURE (
> > USR_NAME VARCHAR(10),
> > "Pwd" VARCHAR(20))
> > AS
> > begin
> > /* Procedure Text */
> > SELECT * FROM ACCOUNTS WHERE "USER_NAME"=:USR_NAME AND
"PASSWORD"=:Pwd
> > end
> >
> > ---------- ERROR MESSAGE ----------
> >
> > Invalid token.
> > Dynamic SQL Error.
> > SQL error code = -104.
> > Token unknown - line 8, char -1.
> > end.
> >
> > What is the prob with this SP?
>
> First of all you need a ';' after a statement and ...
> >
> > Should I define out params as well?
> > How do I return a result-set?
> >
> ... and secondly this procedure will do nothing at all.
>

mmm... even worse, it will do a lot of work, but without any output
it's useless ;)

Andrew, you have to define output parameters to get values from the
stored procedure, and use the costruct "for select ... into ... do
begin.. suspend .. end
Have a look at the documentation, and the employee database, where you
find:
CREATE PROCEDURE GET_EMP_PROJ (
EMP_NO SMALLINT)
RETURNS (
PROJ_ID CHAR (5))
AS
BEGIN
FOR SELECT proj_id
FROM employee_project
WHERE emp_no = :emp_no
INTO :proj_id
DO
SUSPEND;
END

regards
Marco Menardi