Dear All,
I have solved the problem using a sequence in postgresql and putting the
generated ID in a session variable using a pre-insert interceptor.

In postgresql I can do something like "select nextval(sequence_name)" and
the DBMS allocates a new ID without inserting it in the table....

So my preInsert interceptor uses that nextval to alloc a new ID, I put it
in  a session variable an than I know the ID generated from the JSP form.

Thanx to all
Ivan

> Hi Ivan,
>
> This can not work. You really have no change - execpt you have an single -
> to retrieve your new id from db.
>
> You can not formulate something like
>
> Select new record in sql.
>
> Your only change is to get the new id from the database in an preInsert
> interceptor and insert this id in the new record.
>
> Regards,
> Henner
>
>
>
>> -----Ursprüngliche Nachricht-----
>> Von: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] Im
>> Auftrag von Ivan Codarin
>> Gesendet: Samstag, 13. März 2004 20:05
>> An: [EMAIL PROTECTED]
>> Betreff: Re: [dbforms] AutoInc Field and Direct Insert on a form
>>
>> Hi All,
>>
>> I'm on the same problem of reading an autogenerated ID from a
>> sequence on a Postgresql datatabase.
>>
>> Shawn suggested me to use preUpdate and postUpdate to read
>> fields for the current row.
>>
>> Can I use a method like "getField" from postUpdate
>> interceptors to read an autogenerated field from the database?
>>
>> I'm not sure to be right but if I couldn't get the fieldvalue
>> from the postUpdate method the only way is to something like
>> this process:
>>
>> 1) in preUpdate method I have to store in a Session variabile
>> all the fields except the autogenerated ID (generated from DBMS)...
>>    [BUT COULD I USE SESSIONS FROM AN INTERCEPTOR??]
>>
>> 2) in postUpdate method I have to QUERY the database with a
>> whereclause with the data stored in the previous step to get the ID???
>>    [ALSO IN THIS CASE COULD I USE SESSION VARIABLES FROM AND
>> INTERCPETOR???]
>>
>> 3) the postUpdate returns void-data, so the return value from
>> postUpdate must be sended trough the session variables.
>>
>> So, is this right? Could I use Sessions from Interceptors, if
>> so, in which way?
>>
>> Many many many thanx
>> Ivan
>>
>> ---------------OTHER POST---------------------
>> > Dear All,
>> > I've a trouble with dbforms (1.1.4pr2 20031213).
>> > I have to create a form with this features
>> >
>> > - it has a field ID, autoInc=true, type=int, iskey=true This ID
>> > identifies a person during a process of registration of personal
>> > information.
>> >
>> > So,
>> > my form must start with a "insert-mode" WITHOUT clicking any
>> > "navNewButton", without a ID (it's generated from a sequence in
>> > postgresql).
>> > When the user clicks on "next" GotoButton (with autoUpdate)
>> or with a
>> > (Update/Insert button) the form has to store his info on the DB and
>> > then followup to the next step of registration.
>>
>>
>> >
>> > I'm not able to read the ID generated from the database to
>> create the
>> > "next step".
>>
>> In an pre update interceptor, you will have all the data
>> except the ID generated from the database.  I would store
>> that someplace to get it later-- probably in the session.
>> Then in a post update interceptor,
>>   you can get that info from the session and query the
>> database--> select ID from yourTable where (and then here use
>> all the info you saved).  Then put the ID in the session, and
>> clear the other information as it is no longer needed.
>> Finally in the next step of registration, the ID you need to
>> know is in the session.
>>
>> The only problem I see would be if that information (the stuff you
>> stored) could return more than one ID.   But I think you must
>> have other
>> keys too because an autoInc ID as the only key couldn't keep
>> users differentiated.
>>
>>
>> -------------------------------------------------------
>> 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_id=1470&alloc_id=3638&op=click
>> _______________________________________________
>> DbForms Mailing List
>>
>> http://www.wap-force.net/dbforms
>>
>
>



-------------------------------------------------------
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

Reply via email to