Re: ZSQL Question - Insert multiple rows in one statement?
Sascha Gottfried <[email protected]> Tue, 24 Aug 2010 17:55:29 +0200
| Newsgroups | gmane.comp.web.zope.database |
|---|---|
| Message-ID | <[email protected]> |
This is a MIME-formatted message. If you see this text it means that your E-mail software does not support MIME-formatted messages. --===============8824124588400750987== Content-Type: multipart/alternative; boundary="=_maila-8882-1282665330-0001-2" This is a MIME-formatted message. If you see this text it means that your E-mail software does not support MIME-formatted messages. --=_maila-8882-1282665330-0001-2 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-Mime-Autoconverted: from 8bit to quoted-printable by courier 0.65.0 Hi Mark, it is best to do the looping in python. consider the python script as=20 the proper place to process the form values taken from the request=20 variable. No problem to invoke multiple zsql method calls from within=20 this script. I even remember that all invoked zsql methods in one=20 requests belong to a transaction. If one fails, a rollback is done. Your=20 ZSQL connection has to be configured properly to use transactions and=20 your server has to support them as well. Just in case you do not already found this - latest zope book and the=20 chapter about SQL connectivity http://docs.zope.org/zope2/zope2book/RelationalDatabases.html Am 24.08.2010 17:03, schrieb Mark Phillips: > When I retrieve multiple values from a selection box, I need to create=20 > a loop somewhere to insert the multiple values (rows) into a table. Is=20 > there a way to do this within a ZSQL statement, or is it best to do=20 > the looping in a Python script? > > My specific example.... > > table 1 (Players) has information about players (i.e. team members for=20 > a sports team). There is a primary key - playerID > table 2 (Seasons) has information about each season - primary key is=20 > seasonID > table 3 (PlayerSeasons) has two columns - playerID and seasonID. > > The form to crud a player has a combobox where one can select multiple=20 > seasons for a player. When I do an add or update, I have to add one or=20 > more rows to the PlayerSeasons table. Does this loop have to be in a=20 > Python script, or can it be implemented in ZSQL? I looked at the=20 > 'multiple' keyword, but all the examples indicate that it apples to=20 > sql tests, such as testing against a set of values. I can't seem to=20 > find any examples where one is inserting multiple rows into a table. > > Thanks! > > Mark > > > _______________________________________________ > Zope-DB mailing list > [email protected] > https://mail.zope.org/mailman/listinfo/zope-db > > > > __________ Hinweis von ESET NOD32 Antivirus, Signaturdatenbank-Version = 5393 (20100824) __________ > > E-Mail wurde gepr=FCft mit ESET NOD32 Antivirus. > > http://www.eset.com > > =20 __________ Hinweis von ESET NOD32 Antivirus, Signaturdatenbank-Version 53= 93 (20100824) __________ E-Mail wurde gepr=FCft mit ESET NOD32 Antivirus. http://www.eset.com --=_maila-8882-1282665330-0001-2 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 7bit <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#ffffff" text="#000000"> Hi Mark,<br> <br> it is best to do the looping in python. consider the python script as the proper place to process the form values taken from the request variable. No problem to invoke multiple zsql method calls from within this script. I even remember that all invoked zsql methods in one requests belong to a transaction. If one fails, a rollback is done. Your ZSQL connection has to be configured properly to use transactions and your server has to support them as well. <br> <br> Just in case you do not already found this - latest zope book and the chapter about SQL connectivity<br> <a class="moz-txt-link-freetext" href="http://docs.zope.org/zope2/zope2book/RelationalDatabases.html">http://docs.zope.org/zope2/zope2book/RelationalDatabases.html</a><br> <br> Am 24.08.2010 17:03, schrieb Mark Phillips: <blockquote cite="mid:[email protected]" type="cite">When I retrieve multiple values from a selection box, I need to create a loop somewhere to insert the multiple values (rows) into a table. Is there a way to do this within a ZSQL statement, or is it best to do the looping in a Python script?<br> <br> My specific example....<br> <br> table 1 (Players) has information about players (i.e. team members for a sports team). There is a primary key - playerID<br> table 2 (Seasons) has information about each season - primary key is seasonID<br> table 3 (PlayerSeasons) has two columns - playerID and seasonID. <br> <br> The form to crud a player has a combobox where one can select multiple seasons for a player. When I do an add or update, I have to add one or more rows to the PlayerSeasons table. Does this loop have to be in a Python script, or can it be implemented in ZSQL? I looked at the 'multiple' keyword, but all the examples indicate that it apples to sql tests, such as testing against a set of values. I can't seem to find any examples where one is inserting multiple rows into a table.<br> <br> Thanks!<br> <br> Mark<br> <pre wrap=""> <fieldset class="mimeAttachmentHeader"></fieldset> _______________________________________________ Zope-DB mailing list <a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a> <a class="moz-txt-link-freetext" href="https://mail.zope.org/mailman/listinfo/zope-db">https://mail.zope.org/mailman/listinfo/zope-db</a> __________ Hinweis von ESET NOD32 Antivirus, Signaturdatenbank-Version 5393 (20100824) __________ E-Mail wurde geprüft mit ESET NOD32 Antivirus. <a class="moz-txt-link-freetext" href="http://www.eset.com">http://www.eset.com</a> </pre> </blockquote> <br> <BR> <BR> __________ Hinweis von ESET NOD32 Antivirus, Signaturdatenbank-Version 5393 (20100824) __________<BR> <BR> E-Mail wurde geprüft mit ESET NOD32 Antivirus.<BR> <BR> <A HREF="http://www.eset.com">http://www.eset.com</A><BR> </body> </html> --=_maila-8882-1282665330-0001-2-- --===============8824124588400750987== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Zope-DB mailing list [email protected] https://mail.zope.org/mailman/listinfo/zope-db --===============8824124588400750987==--