Subject | Autogenerate template procedures (IBExpert) |
---|---|
Author | Tim Gahnström |
Post date | 2005-05-19T14:42:26Z |
Are there features in firebird or IBExpert to simplify common tasks such as creating a stored procedure to add or update a field in a table.
I am getting somewhat bored writing code like this where the same field name is repeated five times (plus the a few times on the calling side)
CREATE PROCEDURE SP_ITEM_ADD (
IITEM_ID INTEGER,
SNAME VARCHAR(50))
AS
begin
INSERT INTO T_ITEMS
(ITEM_ID, NAME)
VALUES (:IITEM_ID, :SNAME);
when sqlcode -803 do --errorcode "no duplicate value"
UPDATE T_ITEMS
set name = :SNAME,
where ITEM_ID = :IITEM_ID;
End
Are there tools to generate this or is there a better way than writing it all? This is esentially a procedure adding all data to a row in a table based on the primary key.
Tim
Tim
I am getting somewhat bored writing code like this where the same field name is repeated five times (plus the a few times on the calling side)
CREATE PROCEDURE SP_ITEM_ADD (
IITEM_ID INTEGER,
SNAME VARCHAR(50))
AS
begin
INSERT INTO T_ITEMS
(ITEM_ID, NAME)
VALUES (:IITEM_ID, :SNAME);
when sqlcode -803 do --errorcode "no duplicate value"
UPDATE T_ITEMS
set name = :SNAME,
where ITEM_ID = :IITEM_ID;
End
Are there tools to generate this or is there a better way than writing it all? This is esentially a procedure adding all data to a row in a table based on the primary key.
Tim
Tim