[Zope] dtml-sqlgroup for other SQL actions

Ed Leafe ed@leafe.com
Wed, 17 Jul 2002 20:17:34 -0400


	I think I've gotten the hang of using the dtml-sqlgroup tags for 
creating variable queries, so I'm wondering if there are related tags 
that will work for other SQL functions; specifically, Update.

	I have a table that can be updated from various forms, and the 
forms will have different numbers of fields, depending on things like 
security, etc. I'd like to have a single ZSQL method for this, but since 
the various fields in an SQL Update command are joined by commas, not 
ANDs, I'm not sure how this can be done. For example, let's say that the 
ZSQL method for updating a table called 'People' might have the 
following arguments: cLast, cFirst, cSSN, cPhoneNum. One form might 
return just the first name and last name, and the SQL should look like:

UPDATE People
SET
<dtml-sqlvar cLast type="string">,
<dtml-sqlvar cFirst type="string">
WHERE <dtml-sqltest cSSN op="eq" type="string">

while a second form might pass just last name and phone number, 
generating this SQL:

UPDATE People
SET
<dtml-sqlvar cLast type="string">,
<dtml-sqlvar cPhoneNum type="string">
WHERE <dtml-sqltest cSSN op="eq" type="string">

and a third might pass 'em all:

UPDATE People
SET
<dtml-sqlvar cLast type="string">,
<dtml-sqlvar cFirst type="string">,
<dtml-sqlvar cPhoneNum type="string">
WHERE <dtml-sqltest cSSN op="eq" type="string">

	So is there something I'm missing? Or do I need to code this myself?

      ___/
     /
    __/
   /
  ____/
  Ed Leafe
  http://leafe.com/
  http://foxcentral.net