[ic] Ideas to substitute for a [query] inside a [query]?

Dan B db@cyclonehq.dnsalias.net
Wed, 14 Feb 2001 22:02:26 -0800


At 12:07 AM 2/15/2001 -0500, you wrote:
>We do next to everything in perl (option 4).  If you go that route
>you want to start looking at glue to the internal database routines.
>
>
>{
>     $table ||='products';
>
>     $db=$Vend::Database{$table} or
>         ::logGlobal(sprintf(qq`%s: %d ERROR: dbi_query: unknown base 
> table: %s, SQL: %s`,__FILE__,__LINE__,$table,$query));
>
>     $db=$db->ref();
>     $db=$db->[$DBI];
>     my($sth);
>     eval {
>         unless($sth=$db->prepare($query)) {
>             ::logGlobal(" Error: 5 $DBI::errstr on $query") unless 
> ($DBI::errstr=~/specials/); # specials
>             return;
>         }
>         unless($sth->execute()) {
>             ::logGlobal(" Error: 4 $DBI::errstr on $query") unless 
> ($DBI::errstr=~/exist/); # specials
>             return;
>         }
>
>         # This returns a reference to array of references to arrays
>         $tmp=$sth->fetchall_arrayref;
>     };
>     if ($@||$DBI::errstr) {
>         ::logGlobal("ERROR: 6 array_query croaked, error: $@ $DBI::errstr 
> SQL: $query") unless ($DBI::errstr=~/exist/);
>         return;
>     }
>     if($sth->rows) {
>         return @{$tmp};
>     } else {
>         return;
>     }
>}

Is this code exec'able in a [mvasp tables="products"]<% %>[/mvasp]?
It would be nice (especially for debugging).

Here's what I get in CATROOT/error.log


10.0.0.103 v53CRicP:10.0.0.103 - [14/February/2001:21:40:49 -0800] ds25 
/cgi-bin/ds25/process.html Safe: eval string tra
pped by operation mask at (eval 319) line 31.
 >
 > ; my $html = <<'_MV_ASP_EOF981849053';
 >
 >
 > _MV_ASP_EOF981849053
 > chop($html);
 >               HTML( $html );
 >
 >       $Document->write ("<BR>---<BR>");
 >
 >       if (1){
 >     $table ||='products';
 >
 >     $db=$Vend::Database{$table} or
 >         ::logGlobal(sprintf(qq`%s: %d ERROR: dbi_query: unknown base 
table: %s, SQL: %s`,,,$table,$query));
 >
 >     $db=$db->ref();
 >     $db=$db->[$DBI];
 >     my($sth);
 >     eval {
 >         unless($sth=$db->prepare($query)) {
 >             ::logGlobal(" Error: 5 $DBI::errstr on $query") unless 
($DBI::errstr=~/specials/); # specials
 >             return;
 >         }
 >         unless($sth->execute()) {
 >             ::logGlobal(" Error: 4 $DBI::errstr on $query") unless 
($DBI::errstr=~/exist/); # specials
 >             return;
 >         }
 >
 >         # This returns a reference to array of references to arrays
 >         $tmp=$sth->fetchall_arrayref;
 >     };
 >     if ($@||$DBI::errstr) {
 >         ::logGlobal("ERROR: 6 array_query croaked, error: $@ 
$DBI::errstr SQL: $query") unless ($DBI::errstr=~/exist/)
;
 >         return;
 >     }
 >     if($sth->rows) {
 >         return @{$tmp};
 >     } else {
 >         return;
 >     }
 >       }
 > ;
 > ; my $html = <<'_MV_ASP_EOF981849053';
 >
 >
 > _MV_ASP_EOF981849053
 > chop($html);
 >               HTML( $html );
 >
 >
10.0.0.103 v53CRicP:10.0.0.103 - [14/February/2001:21:40:49 -0800] ds25 
/cgi-bin/ds25/process.html Runtime error: Can't
call method "open_table" on an undefined value at 
/usr/local/ic46-jan25/lib/Vend/Data.pm line 872.


Thanks again for your help,


Dan Browning, Cyclone Computer Systems, danb@cyclonecomputers.com