[ic] Re: Accessing looped data in a usertag

Grant emailgrant at gmail.com
Wed Mar 19 01:17:41 EST 2008


>  > 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};
>  >       }
>  > }
>
>  Grant,
>
>  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.

Thank you Ron and Jon, working perfectly now.

- Grant

>  Jon Jensen
>  End Point Corporation
>  http://www.endpoint.com/


More information about the interchange-users mailing list