[ic] Re: Accessing looped data in a usertag

Jon Jensen jon at endpoint.com
Tue Mar 18 21:50:46 EST 2008

On Tue, 18 Mar 2008, Ron Phipps wrote:

> You may want to try using a query to pull the orderline data, something like 
> this in a usertag:
> my $db = Vend::Data::database_exists_ref('orderline');
> my $sql = "SELECT code, sku FROM orderline WHERE order_number = '1234'";
> my $dbh = $db->[$Vend::Table::DBI::DBI];
> my $sth = $dbh->prepare($sql);
> $sth->execute();
> if ($sth) {
> 	while (my $sql_results = $sth->fetchrow_hashref()) {
> 		my $code = $$sql_results{code};
> 		my $sku = $$sql_results{sku};
> 	}
> }


Ron's advice above is for a global usertag; if you want to use a catalog 
usertag, use this to get the $dbh instead:

my $dbh = $Sql{orderline} or die "Couldn't get orderline handle\n";

And in the page that calls the usertag you'll need to pre-open the 
database handle with something like:

[perl tables="orderline"][/perl]

before you call the tag.


Jon Jensen
End Point Corporation

More information about the interchange-users mailing list