[Templates] Passing a list to DBI execute?

[prev] [thread] [next] [Date index for 2004/12/06]

From: Larry Leszczynski
Subject: [Templates] Passing a list to DBI execute?
Date: 18:14 on 06 Dec 2004
Hi -

I'm having trouble passing a list of bind parameter values to the DBI
execute function, hoping someone can shed some light.  It works fine when
the query has a single placeholder and I send a single string.  But when
the query has multiple placeholders and I try to send a list, the execute
subroutine is just getting the array ref and not the list of values, e.g.
something like this fails:

[%
   query = "select * from users where email like ? and status = ?";
   bind_params = [ '%larryl%', 'A' ];
   PROCESS my_utility_template;
%]

where "my_utility_template" is something like:

[%
   sth  = DBI.prepare(query);
   rows = sth.execute(bind_params);
   FOREACH row IN rows;
      ...do stuff...
   END;
-%]

Passing the params explicitly works, e.g.:
   rows = sth.execute('%larryl%', 'A');
except I can't do that in my case, because they're defined elsewhere and
used later within the template that does the prepare/execute.

Is there some sort of dereferencing or eval-ing that I need to do to get
the bind_params list passed through to execute?


Thanks,
Larry Leszczynski



_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] Passing a list to DBI execute?
Larry Leszczynski 18:14 on 06 Dec 2004

Re: [Templates] Passing a list to DBI execute?
Andy Wardley 18:19 on 06 Dec 2004

Re: [Templates] Passing a list to DBI execute?
Harald Joerg 21:34 on 06 Dec 2004

Re: [Templates] Passing a list to DBI execute? (solved)
Larry Leszczynski 22:55 on 06 Dec 2004

Generated at 08:56 on 15 Mar 2005 by mariachi v0.52