You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rivet-dev@tcl.apache.org by Cyril Shtumf <we...@livehistory.ru> on 2011/03/29 19:19:55 UTC

Conflict of commands in the package DIO.

Hello everyone!

I was faced with an insurmountable problem when using the package DIO. 
The problem is that the command "forall" returns only one row, if the 
body contains the command "array". For example:

db forall "SELECT `products_id` FROM `products`" row {

     db array "SELECT `specifications_id` FROM `products_specifications` 
WHERE `products_id` = '$row(products_id)'" row2

}

Alas, I don't know how to fix it. I hope for your help.

---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org


Re: Conflict of commands in the package DIO.

Posted by Cyril Shumff <sh...@gmail.com>.
Yes, but in my case this is not applicable. As a temporary workaround I 
am using 2 connections. I believe that the best solution would be to 
change the stack in DIO to allow multiple queries. But, I have little 
experience works with itcl and I can't realize this at the moment. Thanks.


30.03.2011 02:15, Massimo Manghi wrote:
> btw, the best approach (if applicable) would be to have a single 
> forloop on
> a query that joins 2 tables. Check if SQL can help you build such a 
> query or
> you may elaborate the problem on the list. It sounds like Jeff has a 
> pretty
> strong experience in database queries. My previous message was only meant
> to point out why that specific construct based on nested loops failed.
>
>   -- Massimo
>

---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org


Re: Conflict of commands in the package DIO.

Posted by Massimo Manghi <ma...@unipr.it>.
 btw, the best approach (if applicable) would be to have a single 
 forloop on
 a query that joins 2 tables. Check if SQL can help you build such a 
 query or
 you may elaborate the problem on the list. It sounds like Jeff has a 
 pretty
 strong experience in database queries. My previous message was only 
 meant
 to point out why that specific construct based on nested loops failed.

   -- Massimo

 On Tue, 29 Mar 2011 23:12:42 +0400, Cyril Shumff wrote:
> Thanks, but my last sql-query is only an example, actually the
> problem is much more complicated and there is need to use the "array"
> in the body of "forall". Other commands (array, list, etc) in the 
> body
> "forall" also stops a cycle.
>
>  29.03.2011 21:43, Jeff Lawson wrote:
>
>> If you're trying to get all of the matching specficiation_id's, then
>> maybe you want something like:
>>
>> set myspecs [db list "SELECT specifications_id FROM
>> product_specifications, products WHERE
>> product_specifications.products_id = products.products_id"]
>>
>> On Tue, Mar 29, 2011 at 12:19 PM, Cyril Shtumf wrote:
>>
>>> Hello everyone!
>>>
>>> I was faced with an insurmountable problem when using the package
>>> DIO. The problem is that the command "forall" returns only one
>>> row, if the body contains the command "array". For example:
>>>
>>> db forall "SELECT `products_id` FROM `products`" row {
>>>
>>>    db array "SELECT `specifications_id` FROM
>>> `products_specifications` WHERE `products_id` =
>>> '$row(products_id)'" row2
>>>
>>> }
>>>
>>> Alas, I don't know how to fix it. I hope for your help.
>>>
>>>
>>
> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org [1]
>>> For additional commands, e-mail: rivet-dev-help@tcl.apache.org
>>> [2]
>
>
>
> Links:
> ------
> [1] mailto:rivet-dev-unsubscribe@tcl.apache.org
> [2] mailto:rivet-dev-help@tcl.apache.org
> [3] mailto:webmaster@livehistory.ru


---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org


Re: Conflict of commands in the package DIO.

Posted by Massimo Manghi <ma...@unipr.it>.
 I cannot check this now, but I think the DIO object stores query 
 results
 in a result object and it owns only an instance of it. So probably the
 inner query passed to the array method messes with the ongoing results
 that drive the forall loop.

 if it's correct possible workarounds are:

 1) change DIO and build a result stack in DIO to allow multiple queries

 2) use 2 instances of db (at the cost of having 2 connections open)

 db1 forall "SELECT `products_id` FROM `products`" row {
   db2 array "SELECT `specifications_id` FROM `products_specifications` 
 WHERE `products_id` = '$row(products_id)'" row2
 }

  -- Massimo


 On Tue, 29 Mar 2011 23:12:42 +0400, Cyril Shumff wrote:
