[ic] FW: More questions about $Tag->query

Eric Terry elterry at multiservice.com
Thu Jan 15 17:12:58 EST 2004

-----Original Message-----
From: Eric [mailto:eric at 80s.com] 
Sent: Thursday, January 15, 2004 4:12 PM
To: interchange-users at icdevgroup.org (interchange-users at icdevgroup.org)
Subject: More questions about $Tag->query

Okay, I'm having more trouble with using $Tag->query.
Basically I'm trying copy ordline records to a new table along with a
sequence number. All works fine as long as there is only one record returned
from the query.

When 2 or more records are returned the first record is recorded and the
others are not.

And this error is in the log:
Safe: Can't use an undefined value as an ARRAY reference at (eval 193) line

I've tried changing this line(89) of code '@$results[$j]->[$i]' to:

I'm using interchange 4.8.6 and perl 5.8.0.

The code that follows is inside of a perl tag:

do_insert("transactions", "transactions_log", 53);
do_insert("orderline", "orderline_log", 25);

sub do_insert(){

        my $table_out = shift; # name of original ic table - transactions,
        my $table_in = shift;   # name of new log table - transactions_log,
        my $count = shift;      # column count of table

        my $sql = "select * from $table_out where order_number =
        my $results = $Tag->query({
                        table => "$table_out",
                        sql => $sql,

        my $rows = set_count($table_out);

        my ($i, $j) = '';

        for( $j = 0; $j <= $rows; $j++ ){

                $sql = "insert into $table_in values (";

                for( $i = 0; $i < $count; $i++ ){

                        $sql .= "'@$results[$j]->[$i]', ";  # <<< PROBLEM

                $sql .= "LAST_INSERT_ID())";

                $results = $Tag->query({
                        table => "$table_in",
                        sql => $sql,

sub set_count(){

        my $table = shift;
        my $sql = "select count(*) from $table where order_number =
        my $results = $Tag->query({
                table => "$table", 
                sql => $sql,

        my $rc = @$results[0]->[0];

        return ++$rc;

More information about the interchange-users mailing list