ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Albert L. Sapp" <as...@uiuc.edu>
Subject Re: dynamic query to pick up a sequence
Date Tue, 08 Nov 2005 22:58:39 GMT
Tom Stockton wrote:

>I've searched the archives, it doesn't look like this has come up before.  This is an
oracle example:
>
>    <select id="fetchNextInSequence" resultClass="java.util.HashMap">
>        Select #sequenceName#.nextval from dual
>    </select>
>
>in a nutshell, we want to pass the name of the sequence into the query and get the result
back.
>For instance, if I execute the query with an sequenceName = "APPLICATION_SEQ", we would
want the following SQL to be executed:
>
>Select APPLICATION_SEQ.nextval from dual
>
>It looks like the sql being executed is something along the lines of
>
>       select '#sequenceName#' nextval from dual
>
>what comes back in the map is a key-value pair of nextVal->APPLICATION_SEQ
>
>Can I use this approach?  If not, is there another approach to give me the same result
(not having to code an individual query for each sequence)?
>
>thanks,
>
>t
>
>
>
>
>
>  
>
In our sequence.xml file, we have for selecting a sequence the following 
code.

select '$name$' as name, $name$.nextval as nextid from dual

name is a parameter we pass that has the sequence name in it.  In your 
case, APPLICATION_SEQ would be passed in and the sequence number returned.

Hope this helps.


Mime
View raw message