Forum OpenACS Development: Re: Problem with using db_multirow in <package>-procs.tcl

Collapse
Posted by Dave Bauer on
Normally the pattern for upvaring a multirow works like this:

ad_proc -public my::proc {
    {-multirow_name "varname"}
} {
    upvar $varname local_var
    db_multirow local_var queryname "*SQL*"
}

What this does is take the name of a variable in the callers scope. It creates this variable which will be used as the multirow reference.

Collapse
Posted by Jon Suen on
Thanks for your help.
Are you saying -multirow_name "varname" is defined in a separate code block to the rest?

At the moment my understanding of the syntax for procs generally is:

ad_proc -public processname {
{-parameters_passed_in:required,etc.}
} { Documentation
} {

# Code block (main body for the procedure)

return $args
# for example

}

Is this correct? I'm just not entirely clear on where
{-multirow_name "varname"}
would fit in, if not within the main body.

I'll give it a go all the same, thanks again.

Jon

At present I have:

{ -multirow_name "prs" }


{ upvar $prs prs

db_multirow prs pre_reqs_sql { }
}

### And I define pre_reqs_sql to return a multirow-ed
### value in the according package-procs.xql file.

This currently spits up a request error:
[snip]
invalid command name "-multirow_name "prs""
[/snip]

Which I didn't really expect to work all the same, since I'm not sure about the placement of the -multirow_name switch...

Any help would be greatly appreciated

Cheeres

Hi,

I don't know if this problem is still a current one, but by replacing

upvar $varname local_var
db_multirow local_var queryname "*SQL*"

to

upvar $multirow_name local_var
db_multirow local_var queryname "*SQL*"

the whole thing works pretty fine.