Trigger question (auto-increment)
Martin S.
blackfin at elfenherz.de
Thu Oct 18 08:51:45 CDT 2007
Bart Pietercil schrieb:
> 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
>
no, this does not work inside a trigger (unexpected token: SELECT)
:(
>
> I don't see why this would not work
>
> hth
>
> Bart
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina
>
More information about the Valentina
mailing list