• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

maximum value

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Help please
What is the fastest way to get the maximum value in the field.
I need to get this value to my variable and use it as a base for deriving my invoice number.
 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fastest way? Use an AUTONUMBER field in something like Oracle or MySQL - let it get the next number, and then build your invoice number off of it. Alternatively,

Make sure you synchronize invoice number creation/usage so that you don't reuse your number (or have some other scheme for unique invoice number creation - using a unique key on invoice number is typical, to validate that created numbers are unique).
Depending on your database/enterprise architecture, you could theoretically also write a trigger that creates the invoice number upon insert of a record. The advantage there is that you know everyone inserting a record is using the same algorithm for creating an invoice number.
 
Manuel Paco
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.
Select MAX(number) from . . .
How do I get value from that?
 
Manuel Paco
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it. Works. Thanks.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic