Re: Dealing with Uninitialized values in an array and DBI?
On Oct 1, Crayola said: Use of uninitialized value in concatenation (.) or string at ./audit-logs.pl line 98. Which line that you've shown us is line 98? The code is below. my $oth = $oracledbh-prepare (select * from sys.aud\$ where timestamp\# ? ); While the '$' does need a backslash, the '#' doesn't. You could just use single quotes here anyway: $oracledbh-prepare('select * from sys.aud$ where timestamp# ?'); $oth-bind_param( 1, $timest, { TYPE = 'SQL_DATE' } ); $oth-execute (); while (my @ary = $oth-fetchrow_array() ) { my $rows2 = $mysqldbh-do (\$sid\, \${ary[0]}\, \${ary[1]}\, \${ary[2]}\, \${ary[3]}\, \${ary[4]}\, \${ary[5]}\, \${ary[6]}\, \${ary[7]}\, \${ary[8]}\, \${ary[9]}\, \${ary[10]}\, \${ary[11]}\, \${ary[12]}\, \${ary[13]}\, \${ary[14]}\, \${ary[15]}\, \${ary[16]}\, \${ary[17]}\, \${ary[18]}\, \${ary[19]}\, \${ary[20]}\, \${ary[21]}\, \${ary[22]}\, \${ary[23]}\, \${ary[24]}\, \${ary[25]}\, \${ary[26]}\, \${ary[27]}\, \${ary[28]}\, \${ary[29]}\)); What is that? WHAT is THAT? Assuming $mysqldbh is just a database handle, you're passing it a reference to an enormous string. You're doing something wrong here. my @ary = (); That's doing nothing -- you're creating a NEW lexical named @ary. Drop the my(), but I'm not even sure it's necessary. -- Jeff japhy Pinyan% How can we ever be the sold short or RPI Acacia Brother #734% the cheated, we who for every service http://www.perlmonks.org/ % have long ago been overpaid? http://princeton.pm.org/ %-- Meister Eckhart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Dealing with Uninitialized values in an array and DBI?
I am querying a table within an oracle database and extracting a ton of rows using DBI. Unfortunately.. several of the columns in this table will occasionally be undefined. Hence the resulting array from a fetchrow_array occasionally has undefined values in it. I am taking this array and pumping it to another database.. but when I do, I occasionally get this error... Use of uninitialized value in concatenation (.) or string at ./audit-logs.pl line 98. Any ideas how I can check for uninitialized values in the array and set them to something default, or not put those array values into the insert statement? The code is below. Thanks for any help you can offer.. Mike --- sub pulllogs { my $result = $oracledbh-do(alter session set nls_date_format='-MM-DD HH24:MI:SS'); my $oth = $oracledbh-prepare (select * from sys.aud\$ where timestamp\# ? ); $oth-bind_param( 1, $timest, { TYPE = 'SQL_DATE' } ); $oth-execute (); while (my @ary = $oth-fetchrow_array() ) { my $rows2 = $mysqldbh-do (\$sid\, \${ary[0]}\, \${ary[1]}\, \${ary[2]}\, \${ary[3]}\, \${ary[4]}\, \${ary[5]}\, \${ary[6]}\, \${ary[7]}\, \${ary[8]}\, \${ary[9]}\, \${ary[10]}\, \${ary[11]}\, \${ary[12]}\, \${ary[13]}\, \${ary[14]}\, \${ary[15]}\, \${ary[16]}\, \${ary[17]}\, \${ary[18]}\, \${ary[19]}\, \${ary[20]}\, \${ary[21]}\, \${ary[22]}\, \${ary[23]}\, \${ary[24]}\, \${ary[25]}\, \${ary[26]}\, \${ary[27]}\, \${ary[28]}\, \${ary[29]}\)); my @ary = (); } $oth-finish (); } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response