• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

autoincrement invoice

 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if this is servlet or jdbc but here goes.

MySql only lets you do AUTO_INCREMENT on one column and I am using it for the invoice id.

What can I do to do an auto generated INVOICE_NUMBER?

I would rather not select the max(invoice_id) and use that as the INVOICE_NUMBER

What else could I do?

CREATE TABLE INVOICE (
INVOICE_ID INT NOT NULL AUTO_INCREMENT,
USER_ID INT,
INVOICE_NUMBER INT NOT NULL,
INVOICE_DTE DATE,
SUBTOTAL NUMERIC(15,2),
SHIPPING_CHARGE NUMERIC(15,2),
TOTAL NUMERIC(15,2),
TAX NUMERIC(15,2),
COUPON_CODE_NUM VARCHAR(20),
IS_TAXED CHAR(1),
HAS_APPROVED CHAR(1),
HAS_SYNCED CHAR(1),
HAS_PROCESSED CHAR(1),
PRIMARY KEY (INVOICE_ID));


DAO
 
Pavan BH
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I know we cant give two fields as auto increment in MySql
Only Primary Key can be auto increment.
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Pavan BH" please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic