2,540 pts.
 SQL auto increment by group with INSERT..
Is it possible to define an auto-incremental coloumn which increments by 'group' ?

I want to create a version log for an old table (uniquely keyed 'HOWTONO') which contains records with 'How to' data in the form of short code-fields and some long fields with text.  I intend to trigger updates, inserts  and deletions from this table, and use SQL in the trigger pgm to INSERT a record in a new  SQL-defined table  'VERSIONS'.

This new file shall be keyed by (HOWTONO + versionnumber).

Is it possible to define the 'versionnumber'-coloumn such that it is incrementet [strong]within[/strong] the group of a [strong]single[/strong] HOWTONO number?

 

 



Software/Hardware used:
9407/M15 (Power6) running V6R1
ASKED: August 21, 2009  11:19 AM
UPDATED: August 25, 2009  6:10 PM

Answer Wiki:
Automatically, no. You would need to handle that numbering yourself via your stored procedure code. ------------------ Or use an IDENTITY or SEQUENCE data type, depending on your RDBMS (DB2 and Oracle support these). Or maybe I don't understand your question.
Last Wiki Answer Submitted:  August 25, 2009  6:10 pm  by  Denny Cherry   64,520 pts.
All Answer Wiki Contributors:  Denny Cherry   64,520 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _