SQL auto increment by group with INSERT..

2555 pts.
Tags:
AS/400
Incremental backup
SQL
SQL INSERT
V6R1
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following