You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Marcus Crafter <cr...@dresdnerbank.de> on 2000/11/04 13:51:07 UTC

[C2] xsp in esql ? (was Re: [C2] esql connections diff)

Hi Donald (and others),

	What are your thoughts about being able to parameterize the queries
	with your suggested syntax, perhaps with xsp ? For example:

<esql:connection>

	<esql:driver>...</esql:driver>

	<xsp:logic>
		for (int i=0; i &lt; sz; i++) {
			<esql:execute-query>
				<esql:query>
					INSERT INTO mytable VALUES
					('<xsp:expr>field[i]</xsp:expr>');
				</esql:query>
			</esql:execute-query>
		}
	</xsp:logic>

</esql:connection>

	This is something we've done here in C1 using the SQL processor (xsp
	is done first, then the sql processor). Such abilities in esql would
	also be very useful.
	
	I guess it's a general question about using xsp within esql.
	What do you think ? (or is this already possible ?)

	Cheers,

	Marcus

-- 
        .....
     ,,$$$$$$$$$,      Marcus Crafter
    ;$'      '$$$$:    Computer Systems Engineer
    $:         $$$$:   Open Software Associates GmbH
     $       o_)$$$:   82-84 Mainzer Landstrasse
     ;$,    _/\ &&:'   60327 Frankfurt Germany
       '     /( &&&
           \_&&&&'     Email : Marcus.Crafter@osa.de
          &&&&.        Business Hours : +49 69 9757 200
    &&&&&&&:           After Hours    : +49 69 49086750


Re: [C2] xsp in esql ? (was Re: [C2] esql connections diff)

Posted by Donald Ball <ba...@webslingerZ.com>.
On Sat, 4 Nov 2000, Marcus Crafter wrote:

> Hi Donald (and others),
> 
> 	What are your thoughts about being able to parameterize the queries
> 	with your suggested syntax, perhaps with xsp ? For example:
> 
> <esql:connection>
> 
> 	<esql:driver>...</esql:driver>
> 
> 	<xsp:logic>
> 		for (int i=0; i &lt; sz; i++) {
> 			<esql:execute-query>
> 				<esql:query>
> 					INSERT INTO mytable VALUES
> 					('<xsp:expr>field[i]</xsp:expr>');
> 				</esql:query>
> 			</esql:execute-query>
> 		}
> 	</xsp:logic>
> 
> </esql:connection>
> 
> 	This is something we've done here in C1 using the SQL processor (xsp
> 	is done first, then the sql processor). Such abilities in esql would
> 	also be very useful.
> 	
> 	I guess it's a general question about using xsp within esql.
> 	What do you think ? (or is this already possible ?)

yes, it's already possible - you want to use prepared statements here so
that you don't have to worry about escaping apostraphes and such. try:

<esql:statement>insert into mytable values (
 <esql:parameter><xsp:expr>field[0]</xsp:expr></esql:parameter>
)
</esql:statement>

i'm probably going to merge the statement and query elements, i'll just
consider a query to be a prepared statement if a parameter element appears
inside it. :)

- donald