[Zope] setting 'arguments' string dynamically in a ZSQL metho d

Chas Wareing c3w@isp.net
Fri, 8 Jun 2001 04:04:22 -0700


Holger-

this still appears to have fixed variable names- my variable
names are dynamic, based on sql column names so I can't
predefine their existance in the ZSQL 'arguments' box-

this is my qryInsert object as of tonight (this morning)
- it would work in the proper namespace- 

field is a sql column, as in 'firstname' or 'address'.
_[field] is then its value, which is set in a previous
http post form- the ZSQL method bombs out when it can't
see the post variables

INSERT into <dtml-var sqlvarTable>
(
<dtml-in "qryShowColumns(sqlvarTable=sqlvarTable)">
<dtml-if sequence-end>
	<dtml-var field>
<dtml-else>
	<dtml-var field>,
</dtml-if>
</dtml-in>
)
VALUES ( 
<dtml-in "qryShowColumns(sqlvarTable=sqlvarTable)">
<dtml-if sequence-end>
	<dtml-sqlvar "_[field]" type=string>
<dtml-else>
	<dtml-sqlvar "_[field]" type=string>,
</dtml-if>
</dtml-in>
)

Chas.

-----Original Message-----
From: Holger Lehmann [mailto:lehmann@catworkx.de]
Sent: Friday, June 08, 2001 3:38 AM
To: Chas Wareing; 'zope@zope.org'
Subject: Re: [Zope] setting 'arguments' string dynamically in a ZSQL
method


Hi Chas,

why not trying this:
(assuming three hardcoded parameters)

<dtml-in "YourSQLMethod(param1=value1,param2=value2,param3=None)">

and another time:

<dtml-in
"YourSQLMethod(param1=value5,param2=_['variable10'],param3=value4)">

with something like this in your ZSQLMethod:

params:
param1, param2, param3

sql (warning untested):
<dtml-if "param3!='None'">
select * from foo where ..... 
<dtml-else>
select * from bar where ....
</dtml-if>

**and** set the advanced setting " max rows retreived " to 0 (zero) to stop 
the ZSQLMethod from appending SQL code to your statement dynamically.


- Holger

Am Freitag,  8. Juni 2001 11:58 schrieb Chas Wareing:
> I've been spending way too much time on this--
>
> I'd like to set the 'arguments' string while calling a ZSQL method
> instead of hardcoding it on the method- my variable names are dynamic
>
> a namespace hack or zsql product patch would be appreciated-
>
> I'm using this for a generic/reusable qryInsert object-
>
> Chas. <c3w@ISP.NET>
> ISP Networks, Inc.
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )

-- 
-----------------------------------
catWorkX GmbH
Dipl.-Ing. Holger Lehmann
Stresemannstr. 364
22761 Hamburg
Tel: +49 (0700) catWorkX
Tel: +49 (40) 890 646-0
Fax: +49 (40) 890 646-66
mailto:lehmann@catworkx.de
http://www.catworkx.de
http://www.catbridge.de