On śro, mar 05, 2003 at 09:33:50 +0100, Torsten Curdt wrote:
> >>>Am I right that even though I can use prepared statement I cannot rerun 
> >>>the
> >>>query several times without recreating the statement every time? I have 
> >>>a lot
> >>>of cases when I have to make a lot of same inserts basing on xml data 
> >>>from
> >>>request body.
> >>
> >>http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html
> >
> >Yeah nice. That's obvious. I know how to do it in JDBC. Just asking if ESQL
> >supports it.
> 
> Ah.. sorry.
> 
> No, not yet. Care enough for a patch? :)
Sure, at least I can try. Please comment my idea. 

Instead of in-place execution:

<xsp:logic>
int i;
for ( i = 0; i < count; ++i ) {
        somevar = somearray[ i ];
        
        <esql:execute-query>
                <esql:query>select foo from bar where blah =
                
<esql:parameter><xsp:expr>somevar</xsp:expr></esql:parameter></esql:query>
        <esql:results>
                <!-- standard stuff -->
        </esql:results>
        </esql:execute-query>

}
</xsp:logic>
you may do something like:

<esql:declare-prepared-query id="prepared-no1">
        select foo from bar where blah = <esql:parameter name="firstparam"/>
</esql:declare-prepared-query>

<xsp:logic>
int i;
for ( i = 0; i < count; ++i ) {
        <esql:set-param query="prepared-no1" name="firstparam">
                <xsp:expr>somearray[ i ]</xsp:expr>
        </esql:set-param>

        <esql:run-prepared-query id="prepared-no1">
                <esql:results>
                        <!-- standard stuff goes here -->
                </esql:results>
        </esql:run-prepared-query>
}
</xsp:logic>

What do you think ? 
        ouzo
-- 
            __
         | /  \ |        Leszek Gawron            //  \\
        \_\\  //_/      [EMAIL PROTECTED]          _\\()//_
         .'/()\'.     Phone: +48(600)341118     / //  \\ \
          \\  //  recursive: adj; see recursive  | \__/ |

Reply via email to