• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best Way for auto-increment/sequence generation upon a composite-key with 2 columns

 
slreddy kollu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am intermediate to Java, please suggest me best Way for developing a logic for auto-increment/sequence generation upon a composite-key with 2 columns.

Complete Description:

I want to have Composite Primary Key on two columns like this :

PRIMARY KEY (`base`, `id`);

for which base to be auto-incremented and based on that id be auto-incremented for the same base

Example:

base id
A 1
A 2
B 1
C 1


The base currently represents a company, the id represents invoice number.

There should be auto-incrementing invoice numbers for each company but there could be cases where two companies have invoices with the same number.

Technology Used: JSP, Servlets with Sybase Database.

Is it possible to do it with programming exactly?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic