Subject | Executing an insert procedure |
---|---|
Author | Daniel L. Miller |
Post date | 2004-11-01T08:17:29Z |
Hi all.
I'm trying to implement a stored procedure to perform updates on Debian
Linux packaged FB1.5. Full text of procedure below:
CREATE PROCEDURE UPDATE_ZIPCODE (ID INTEGER, ZIPCODE CHARACTER (10),
STATE CHARACTER (2), CITY VARCHAR (30))
RETURNS (NEWID INTEGER)
AS
BEGIN
IF (id IS NOT NULL) THEN
BEGIN
UPDATE ZIPCODES SET zipcode=:zipcode, state=:state, city=:city WHERE
id=:id;
newid=id;
END
ELSE
BEGIN
newid = GEN_ID(gen_zipcode_id,1);
INSERT INTO ZIPCODES (id, zipcode, city, state)
VALUES (:newid, :zipcode, :city, :state);
END
END !!
The idea is to have a single procedure to be used for both inserts &
updates, and have it return the id of the record created/updated. I'm
using ibWebAdmin as my interface. The problem comes when I try to test
the procedure. Executing the following SQL brings these results:
execute procedure update_zipcode (4,'89102','Las Vegas','NV')
RETURNING_VALUES NEWID
execute procedure update_zipcode (4,'89102','Las Vegas','NV')
arithmetic exception, numeric overflow, or string truncation
I tried this in isql also - same results. What am I doing wrong?
Daniel
I'm trying to implement a stored procedure to perform updates on Debian
Linux packaged FB1.5. Full text of procedure below:
CREATE PROCEDURE UPDATE_ZIPCODE (ID INTEGER, ZIPCODE CHARACTER (10),
STATE CHARACTER (2), CITY VARCHAR (30))
RETURNS (NEWID INTEGER)
AS
BEGIN
IF (id IS NOT NULL) THEN
BEGIN
UPDATE ZIPCODES SET zipcode=:zipcode, state=:state, city=:city WHERE
id=:id;
newid=id;
END
ELSE
BEGIN
newid = GEN_ID(gen_zipcode_id,1);
INSERT INTO ZIPCODES (id, zipcode, city, state)
VALUES (:newid, :zipcode, :city, :state);
END
END !!
The idea is to have a single procedure to be used for both inserts &
updates, and have it return the id of the record created/updated. I'm
using ibWebAdmin as my interface. The problem comes when I try to test
the procedure. Executing the following SQL brings these results:
execute procedure update_zipcode (4,'89102','Las Vegas','NV')
RETURNING_VALUES NEWID
>Dynamic SQL Error SQL error code = -104 Token unknown - line 1, char63 RETURNING_VALUES
execute procedure update_zipcode (4,'89102','Las Vegas','NV')
arithmetic exception, numeric overflow, or string truncation
I tried this in isql also - same results. What am I doing wrong?
Daniel