ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tom Stockton" <TStock...@Policy-Studies.com>
Subject dynamic query to pick up a sequence
Date Tue, 08 Nov 2005 22:41:58 GMT
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





Mime
View raw message