You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Gabriel Corneanu <ga...@wireless-vision.de> on 2001/04/25 10:27:03 UTC

Help with esql results for 'insert' query

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: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Help with esql results for 'insert' query

Posted by Matthew Cordes <co...@cs.usm.maine.edu>.
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: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@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: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>