cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Cordes <mcord...@maine.edu>
Subject Re: Help with esql results for 'insert' query
Date Tue, 09 Jan 2001 13:20:05 GMT
This seems a little dangerous... What if someone inserts another record
before you make this call and after you inserted yours, won't you get their
owner_id, not yours?  

The best way to do this is simply disable whatever trigger is auto-creating 
the ids and select them yourself.  In oracle you do 

select <sequence_name>.nextVal from dual

then you could

insert into some_table (owner_id, ...) values (val_from_above, ...)

-matt

On Tue, Jan 09, 2001 at 07:26:48PM +0800, Perry Molendijk wrote:
> This will also return your latest entry:
> 
> SELECT MAX(owner_id) FROM owners
> 
> I have used in the past in asp applications so I can't see why it wouldn't
> work with esql
> 
> ----- Original Message -----
> From: "Paul Brown" <prb@fivesight.com>
> To: <cocoon-users@xml.apache.org>
> Sent: Tuesday, January 09, 2001 10:30 AM
> Subject: RE: Help with esql results for 'insert' query
> 
> 
> >
> > You want to "SELECT @@IDENTITY".  Be aware that triggers and transactions
> > affect its value.
> >
> > - Paul
> >
> > > -----Original Message-----
> > > From: eliza.khosrova@TMINUS10.com [mailto:eliza.khosrova@TMINUS10.com]
> > > Sent: Monday, January 08, 2001 7:11 PM
> > > To: cocoon-users@xml.apache.org
> > > Subject: Help with esql results for 'insert' query
> > >
> > >
> > > Hello,
> > >
> > > I am using MS SQL database and the tables are set up in a way that the
> > > primary keys get generated automatically when inserting entries.
> > > Is it feasible to get the generated id after 'insert' query in esql?
> > >
> > > Example:  I have a table called 'owners' with three columns:
> > > name, address,
> > > owner_id where owner_id is the primary key.
> > >
> > > After I insert as follows:
> > > <eql:execute-query>
> > >    <esql:query>insert into owners values('john smith')</esql:query>
> > >
> > > would query return the generated id for the entry that I just inserted?
> If
> > > so, what is the esql tags?  I don't seem to find it when looking at the
> > > esql logicsheet.  Please note that querying based on 'name' or 'address'
> > > will not help me because they are not necessarily unique, i.e. I
> > > could have
> > > entries with same names or address.
> > >
> > > Any help or suggestion is greatly appreciated.
> > > Eliza
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: cocoon-users-help@xml.apache.org
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> > For additional commands, e-mail: cocoon-users-help@xml.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
> 

Mime
View raw message