Subject | Handling Exceptions in Stored Procedures |
---|---|
Author | robertgilland |
Post date | 2005-05-05T02:52:57Z |
Is there an Example . Itried the following and I could not get it to
compile.
Any Ideas?
CREATE PROCEDURE PROC_INJECT_PLUSALES
(
ASTOREID VARCHAR(10),
ASALESDATE TIMESTAMP,
APLU VARCHAR(14),
AQUANTITYSOLD FLOAT,
ASALESEXGST FLOAT,
ACOSTEXGST FLOAT,
ASALESINCGST FLOAT,
ACOSTINCGST FLOAT
)
AS
BEGIN
INSERT INTO PLUSALES
( STOREID, SALESDATE, PLU,
QUANTITYSOLD, SALESEXGST,
COSTEXGST, SALESINCGST, COSTINCGST )
VALUES
( :ASTOREID, :ASALESDATE, :APLU,
:AQUANTITYSOLD, :ASALESEXGST,
:ACOSTEXGST, :ASALESINCGST, :ACOSTINCGST );
WHEN EXCEPTION DO
BEGIN
UPDATE PLUSALES
SET
QUANTITYSOLD = :AQUANTITYSOLD,
SALESEXGST = :ASALESEXGST,
COSTEXGST = :ACOSTEXGST,
SALESINCGST = :ASALESINCGST,
COSTINCGST = :ACOSTINCGST
WHERE
( STOREID = :ASTOREID )AND
( SALESDATE = :ASALESDATE )AND
( PLU = :APLU );
END
END;
compile.
Any Ideas?
CREATE PROCEDURE PROC_INJECT_PLUSALES
(
ASTOREID VARCHAR(10),
ASALESDATE TIMESTAMP,
APLU VARCHAR(14),
AQUANTITYSOLD FLOAT,
ASALESEXGST FLOAT,
ACOSTEXGST FLOAT,
ASALESINCGST FLOAT,
ACOSTINCGST FLOAT
)
AS
BEGIN
INSERT INTO PLUSALES
( STOREID, SALESDATE, PLU,
QUANTITYSOLD, SALESEXGST,
COSTEXGST, SALESINCGST, COSTINCGST )
VALUES
( :ASTOREID, :ASALESDATE, :APLU,
:AQUANTITYSOLD, :ASALESEXGST,
:ACOSTEXGST, :ASALESINCGST, :ACOSTINCGST );
WHEN EXCEPTION DO
BEGIN
UPDATE PLUSALES
SET
QUANTITYSOLD = :AQUANTITYSOLD,
SALESEXGST = :ASALESEXGST,
COSTEXGST = :ACOSTEXGST,
SALESINCGST = :ASALESINCGST,
COSTINCGST = :ACOSTINCGST
WHERE
( STOREID = :ASTOREID )AND
( SALESDATE = :ASALESDATE )AND
( PLU = :APLU );
END
END;