Subject | Re: [ib-support] New to Stored Procedures |
---|---|
Author | Helen Borrie |
Post date | 2001-07-04T02:23:44Z |
At 04:07 AM 04-07-01 +0200, you wrote:
You need to declare the variable B as either an argument or a local variable in order to reference it. In this case, I assume you want it to be an output argument, i.e.
CREATE PROCEDURE ROUND_NORMAL
RETURNS(B DOUBLE PRECISION)
AS
BEGIN
FOR SELECT BETRAG
FROM BETRAEGE
INTO :B
DO BEGIN
B=(B/100+0.5)*100;
END
/* EXIT; */
END
btw, you don't need to include the EXIT statement - use that just when you want the procedure to terminate prematurely because of some condition.
Cheers,
Helen
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________
>Hello!Tobias,
>
>I'm having trouble getting my first stored procedure to work. In this small
>excerpt, I'm trying to create the database with one table and a stored
>procedure. The table is created fine, but the stored procedure definition
>returns the error:
>COLUMN UNKNOWN - why?
You need to declare the variable B as either an argument or a local variable in order to reference it. In this case, I assume you want it to be an output argument, i.e.
CREATE PROCEDURE ROUND_NORMAL
RETURNS(B DOUBLE PRECISION)
AS
BEGIN
FOR SELECT BETRAG
FROM BETRAEGE
INTO :B
DO BEGIN
B=(B/100+0.5)*100;
END
/* EXIT; */
END
btw, you don't need to include the EXIT statement - use that just when you want the procedure to terminate prematurely because of some condition.
Cheers,
Helen
>Thanks for your help.All for Open and Open for All
>Tobias
>
>----------------------------------------
>SET SQL DIALECT 3;
>
>CREATE DATABASE 'XYZ.GDB' PAGE_SIZE 1024 USER "SYSDBA" PASSWORD "masterkey";
>
>CREATE TABLE BETRAEGE
>(
> ID INTEGER NOT NULL,
> TYP CHAR( 10) NOT NULL,
> DATUM TIMESTAMP NOT NULL,
> BETRAG DOUBLE PRECISION,
> CONSTRAINT PK_BETRAEGE PRIMARY KEY (ID,TYP,DATUM)
>);
>
>COMMIT WORK;
>SET AUTODDL OFF;
>SET TERM ^ ;
>
>CREATE PROCEDURE ROUND_NORMAL AS
>BEGIN
> FOR SELECT BETRAG
> FROM BETRAEGE
> INTO :B
> DO BEGIN
> B=(B/100+0.5)*100;
> END
> EXIT;
> END ^
>
>SET TERM ; ^
>
>COMMIT WORK;
>SET AUTODDL ON;
>
>
>To unsubscribe from this group, send an email to:
>ib-support-unsubscribe@egroups.com
>
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________