aspose file tools*
The moose likes JDBC and the fly likes autoincrement invoice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "autoincrement invoice" Watch "autoincrement invoice" New topic
Author

autoincrement invoice

John Schretz
Ranch Hand

Joined: Sep 10, 2008
Posts: 188
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

Joined: Sep 21, 2008
Posts: 7
As I know we cant give two fields as auto increment in MySql
Only Primary Key can be auto increment.
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

"Pavan BH" please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.


SCJP, SCWCD.
|Asking Good Questions|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: autoincrement invoice