Subject Re: [firebird-support] Autoincrement
Author Hans Hoogstraat
Woukl a trigger alike this procedure work for you ?

uniquenum is a Generator
DIV and MOD are UDF functions

CREATE PROCEDURE NEWPROC //( )
RETURNS ( a integer,b integer )
AS
DECLARE VARIABLE c integer;
BEGIN
c = gen_id(uniquenum,1);
a = div(c,4);
b = mod(c,4);
SUSPEND;
END

----- Original Message -----
From: "a_broekhuis" <akhorahil@...>
To: <firebird-support@yahoogroups.com>
Sent: Tuesday, April 27, 2004 6:13 AM
Subject: [firebird-support] Autoincrement


| Hi,
|
| I need a table to auto increment 2 fields, depending on each other. I
| know i have to use a trigger and a generator, but my question is: How
| can i increment the second field depending on the value in the first
| field?
|
| What I need is a table with 2 integers as prim key, the first is a
| simple auto incrementing number, the second is auto incrementing
| within the first.
|
| EG:
| 1 1
| 1 2
| 1 3
| 2 1
| 2 2
| 2 3
| 3 1
| 3 2
| ...
|
| TiA
|
| Alexander
|
|
|
|
|
| Yahoo! Groups Links
|
|
|
|