As Birgitta said, a before insert is what you want.
I do have to ask though. Why not use an identity column and have the
system autoincrement it for you?
Create table...
myKeyColumn int as identity,
...
Or perhaps a sequence object? Below is a tested example of sequence
created with "Run SQL Scripts":
set current schema rob;
create or replace sequence NextKey;
create table scuzz (
myKeyColumn int as identity,
SomeOtherColumn char(5),
CounterNumber int);
insert into scuzz
(SomeOtherColumn, CounterNumber)
values ('A', next value for NextKey);
insert into scuzz
(SomeOtherColumn, CounterNumber)
values ('B', next value for NextKey);
select * from scuzz;
you will see:
1, A, 1
2, B, 2
values previous value for NextKey;
You will see: 2
If you want to know what object it creates try DSPDTAARA. It's rather
complex though.
Data area . . . . . . . : NEXTKEY
Library . . . . . . . : ROB
Type . . . . . . . . . : *CHAR
Length . . . . . . . . : 2000
I think it uses all that space to keep track of last accessed information.
This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.