[Zope] Passing lists to zsql methods
steve smith
ssmith6@bigpond.net.au
Fri, 6 Oct 2000 22:17:11 +1000
I have a form comprising two selection lists, each supporting multiple
selection. I want the inputs to become parameters to a zsql method. I find
the input works if the user selects at least one item from each list, but
fails with a 'bad object id' message if either list is left unselected. I
have tried providing a default list value, no luck. Any ideas out there?
The form looks like:
<dtml-var standard_html_header>
<p><font face="Arial">Use this form to specify the parameters for your query
or
submission
<p>All fields are optional
<p>Multiple selection is supported - hold down the CONTROL key</font>
</p>
<FORM action="dtSubmitRumour">
<SELECT name="Operators:list" multiple>
<dtml-in dbRetrieveAllOperators>
<OPTION VALUE='<dtml-var OperatorID>'>
<dtml-var FullName null="None in particular">
</OPTION>
</dtml-in>
</SELECT>
<SELECT name="Classes:list" multiple>
<dtml-in dbRetrieveAllClasses>
<OPTION VALUE='<dtml-var OperatorClassID>'>
<dtml-var "FullName + OperatorClass + ' Class'">
</OPTION>
</dtml-in>
</SELECT>
<input type="submit" value="Submit" name="B1"></p>
</FORM>
and the zsql method reads:
use thetable
BEGIN transaction INSERT INTO rumours
(Description)
VALUES (<dtml-sqlvar Description type=nb optional>)
DECLARE @rumourid int
SELECT @rumourid = MAX(rumourid)
FROM rumours
COMMIT
<dtml-if Operators>
<dtml-in Operators>
INSERT
INTO roperators(rumourid, OperatorID)
VALUES (@rumourid, <dtml-sqlvar sequence-item type=int>)
</dtml-in>
</dtml-if>
<dtml-if Classes>
<dtml-in Classes>
INSERT
INTO rclasses(rumourid, ClassID)
VALUES (@rumourid, <dtml-sqlvar sequence-item type=int>)
</dtml-in>
</dtml-if>