Subject Re: [ib-support] New to Stored Procedures
Author Helen Borrie
At 04:07 AM 04-07-01 +0200, you wrote:
>Hello!
>
>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?

Tobias,
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.
>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/

All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________