[Zope] zope + sql

ender kthangavelu@earthlink.net
Tue, 17 Apr 2001 01:54:27 -0700


On Tuesday 17 April 2001 07:03, William Herring wrote:
>>I'll try.
>>
>>I have a list of records from a single sql table that are viewed by the
>>browser using sql SELECT.  I would like to go down and 'check' or mark
>>certain specific records.  Then, for only the records that are
>>'checked', I would like to use sql UPDATE to replace the a value for one
>>of the variables.  The value replaced for that variable would be the
>>same for all of the marked records.

nutshell version

use a multi-select box on the form, use zope coercion to convert it to a list.

on the form processing page, convert the list to a comma separated string

in your select do a

update table_name
var_name = value
where pk in (value_comma_string)

hth

kapil





>>Steve Drees wrote:
>>> I'm not following your description of the problem.
>>> Can you give a more specific example?
>>>
>>>> -----Original Message-----
>>>> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
>>>> William Herring
>>>> Sent: Tuesday, April 17, 2001 7:49 AM
>>>> To: zope@zope.org
>>>> Subject: [Zope] zope + sql
>>>>
>>>>
>>>> I hope someone has an example or suggestion.
>>>>
>>>> Using Znolk, I SELECT from a table and the list is viewed.
>>>> However, I would
>>>> like to choose certain records (mark them  from the viewed list) and
>>>> then change a variable of only the marked records to a single new
>>>> value.  The new
>>>> and old variable values are finite, they could come from a pull down
>>>> list.
>>>>
>>>> So the idea would be to show the  list from SELECT, but have an
>>>> pull-down menu of new values at the top of the page that should be
>>>> replaced for the variable to edit.  The user would choose the new value
>>>> from the pull-down and then go down the page and mark each record for
>>>> which that
>>>> value would be
>>>> UPDATEed in the table
>>>>
>>>> Once this is done the values would be passed back to sql and
>>>> UPDATE used to
>>>> replace the old values.  I'm not quite sure how to do this either.  Do
>>>> you have a loop, where inside the loop the UPDATE is goes through each
>>>> marked record, or do you loop inside the
>>>>
>>>> UPDATE tablename set
>>>>     variable=newvalue
>>>>    where ----loop here with or's------
>>>>
>>>> Any suggestions or similar examples would be appreciated.
>>>>
>>>> --
>>>> ========================================
>>>> William Herring
>>>> Beef Cattle Genetics
>>>> S-132 Animal Science Research Center
>>>> University of Missouri, Columbia 65211
>>>> voice:573.884.6860
>>>> fax:573.882.4798
>>>> ========================================
>>>>
>>>>
>>>> _______________________________________________
>>>> 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 )