multiple INSERT in one sql method
Is it possible to do more than one INSERT in a single SQL method?
Is it possible to do more than one INSERT in a single SQL method?
Apparently not, but I also tried the following and it returned to me this: ok you added foo ok you added bar ok you added baz But the database was NOT modified. thing.html: <FORM METHOD=POST ACTION="inserts.html"> <SELECT NAME="asdf" MULTIPLE SIZE=4> <option selected value="foo">foo <option selected value="bar">bar <option selected value="baz">baz </SELECT> <input type=submit></FORM> inserts.html: <!--#in asdf--> <!--#call inserts(_.['sequence-item'])--> ok you added <!--#var sequence-item--><br> <!--#/in--> inserts: (arguments: thingie) INSERT INTO sodas VALUES (<!--#sqlvar thingie type=nb-->,'blah');
"Daniel M. Drucker" wrote:
Is it possible to do more than one INSERT in a single SQL method?
Apparently not,
See my other message.
but I also tried the following and it returned to me this:
ok you added foo ok you added bar ok you added baz
But the database was NOT modified.
That's odd. Hm...
thing.html: <FORM METHOD=POST ACTION="inserts.html"> <SELECT NAME="asdf" MULTIPLE SIZE=4> <option selected value="foo">foo <option selected value="bar">bar <option selected value="baz">baz </SELECT> <input type=submit></FORM>
inserts.html: <!--#in asdf--> <!--#call inserts(_.['sequence-item'])-->
When you call an SQL method, you need to use keyword arguments: <!--#call inserts(thingie=_.['sequence-item'])--> I'm really surprized you didn't get an error message. Are you sure the SQL method didn't give a default for thingie? Jim -- Jim Fulton mailto:jim@digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
"Daniel M. Drucker" wrote:
Is it possible to do more than one INSERT in a single SQL method?
Yup. You need to use use sql_delimiter variable: insert into data values(1) <!--#var sql_delimiter--> insert into data values(2) Basically, you can have any number of sql statements separated by the delimiter. You cannot use more than one select statement. (Some DAs let you have multiple selects if the result tables all have the same schema.) Jim -- Jim Fulton mailto:jim@digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
Yes, I'm using Gadfly and have: INSERT INTO table VALUES ( 'a', 'b', 'c', ... ); INSERT INTO table VALUES ( 'd', 'e', 'f', ... ); ... INSERT INTO table VALUES ( 'p', 'q', 'r', ... ) * Note the semicolon after all INSERTs but the last. Larry
Yes, I'm using Gadfly and have:
I'm using MySQL. While <!--#var sql_delimiter--> works fine, a semicolon doesn't... ineresting.
INSERT INTO table VALUES ( 'a', 'b', 'c', ... ); INSERT INTO table VALUES ( 'd', 'e', 'f', ... ); INSERT INTO table VALUES ( 'p', 'q', 'r', ... ) * Note the semicolon after all INSERTs but the last.
"Daniel M. Drucker" wrote:
Yes, I'm using Gadfly and have:
I'm using MySQL. While <!--#var sql_delimiter--> works fine, a semicolon doesn't... ineresting.
INSERT INTO table VALUES ( 'a', 'b', 'c', ... ); INSERT INTO table VALUES ( 'd', 'e', 'f', ... ); INSERT INTO table VALUES ( 'p', 'q', 'r', ... ) * Note the semicolon after all INSERTs but the last.
The use of a semicolon is a featue of some SQL UIs, it is not part of SQL. SQLMethod use <!--#var sql_delimiter--> instead. Jim -- Jim Fulton mailto:jim@digicool.com Technical Director (540) 371-6909 Python Powered! Digital Creations http://www.digicool.com http://www.python.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
Larry Luther wrote:
Yes, I'm using Gadfly and have: INSERT INTO table VALUES ( 'a', 'b', 'c', ... ); INSERT INTO table VALUES ( 'd', 'e', 'f', ... ); ... INSERT INTO table VALUES ( 'p', 'q', 'r', ... ) * Note the semicolon after all INSERTs but the last.
... And here's one way to implement this logic (ain't it great how all these tricks are built into Zope for when you need them!): <!--#with REQUEST--> delete from rests where rest_index in ( <!--#in delkey--> '<!--#var sequence-item-->' <!--#unless sequence-end--> , <!--#/unless--> <!--#/in--> ) <!--#/with--> Note that I'm deleting rows here, but same idea... - Craig -- Craig Allen - Managing Partner - Mutual Alchemy Web Architecture - http://alchemy.nu
participants (4)
-
Craig Allen -
Daniel M. Drucker -
Jim Fulton -
Larry Luther