Forum OpenACS Q&A: Nested multiple / multirow

Collapse
Posted by Gabriel Burca on
There is a thread that seems to indicate that nested db_multirow works, but I can't find the patches it's talking about, or an example of how the adp file should look like. I'm using something like this in my tcl file:
db_multirow -extend {submulti} multi sql { ** } {
    template::multirow create sub1 stuff
    for {...} {...} {...} {
        template::multirow append sub1 $value
    }
    set submulti [template::util::multirow_to_list sub1]
}
For the adp, I have a multiple tag with a name of "multi" and inside it another multiple tag with a name of "submulti", but when I do that I get an error about not being able to read "submulti:rowcount". I tried printing "multi" using multirow_to_list and it looked fine so it seems the problem is with the adp file.

So my question is, is it possible to create nested multiple tags in adp, and if so, how? In my case the data in the nested multirow does not come from a DB, but is computed in tcl.

If that's not possible, what are some of the work-arounds?

Collapse
Posted by Jeff Davis on
This won't work, you can nest <multiple> tags but you cannot nest multirow data structures (and most of the time you probably shouldn't think of doing something like this since most of the time it means doing a second query for every row in the first query which is a formula for a disastrous performance).

you might see if the <list> tag will do what you need since embedding a list in an element of a multirow should work.

Collapse
Posted by Gabriel Burca on
I tried using the <list> tag, but it looks like there's a bug when it comes to displaying the data. Even though I have a different list for each row of the multirow, the same list is displayed for each row (the list belonging to the last row).

For the <list> part of it I was expecting:

4 6 9 3 1
5 9 7 8 9 53 2
3 76 8

but instead I get:

3 76 8
3 76 8
3 76 8

I verified that the data is properly created using the multirow_to_list function to display the multirow internal structure.

Collapse
Posted by Tilmann Singer on
Looks like you are not applying the list value to a multirow column but to a normal variable, which happens to have the value that you assigned to it last when the adp is built.

Are you referencing your list with @multi.mylist@ in the adp?