[Zope] (no subject)

Rob Page rob.page@digicool.com
Tue, 20 Apr 1999 10:23:43 -0400


>  seems to work fine (new data is entered in database) It only 
>  gives the
>  result text of 'this was not a query'... how comes?

Probably because the INSERT returns no data.  I don't know if this is a
feature/function of the Database Adapter or the underlying Python
database connection code.  The MS Access lash-up returns This query
returned no data.  I suppose that, _technically_, an INSERT isn't a
query (a question)... ??  :^)
  
>  2) I've made DTML Document with :
>  
>  <FORM METHOD="post" ACTION="???????">
>  <TABLE BORDER="0">
>  <TR>
>  <TD>New Item:</TD>
>  <TD><INPUT NAME="item_string"></TD>
>  </TR>
>  <TR>
>  <TD>Vendor:</TD>
>  <TD><INPUT NAME="vendor_string"></TD>
>  </TR>
>  <TR>
>  <TD>Quantity:</TD>
>  <TD><INPUT NAME="quantity_int"></TD>
>  </TR>
>  </TABLE>
>  <INPUT TYPE="submit">
>  </FORM>
>  
>  3) How do I glue these together? So that when pressing 
>  submit the values
>  are inserted in the database??
>  
>  I've putted the SQL Method in the ACTION, but this doesn't 
>  seem to work.
>  
>  4) Actualy It should return a new page with inserting of ... 
>  succesfull
>  (inserting ... was not successfull)... how can this be done?

Create a DTML document called drRecordInsert and make it the ACTION
target of your form listed above.  In dtRecordInsert do something like:

<!--#var standard_html_header-->

<!--#call sqlInsertNewItem-->
<P>Record inserted.</P>
<!--#var standard_html_footer

where sqlInsertNewItem is a SQLMethod...

  
>  5) Instead of letting the user enter the vendorname (<INPUT
>  NAME="vendor_string">), I would like to give him a combobox (<SELECT>
>  NAME...). This combobox should be filled with the result of 
>  a query to all
>  vendors in the database. How can this be done? i.e. Putting 
>  the result set
>  of a query in a select box.

how about another SQLMethod sqlGetAllVendors

and then in the form:

<SELECT NAME="vendor_string">

<!--#in sqlGetAllVendors-->
  <OPTION VALUE="<!--#var vendor_code_int-->"><!--#var
vendor_name--></OPTION>
<!--#/in-->

</SELECT>

>  6) If I 5 can be done, the insert SQL should slightly change :
>  
>  INSERT INTO list 
>  VALUES (<!--#sqlvar item_string type=string-->
>         ,<!--#sqlvar vendorcode_int type=int-->
>         ,<!--#sqlvar quantity_int type=int-->)
>  
>  with the vendorcode_int comming from another sql :
>  
>  select vendorcode
>  from vendors
>  WHERE <!--#sqltest vendor_name column=vendorname type=string-->

The original sql wouldn't change -- the vendor_code_int would still come
in with the REQUEST from the form!


Hope this helps!
-Rob