Hello again,

Sorry to bother again, but I've been fiddling with this for the best
part of today and don't seem to be getting anywhere.

http://search.cpan.org/~abw/Template-DBI-2.64/lib/Template/Plugin/DBI.pm

says that the execute function takes an array for the bind values 

execute(@args)

I've got a chunk of template which looks like

        [% main = DBI.prepare(sql) %]
        [% FOREACH actives = active %]
            [% bind.push(parms.$actives) %]
        [% END %]
        [% FOREACH customer = main.execute(bind) %]


now active is an array passed through from the cgi which contains a list
of the keys in the hash parms which are active, and parms is a hash
created with query->Vars.

sql is a sql statment that is generated by finding out which of the
columns in the db we need to sort on (given to us by the values of the
cgi vars) 

So forinstance 

$sql = 'SELECT * FROM customer WHERE date = ? ORDER by ?';

@active = qw(date, order);

$parms = {
                        date => '2008-07-23',
                        order => 'name ASC',
                        address => ''
                        ...
}

the ... signifies there's more stuff in that hash, 12 items in total
most set to null or ALL

But When I run it I get 

[Wed Nov 12 18:16:43 2008] [error] [client 92.41.135.118] DBI error -
execute failed: called with 1 bind variables when 2 are needed, referer:
http://test

I've been wondering if I need to declare bind somehow before I start
pushing stuff onto it?

Or if I got the syntax of the execute right?

tvmia

M
-- 
GPG key here. http://www.gatrell.org/gpg.public.key

Attachment: signature.asc
Description: Digital signature

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to