Having problems with SQL methods
I have an SQL method: ID: insert_call_data.sql TITLE: Insert Call Data Query ARGUMENTS: user_id, call_type_id, call_desc, call_date, costcode_id Query Template: INSERT INTO calls (user_id, call_type_id, call_desc, call_date, costcode_id) VALUES ( <dtml-sqlvar user_id type=int>, <dtml-sqlvar call_type_id type=int>, <dtml-sqlvar call_desc type=string>, <dtml-sqlvar call_date type=nb>, <dtml-sqlvar costcode_id type=int> ); When I do a change and test, I get the form to fill out, and I fill out the arguments. When I submit the query, I get this: Error, Missing Input: Missing input variable, user_id SQL used: Could not render the query template! And this traceback: Traceback (innermost last): File /opt/Zope/lib/python/ZPublisher/Publish.py, line 214, in publish_module File /opt/Zope/lib/python/ZPublisher/Publish.py, line 179, in publish File /opt/Zope/lib/python/Zope/__init__.py, line 201, in zpublisher_exception_hook (Object: insert_call_data.sql) File /opt/Zope/lib/python/ZPublisher/Publish.py, line 165, in publish File /opt/Zope/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: manage_test) File /opt/Zope/lib/python/ZPublisher/Publish.py, line 102, in call_object (Object: manage_test) File /opt/Zope/lib/python/Shared/DC/ZRDB/DA.py, line 316, in manage_test (Object: insert_call_data.sql) File /opt/Zope/lib/python/Shared/DC/ZRDB/DA.py, line 295, in manage_test (Object: insert_call_data.sql) File /opt/Zope/lib/python/Shared/DC/ZRDB/DA.py, line 395, in __call__ (Object: insert_call_data.sql) File /opt/Zope/lib/python/DocumentTemplate/DT_String.py, line 502, in __call__ (Object: <string>) File /opt/Zope/lib/python/Shared/DC/ZRDB/sqlvar.py, line 168, in render (Object: user_id) Missing Input: (see above) What am I doing wrong? Is this the best way of inserting data into tables? Is there a document I should read before posting such newbie questions? (I *have* read the Z SQL Methods User's Guide, but that seems to have nothing on inserting data) Regards Peter. -- Peter Whysall Systems Engineer Serco Technology
Peter Whysall schrieb:
I have an SQL method:
ID: insert_call_data.sql TITLE: Insert Call Data Query ARGUMENTS: user_id, call_type_id, call_desc, call_date, costcode_id
Use a simple space - without a comma - to separate the arguments of the ZSQL Method. hth, thomas
Query Template:
INSERT INTO calls (user_id, call_type_id, call_desc, call_date, costcode_id) VALUES ( <dtml-sqlvar user_id type=int>, <dtml-sqlvar call_type_id type=int>, <dtml-sqlvar call_desc type=string>, <dtml-sqlvar call_date type=nb>, <dtml-sqlvar costcode_id type=int> );
When I do a change and test, I get the form to fill out, and I fill out the arguments.
When I submit the query, I get this:
Error, Missing Input: Missing input variable, user_id
SQL used:
Could not render the query template!
And this traceback:
Traceback (innermost last): File /opt/Zope/lib/python/ZPublisher/Publish.py, line 214, in publish_module File /opt/Zope/lib/python/ZPublisher/Publish.py, line 179, in publish File /opt/Zope/lib/python/Zope/__init__.py, line 201, in zpublisher_exception_hook (Object: insert_call_data.sql) File /opt/Zope/lib/python/ZPublisher/Publish.py, line 165, in publish File /opt/Zope/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: manage_test) File /opt/Zope/lib/python/ZPublisher/Publish.py, line 102, in call_object (Object: manage_test) File /opt/Zope/lib/python/Shared/DC/ZRDB/DA.py, line 316, in manage_test (Object: insert_call_data.sql) File /opt/Zope/lib/python/Shared/DC/ZRDB/DA.py, line 295, in manage_test (Object: insert_call_data.sql) File /opt/Zope/lib/python/Shared/DC/ZRDB/DA.py, line 395, in __call__ (Object: insert_call_data.sql) File /opt/Zope/lib/python/DocumentTemplate/DT_String.py, line 502, in __call__ (Object: <string>) File /opt/Zope/lib/python/Shared/DC/ZRDB/sqlvar.py, line 168, in render (Object: user_id) Missing Input: (see above)
What am I doing wrong? Is this the best way of inserting data into tables? Is there a document I should read before posting such newbie questions? (I *have* read the Z SQL Methods User's Guide, but that seems to have nothing on inserting data)
Regards
Peter. -- Peter Whysall Systems Engineer Serco Technology
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(To receive general Zope announcements, see: http://www.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
I have an html table where each cell in one column is a form with a button. I am trying to have the submit button perform the sql shown below. The database connection is to a MySQL Table. I've looked on the Zope site at: http://www.zope.org/Documentation/Guides/ZSQL/ZSQL-HTML/ZSQL.2.5.4.html and see that if an sqltemplate is used that the first lookup for the var is in the http request. The add2dun is an enum Y,N. The test works but if I use the action shown below I just get the test page with the url ..../y_add2dun/manage_test I've changed the last line to just ="<dtml-var ID>" and get the same results. In the page where the button is pressed the <dtml-var ID> is actually an integer in the source code of the html as I expected. Any help would be appreciated. I've also looked at the new sql How tos and they deal with forms that have fill in boxes which I've had no problem with the fill in boxes but thanks for the How-To's SQL: ID=y_add2dun Arguments= ID UPDATE askref SET add2dun='Y' WHERE ID="<dtml-sqlvar ID type=int>" COLUMNS in MySQL TABLE: |ID|Date|Submitter|Phone|add2dun|add2faq|responder| --------------------------------------------------- HTML IN DTML DOCUMENT( this is one cell in a table from a previous sql to display all where add2dun='N' and responder=''): <td><form method=post action=y_add2dun value="<dtml-var ID>" name="ID"> <input type ="submit" name="submit" value="ADD"></form></td> Thanx Thomas -------------------------------------------------------------------- Rock and Rule Zope Rocks -- http://www.zope.org Python Rules -- http://www.python.org -------------------------------------------------------------------- Thomas McMillan Grant Bennett Appalachian State University Computer Consultant II University Library bennettt@am.appstate.edu http://www.library.appstate.edu/webmaster/ Voice: 828 262 6587 FAX: 828 262 3001 Windows 95 is a 32-bit extension to a 16-bit patch for an 8-bit operating system that was originally coded for a 4-bit microprocessor. - Chris Dunphy Boot Magazine
participants (3)
-
Peter Whysall -
Thomas Weiner -
TMGB