Im storing information in a talble (Invoice), and at the end; the table is generating a number(Invoice #). ie im trying to generate an invoice # which is unique. I know how to save the info, but my problem is how to retrieve this number. Is there a way to read the Invoice # column prior to closing. Thank u for your time
1. If you are using oracle: you can "select sequence.nextval from dual" then use that number as the primary key in an insert statement(guaranteed not to be duplicated) 2. in the JDK 1.4SE there is a method that upon insert, also returns the autonumber field. I don't know of any drivers that implement this yet though. 3. create an autonumber class that will return a unique number, then insert it. 4. Synchronize your insert block that includes a "select max(invoice_id) from table" after your insert which will return the last inserted record's autonumber/pk field. Which database are you using? Jamie
Originally posted by john mattucci: isnt there a way to call the row u are inserting information into. That way I can go back and call the invoice# from this row. Thank u for yor help
There might be a way programmatically:
moveToCurrentRow public void moveToCurrentRow() throws SQLException Moves the cursor to the remembered cursor position, usually the current row. This method has no effect if the cursor is not on the insert row.
but I've always been more of a fan of using strictly SQL statements. Jamie.
It is no measure of health to be well adjusted to a profoundly sick society. -Krishnamurti Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss