[ic] Tag->query in a usertag
Kyle Cook
interchange-users@interchange.redhat.com
Thu Apr 18 22:27:01 2002
At 05:01 PM 4/18/02, you wrote:
>I'm attempting to write a routine that will return a list of quantity
>break fields that contain data. I have the following code that works
>correctly in a [perl] section, but will not function correctly in a
>usertag. The query tag is supposed to return a reference to an array of
>hash references. I have tested that this indeed works in a [perl]
>section.
<SNIP>
Ron,
Here is how I'd access the sql via a usertag:
my $db = Vend::Data::database_exists_ref('pricing');
my $dbh = $db->[$Vend::Table::DBI::DBI];
my $sql = "SELECT " . $available_breaks .
" FROM pricing WHERE sku ='" . $code . "';";
my $sth = $dbh->prepare($sql);
$sth->execute();
if ($sth) {
my $sql_results = $sth->fetchrow_hashref();
}
else {
# No results! may wish to log error
# and send back some default.
}
Kyle Cook