Author Topic: Invoice numbers  (Read 1510 times)

0 Members and 1 Guest are viewing this topic.

Offline clay1Topic starter

  • Enthusiast
  • Posts: 161
    • View Profile
Invoice numbers
« on: October 11, 2009, 01:29:12 AM »
Anyone have any tutorials or directions on creating invoice numbers?

I have a table called invoices with a column named invoicenumber which is set to a serial

I want to be able to assign a new invoice the next number in the sequence.

Offline artacus

  • Devotee
  • Posts: 915
  • Gender: Male
  • World domination? Never heard of it.
    • View Profile
    • Flex and Specs()
Re: Invoice numbers
« Reply #1 on: October 16, 2009, 12:51:50 AM »
Easiest way would be to use the keyword DEFAULT for the invoice number.

INSERT INTO invoices (invoicenumber, invoice_time, customer_id)
VALUES (DEFAULT, current_timestamp, 222);

Otherwise you can use nextval('invoice_seq') where invoice_seq is the name of your sequence.
artacus

-- Trust your leaders, depend on your government, don't question the media... and this won't hurt a bit. --