What is the difference between varchar and text.  H2 specifically rejects 
using unique or primarykey for text fields.

Also, this does not solve the problem of caching the preparedStatement in 
the function.  Any suggestions there?

On Monday, October 22, 2012 12:37:51 PM UTC-6, Vasile Rotaru wrote:
>
> So what's wroing with:
>
>       create table unique_names (id identity, name varchar not null unique)
>
> You can even make the a column of type varchar the primary key. I did.
>  
> On Mon, Oct 22, 2012 at 7:18 PM, Brent Ellwein 
> <[email protected]<javascript:>> 
> wrote: 
>
> 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]<javascript:>
>> .
>> To unsubscribe from this group, send email to 
>> [email protected] <javascript:>.
>> For more options, visit this group at 
>> http://groups.google.com/group/h2-database?hl=en.
>>
> -- 
>    Vasile Rotaru
>

-- 
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/-/qQXvrCc7kPAJ.
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