At 02:42 PM 7/31/2001 -0700, Douglas Sparling wrote:
>Hello,
>
>I have a value in
>
>[% feature_abbrv %]
>
>that I'd like to use in an SQL statement:
>
>[% USE DBI('dbi:mysql:database=mydatabase') %]
>
><p>
>Features:<br>
>[% query = DBI.prepare('SELECT * FROM features
>    WHERE feature_abbrv = ?') %]
>[% FOREACH f = query.execute('ga') %]
>[% f.feature_name %]<br>
>[% END %]

Assuming I understand the question correctly, just pass your
variable in as a function argument:

[% FOREACH f = query.execute(feature_abbrv) %]

As an alternative, provided the value of feature_abbrv doesn't
contain any special sql characters and you only run the query
once, you could interpolate the value straight into the select
statement:

[% query = DBI.prepare("SELECT * FROM features
         WHERE feature_abbrv = '$feature_abbrv'") %]

TT2 interpolates $feature_abbrv inside the double quotes.

Craig



Reply via email to