Subject | Simple trigger task |
---|---|
Author | Yves Glodt |
Post date | 2003-11-16T14:35:52Z |
Hi,
I never used triggers/stored procedures, but I think the moment to start
with has come... See this table:
CREATE TABLE WT_PERS (
IPN INTEGER NOT NULL,
PERS_BDG VARCHAR(20),
PERS_NUMBER VARCHAR(20),
PERS_NAME VARCHAR(50),
etc ....
PRIMARY KEY (IPN)
);
When a new person is inserted, the field PERS_NUMBER is not included in
the insert statement.
What I wanna do is, after an insert has been performed, the field
PERS_NUMBER should automatically get the last (highest) used
PERS_NUMBER incremented by 1
So I guess an after-insert-trigger that calls a stored procedure which
updates the PERS_NUMBER would be the way to go.
How would such a trigger/stored proc look like?
Thank you and best regards,
Yves Glodt
--
Linux 2.4.22-1-k7 #1 Sat Sep 6 02:13:04 EST 2003 i686
15:18:48 up 9 min, 1 user, load average: 0.14, 0.21, 0.15
I never used triggers/stored procedures, but I think the moment to start
with has come... See this table:
CREATE TABLE WT_PERS (
IPN INTEGER NOT NULL,
PERS_BDG VARCHAR(20),
PERS_NUMBER VARCHAR(20),
PERS_NAME VARCHAR(50),
etc ....
PRIMARY KEY (IPN)
);
When a new person is inserted, the field PERS_NUMBER is not included in
the insert statement.
What I wanna do is, after an insert has been performed, the field
PERS_NUMBER should automatically get the last (highest) used
PERS_NUMBER incremented by 1
So I guess an after-insert-trigger that calls a stored procedure which
updates the PERS_NUMBER would be the way to go.
How would such a trigger/stored proc look like?
Thank you and best regards,
Yves Glodt
--
Linux 2.4.22-1-k7 #1 Sat Sep 6 02:13:04 EST 2003 i686
15:18:48 up 9 min, 1 user, load average: 0.14, 0.21, 0.15