Subject | [firebird-support] Is there a better way of doing this ? |
---|---|
Author | Stephen Davey |
Post date | 2006-11-23T23:30:20Z |
I use this structure to table maintenance processes.
The simple question is , can it be done in a better way ?
Thanks
Stephen
SET TERM ^ ;
CREATE PROCEDURE BALE_SAVE
(
CODE VARCHAR(30),
FABRICCODE VARCHAR(20),
FABRICDESCR VARCHAR(60),
APMCODE VARCHAR(20),
APMDESCR VARCHAR(60),
QTYEST NUMERIC(15,2)
)
AS
DECLARE VARIABLE CNT INTEGER ;
BEGIN
SELECT COUNT(CODE) FROM BALE
WHERE BALE.CODE = :CODE
INTO CNT ;
IF (:CNT=0) THEN INSERT INTO BALE(CODE) VALUES (:CODE) ;
UPDATE BALE
SET
FABRICCODE = :FABRICCODE,
FABRICDESCR = :FABRICDESCR,
APMCODE = :APMCODE,
APMDESCR = :APMDESCR,
QTYEST = :QTYEST
WHERE
CODE = :CODE ;
END ^
[Non-text portions of this message have been removed]
The simple question is , can it be done in a better way ?
Thanks
Stephen
SET TERM ^ ;
CREATE PROCEDURE BALE_SAVE
(
CODE VARCHAR(30),
FABRICCODE VARCHAR(20),
FABRICDESCR VARCHAR(60),
APMCODE VARCHAR(20),
APMDESCR VARCHAR(60),
QTYEST NUMERIC(15,2)
)
AS
DECLARE VARIABLE CNT INTEGER ;
BEGIN
SELECT COUNT(CODE) FROM BALE
WHERE BALE.CODE = :CODE
INTO CNT ;
IF (:CNT=0) THEN INSERT INTO BALE(CODE) VALUES (:CODE) ;
UPDATE BALE
SET
FABRICCODE = :FABRICCODE,
FABRICDESCR = :FABRICDESCR,
APMCODE = :APMCODE,
APMDESCR = :APMDESCR,
QTYEST = :QTYEST
WHERE
CODE = :CODE ;
END ^
[Non-text portions of this message have been removed]