• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

autoincrement invoice  RSS feed

 
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
 
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.
 
Bartender
Posts: 2856
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!