Hello,

I am trying to have a unique String column for my H2 database 
implementation.  As this is not natively supported, I'm walking around in 
the weeds a little bit, and store the hash of the string in an indexed 
column in the table.  For insert, I have a two-part check.

1)  see if a row exists with the String value using an SQL select 
statement, if so return the generated ID for the already existing row.
2)  insert the new row and then return the resulting generated ID.

This seems to work fine with a combination of a select statement and a 
followup insert statement.  BUT what I would like to do is write a stored 
procedure which does it all at once and then returns the id value quickly.  
I was able to write this function.  However, I cannot seem to cache the 
prepared statement in my function call, and thus generate the statement for 
each call.  The end result is that the stored procedure executes more 
slowly than running several calls through a client with cached stored 
procedures.

Thus my question is, is there a way to cache a prepared statement from 
within a stored procedure?  Is there a better approach to the problem which 
I have not yet thought of?

Thanks you for your input.
--Brent

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/h2-database/-/P4Pa9RQ1EgMJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to