cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Cordes <cor...@cs.usm.maine.edu>
Subject Re: Help with esql results for 'insert' query
Date Wed, 25 Apr 2001 13:44:41 GMT
Hi Gabriel,

Can you explain what you're trying to do, sorry I missed the beginning 
of this thread.

It sounds like your trying to store unique ids in a field.  Using 
select MAX(..) and adding 1 is very bad (assuming your db is multi-threaded).
You're using mysql, so why not make that field auto-increment itself (I'm 
pretty sure you can specify this when creating the table), then you could 
insert a new record and it would pick an appropriate number (like a sequence
and trigger combo in oracle).

If I've missed the point of this discussion entirely please enlighten me.

-matt


On Wed, Apr 25, 2001 at 10:27:03AM +0200, Gabriel Corneanu wrote:
> Hi,
> I have just faced the same problem, and I have read your messages. Did
> you solve it?
> The "SELECT MAX(...)" solution wouldn't satisfy serious people.
> I don't know if the ones who suggested the "select last_insert_id()"
> have tried it. It didn't work for me because it is connection oriented,
> and esql generates code that closes the connection. The above statement
> returns 0. Am I right?
> Probably the stored proc solution is the best, with some questions about
> how to use the result.
> My problem is that I use MySql, so there is no stored proc. This more
> difficult. The only way to solve it was to write another taglib (copy of
> esql) and to create one tag for accessing the statement. This can be
> used as "org.gjt.mm.mysql.Statement" and use the "getLastInsertID()"
> function.
> I don't like it because it makes use of a specific library. What if
> using another driver?
> If there is a simpler way, please tell me.
> 
> Gabriel
> 
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> 
> To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail: <cocoon-users-help@xml.apache.org>
> 

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

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