Hi, I'm using postgresql and I have a sequence to do ID++ for every record I inserted on the db. The problem isn't this, when I post my dbform I have to READ the value that POSTGRES has generated (with its sequence) for the ID because the NEXT FORM uses the same ID to store data in another table...
The system is like a "wizard" (step by step process) where all the forms share the same ID. How can I read the ID value? I tried with currentRow_tablename.get("Id") but it doesn't sound good. My step by step process is something like this 1. first step I have a form with localWebEvent="navNew" so the user can only ADDd a record, and the database generates the ID with the sequence... 2. second step if the data storing of the first step was sucessful I have to ask other things to the user maintaining the same ID. I'm not able to read the ID after the submit of the first form. So I tryed to use the interceptors on preinsert, but this can be a trouble with duplicate primary kes as you said. Any Idea? thanx Ivan *********** REPLY SEPARATOR *********** On 12/03/2004 at 17.06 Shawn wrote: >On Fri, 12 Mar 2004 08:41:56 +0100, Ivan Codarin ><[EMAIL PROTECTED]> wrote: > >> Hi, >> I've troubles with autoInc fields where the field is generated by Db. >> Is there a way to read up the (autogenerated) ID field to pass it to >> other forms? >> Now I'm creating interceptors to: >> >> 1) max_id =select max(id) from table >> 2) insert into table (id) values (max_id) >> 3) and pass this new value to the form with setFieldValue... >> >> It sounds complicated to do this to all forms. >> I'm using jdbforms 1.1.4pr2 13.12.2003. > >What database are you using? > >I talked this over with Henner before. He suggested using a sequence: > >"In Oracle - for example - you can >use a sequence and write a view to get values from the sequence. Most >databases have something like sequence. To be indepent from the database i >define a view in the database to get id - using a sequence." > >I can't use it myself (mysql doesn't have one) but it is a better idea >than selecting the Max value since doing it with a max value means it's >possible that if two users both insert at a simiar time, one of the users >could lose thier data with a "duplicate key message". Of course if you >have redisplay fields on error it is not so bad -- just a little confusing >for the user. > >Anyway, I am not exactly sure if using a sequence simplifies things >completely but it seems a better way if you can do it that way. >-- >Shawn > >Happily using M2, Opera's revolutionary e-mail client: >http://www.opera.com/m2/ ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click _______________________________________________ DbForms Mailing List http://www.wap-force.net/dbforms