• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

autoincrement invoice

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Remember to always leap before you look. But always take the time to smell the tiny ads:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic