I am grabbing a list of SQL statements from a database...(successfully can
cause statements to execute....as long as I don't QQ or QW them!) 
Here's the problem:

I am in the middle of a for loop to define the array containing the statements
(and a few other fields...the statements are just one field..) The array is
local to the script, not the loop...while I could probably localize the array
to the loop, that does not remove the need to undef the array through each
itteration of the loop....(unless it goes out of scope with each
iteration...Does it?)  The first array in the result set appears to be
NULL,NULL (which can't be since I'm retrieving data from a table where those
two values aren't allowed to be NULL and I've looked at the dataset...NO NULL
Values found....just some returned....
Here's the code:

        @nupdates=undef;
        $sql=qq{ SELECT * FROM syncrecords WHERE (syncrecordid > ?) AND
(src_id_database = ?)};
        $sth=$dbh->prepare($sql);
        $sth->execute($lseen,$sdbid);
        while ( my $array_ref=$sth->fetchrow_arrayref) {
                push @nupdates, [@$array_ref];
        }
        for $nurow(@nupdates) {
                print "$nurow->[0], $nurow->[1], $sdbid, $ddbid\n";
        }

Here's the output:  (NOTE:  The two values are the only two in the @nupdates
the other two are defined by the itteration of the two For loops surrounding
the above cod...($sdbid, and $ddbid);

, , 1, 2
121, insert into synctest1 values(49,'test3',20,'1998-05-20 00:00:00','1'), 1,
2
122, delete from synctest1 where synctestid = 49, 1, 2
123, insert into synctest1 values (49,'test3',20,'1998-05-20 00:00:00','0'), 1,
2
124, delete from synctest1 where synctestid = 49, 1, 2
125, insert into synctest1 values(49,'test3',20,'1998-05-20 00:00:00','1'), 1,
2
126, insert into synctest1 values(50,'zippitydoodah',383,'2001-03-03
00:00:00','0'), 1, 2
127, insert into synctest2 values (16,9,'1931-05-02 00:00:00'), 1, 2
128, insert into synctest2 values (17,879,'2001-06-06 00:00:00'), 1, 2
129, insert into synctest1 values(51,'ziffdavis',99,'1977-02-03 00:00:00','0'),
1, 2
130, insert into synctest1 values(52,'Tommy Lee Jones',67578,'2025-07-05
00:00:00','1'), 1, 2


The problem being that the FIRST set has NULL values because I'm trying to say:

$success=$dbh->do($sql);  #$sql=$nurow->[1] in a previous line...
$dbh->commit(); 

Which works fine as long as I don't get a NULL SET.....sticking an if to trap
for null doesn't seem to work either....It's extremely frustrating since I
could finish off a very portable replicator if I could get around this.....

(Portable being defined as: You write triggers in your DB to generate the
replication table...I grab the statements and issue them to slaves...WORKS
great between MS-SQL and PG as long as my triggers build SQL92 compliant
statements with SQL92 compliant data.  (i.e. in our case the only kinds of
fields I have to modify are bit fields and datestamps......bit fields have to
come out as boolean "t" or "f", "y" or "n", or "1" or "0"....and I'm using the
ISO date format of YYYY-MM-DD HH:MM:SS.ss GMT  now if I could just modify it so
that my CODE could do that on the fly....not right now...need to get
replication done this weekend....


-- 
Michael Wray
Network Administrator
FamilyConnect, Inc.


Reply via email to