Trigger question (auto-increment)

Bart Pietercil bart.pietercil at gmail.com
Thu Oct 18 07:49:56 CDT 2007


Hi Martin,

On 18-okt-07, at 14:20, Martin S. wrote:

> As I understand, I can emulate auto-increment fields with triggers.
> But how?
> Is it possible to get the maximum value of a field inside a trigger?
> What I like to do is, on INSERT, find the maximum value of field  
> "autoid", increment it by one and set the new autoid to this.
>
> I want a trigger that does something like this (pseudo code):
>
> CREATE OR REPLACE TRIGGER TABLE1_BEFORE_INSERT BEFORE INSERT
> ON TABLE1 FOR EACH ROW
> BEGIN



New.AutoID = SELECT MAX(AutoID)+1 FROM Table1

>  ; END

I don't see why this would not work

hth

Bart


More information about the Valentina mailing list