Subject | Updating within Stored Procedures |
---|---|
Author | Tobias Giesen |
Post date | 2001-07-04T16:53:26Z |
Hi!
I've got it working now, but I find it a bit awkward. I've got a stored
procedure MyRunden which rounds one value. The main updating stored
procedure copied below uses an UPDATE statement within a SELECT statement.
It seems to work, but is this how it should be done?
Thanks.
Cheers,
Tobias
CREATE PROCEDURE ROUND_NORMAL (Typ CHAR(10), Datum DATE, Kind INTEGER) AS
DECLARE VARIABLE Betrag DOUBLE PRECISION;
DECLARE VARIABLE ID INTEGER;
BEGIN
FOR SELECT BETRAG,ID
FROM BETRAEGE
WHERE (TYP = :Typ) AND (DATUM = :Datum)
INTO :Betrag,:ID
DO BEGIN
EXECUTE PROCEDURE MyRunden :Betrag,:Kind RETURNING_VALUES :Betrag;
UPDATE BETRAEGE
SET Betrag=:Betrag
WHERE TYP =:Typ AND DATUM = :Datum AND ID=:ID;
END
END ^
I've got it working now, but I find it a bit awkward. I've got a stored
procedure MyRunden which rounds one value. The main updating stored
procedure copied below uses an UPDATE statement within a SELECT statement.
It seems to work, but is this how it should be done?
Thanks.
Cheers,
Tobias
CREATE PROCEDURE ROUND_NORMAL (Typ CHAR(10), Datum DATE, Kind INTEGER) AS
DECLARE VARIABLE Betrag DOUBLE PRECISION;
DECLARE VARIABLE ID INTEGER;
BEGIN
FOR SELECT BETRAG,ID
FROM BETRAEGE
WHERE (TYP = :Typ) AND (DATUM = :Datum)
INTO :Betrag,:ID
DO BEGIN
EXECUTE PROCEDURE MyRunden :Betrag,:Kind RETURNING_VALUES :Betrag;
UPDATE BETRAEGE
SET Betrag=:Betrag
WHERE TYP =:Typ AND DATUM = :Datum AND ID=:ID;
END
END ^