SQL auto increment by group with INSERT..
245 pts.
0
Q:
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: Aug 21 2009  11:19 AM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
1840 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
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 Answered: Aug 25 2009  6:10 PM GMT by Meandyou   1840 pts.
Latest Contributors: Mrdenny   46765 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



0