> Thanks, but my last sql-query is only an example, actually the
> problem is much more complicated and there is need to use the "array"
> in the body of "forall". Other commands (array, list, etc) in the 
> body
> "forall" also stops a cycle.
>
>  29.03.2011 21:43, Jeff Lawson wrote:
>
>> If you're trying to get all of the matching specficiation_id's, then
>> maybe you want something like:
>>
>> set myspecs [db list "SELECT specifications_id FROM
>> product_specifications, products WHERE
>> product_specifications.products_id = products.products_id"]
>>
>> On Tue, Mar 29, 2011 at 12:19 PM, Cyril Shtumf wrote:
>>
>>> Hello everyone!
>>>
>>> I was faced with an insurmountable problem when using the package
>>> DIO. The problem is that the command "forall" returns only one
>>> row, if the body contains the command "array". For example:
>>>
>>> db forall "SELECT `products_id` FROM `products`" row {
>>>
>>>    db array "SELECT `specifications_id` FROM
>>> `products_specifications` WHERE `products_id` =
>>> '$row(products_id)'" row2
>>>
>>> }
>>>
>>> Alas, I don't know how to fix it. I hope for your help.
>>>
>>>
>>
> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org [1]
>>> For additional commands, e-mail: rivet-dev-help@tcl.apache.org
>>> [2]
>
>
>
> Links:
> ------
> [1] mailto:rivet-dev-unsubscribe@tcl.apache.org
> [2] mailto:rivet-dev-help@tcl.apache.org
> [3] mailto:webmaster@livehistory.ru


---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org


Re: Conflict of commands in the package DIO.

Posted by Cyril Shumff <sh...@gmail.com>.
Thanks, but my last sql-query is only an example, actually the problem 
is much more complicated and there is need to use the "array" in the 
body of "forall". Other commands (array, list, etc) in the body "forall" 
also stops a cycle.

29.03.2011 21:43, Jeff Lawson wrote:
> If you're trying to get all of the matching specficiation_id's, then 
> maybe you want something like:
>
> set myspecs [db list "SELECT specifications_id FROM 
> product_specifications, products WHERE 
> product_specifications.products_id = products.products_id"]
>
>
>
> On Tue, Mar 29, 2011 at 12:19 PM, Cyril Shtumf 
> <webmaster@livehistory.ru <ma...@livehistory.ru>> wrote:
>
>     Hello everyone!
>
>     I was faced with an insurmountable problem when using the package
>     DIO. The problem is that the command "forall" returns only one
>     row, if the body contains the command "array". For example:
>
>     db forall "SELECT `products_id` FROM `products`" row {
>
>        db array "SELECT `specifications_id` FROM
>     `products_specifications` WHERE `products_id` =
>     '$row(products_id)'" row2
>
>     }
>
>     Alas, I don't know how to fix it. I hope for your help.
>
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
>     <ma...@tcl.apache.org>
>     For additional commands, e-mail: rivet-dev-help@tcl.apache.org
>     <ma...@tcl.apache.org>
>
>


Re: Conflict of commands in the package DIO.

Posted by Jeff Lawson <je...@bovine.net>.
If you're trying to get all of the matching specficiation_id's, then maybe
you want something like:

set myspecs [db list "SELECT specifications_id FROM product_specifications,
products WHERE product_specifications.products_id = products.products_id"]



On Tue, Mar 29, 2011 at 12:19 PM, Cyril Shtumf <we...@livehistory.ru>wrote:

> Hello everyone!
>
> I was faced with an insurmountable problem when using the package DIO. The
> problem is that the command "forall" returns only one row, if the body
> contains the command "array". For example:
>
> db forall "SELECT `products_id` FROM `products`" row {
>
>    db array "SELECT `specifications_id` FROM `products_specifications`
> WHERE `products_id` = '$row(products_id)'" row2
>
> }
>
> Alas, I don't know how to fix it. I hope for your help.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
> For additional commands, e-mail: rivet-dev-help@tcl.apache.org
>
>