Weird Perl error using db2.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Weird Perl error using db2.
# 1  
Old 06-25-2013
Weird Perl error using db2.

I have having a heck of a time figuring this out so any help is much appreciated.

Here is the code where it seems to be dying, I bolded the part it is complaining about:
Code:
$sth = $dbh->prepare( $query ) or die "error with query[$query]\n";
$sth->execute() or die "error executing query ...\n";
while( @row = $sth->fetchrow_array ) {
  undef $agent_id            ;
  undef $execution_id        ;
  undef $primary_auth_id     ;
  undef $client_pid          ;
  undef $client_platform     ;
  undef $client_dns          ;
  undef $appl_name           ;
  undef $user_id             ;
  undef $last_timestamp      ;
  undef $elapsed_hours       ;
  undef $elapsed_minutes     ;
  undef $elapsed_seconds     ;
  undef $chg_timestamp       ;
  undef $start_timestamp     ;
  undef $stop_timestamp      ;
  undef $query_cost_estimate ;
  undef $rows_read           ;
  undef $rows_written        ;
  undef $sql                 ;
  
  $agent_id             = rtrim($row[0]);
  $execution_id         = rtrim($row[1]);
  $primary_auth_id      = rtrim($row[2]);
  $client_pid           = rtrim($row[3]);
  $client_platform      = rtrim($row[4]);
  $client_dns           = rtrim($row[5]);
  $appl_name            = rtrim($row[6]);
  $user_id              = rtrim($row[7]);
  $last_timestamp       = $row[8];
  $elapsed_hours        = $row[9];
  $elapsed_minutes      = $row[10];
  $elapsed_seconds      = $row[11];
  $chg_timestamp        = $row[12];
  $start_timestamp      = $row[13];
  $stop_timestamp       = $row[14];
  $query_cost_estimate  = $row[15];
  $rows_read            = $row[16];
  $rows_written         = $row[17];
  $sql                  = $row[18];
  
  @cleandata = ($agent_id,$execution_id,$primary_auth_id,$client_pid,$client_platform,$client_dns,$appl_name,$user_id,$last_timestamp,$elapsed_hours,$elapsed_minutes,$elapsed_seconds,$chg_timestamp,$start_timestamp,$stop_timestamp,$query_cost_estimate,$rows_read,$rows_written,$sql);

#  if($sql !~ /SNAP_GET_APPL_INFO/ and $sql =~ /appdm\."?cp\_/i and $sql !~ /with\s+ur/i) {
  if($sql !~ /SNAP_GET_APPL_INFO/) {
    #
    # archive information into SQLite DB
    #
    $sqlitesql = qq|insert into sql_archive (agent_id,
                                            execution_id,
                                            primary_auth_id,
                                            client_pid,
                                            client_platform,
                                            client_dns,
                                            appl_name,
                                            user_id,
                                            last_timestamp,
                                            elapsed_hours,
                                            elapsed_minutes,
                                            elapsed_seconds,
                                            chg_timestamp,
                                            start_timestamp,
                                            stop_timestamp,
                                            query_cost_estimate,
                                            rows_read,
                                            rows_written,
                                            sql,
                                            datetime,
                                            epoch ) 
                                            values 
                                            (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)|; 
    $insert = $sqlitedbh->prepare($sqlitesql);
    @insertrow = @cleandata;
    push(@insertrow,$datetime);
    push(@insertrow,$epoch);
    $insert->execute(@insertrow);
  }
}
$sqlitedbh->commit();

#
# terminate db2 connection
#
$sth->finish();
$dbh->disconnect;

Here is the error it is throwing:
Code:
Fetch failed error -1 recorded: [IBM][CLI Driver][DB2/AIX64] SQL1042C  An unexpected system error occurred.  SQLSTATE=58004

    !! ERROR: -1042 '[IBM][CLI Driver][DB2/AIX64] SQL1042C  An unexpected system error occurred.  SQLSTATE=58004
' (err#0)
    <- fetchrow_array= ( ) [0 items] row-1 at sql_archiver.pl line 186
DBD::DB2::st fetchrow_array failed: [IBM][CLI Driver][DB2/AIX64] SQL1042C  An unexpected system error occurred.  SQLSTATE=58004

This was a previous administrator's script and I inherited the mess. It works fine on two other servers, I just can't figure out why it hates this one server. I have searched high and low, but everything I have found hasn't worked so far.
# 2  
Old 06-25-2013
see notes on sql error 58004 then check the servers which are showing the issue ... there is most likely nothing wrong with the script other than to account for the differences found in the affected servers (i.e., command path, server load, os version, etc. ) ...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX with DB2 error status Issue

I have a shell script main.ksh We are calling dbscript.ksh from main.ksh I am using select statement in dbscript.ksh but there is a problem with the select statement in dbscript.ksh but still echo $? is showing as zero. I am using DB2 commands in dbscript.ksh Main.ksh dbscript.ksh echo $? ... (13 Replies)
Discussion started by: vamsi.valiveti
13 Replies

2. Shell Programming and Scripting

Weird Error (: No such file or directory)

Hi Everyone, I am trying to make this script to use, to find out the DAHDI channel status. Every thing works fine, I even get proper results, however I have this weird error that comes along. Can someone please help me. Thanks a lot. #!/bin/bash # Color to set the test to when a channel is... (3 Replies)
Discussion started by: jeetz
3 Replies

3. Shell Programming and Scripting

awk weird error

Here is the awk code i wrote : if ; then gawk -v field_position="$field_position" -v field_length="$field_length" -v header="$header" -v trailer="$trailer" -v lr="$lr" '{ if(NR==1&&header=="1") { next } if(NR==lr&&trailer=="1") { next }... (1 Reply)
Discussion started by: ysvsr1
1 Replies

4. UNIX for Dummies Questions & Answers

Weird Error moving a file

Hi, We are running into very weird error on AIX. Target directory exists on NFS. We have one script runs every 5 mins on our system. This script is running for 5 years for now without any issuess. Followig is the snapshot of the script : stmt_cnt=$(ls -1 ${1}/${2}|wc -l) if ;... (7 Replies)
Discussion started by: himihir2000
7 Replies

5. Ubuntu

Need help with a weird sudo error.

I'm fairly new to unix and I was trying to change the name of my host and my user. I changed the name in /hostname using this: gksudo gedit /etc/hostname I then tried changing the name back but it still gave the same error: {env_reset,... (1 Reply)
Discussion started by: H3jck
1 Replies

6. Shell Programming and Scripting

Error: SQL3100W while export in DB2

Problem has been resolved (7 Replies)
Discussion started by: ustechie
7 Replies

7. Shell Programming and Scripting

Weird unbalanced quotes error

hi all, i am writing a wrapping script to burn subtitle into video file using transcode. I got this very weird error: code: inFile="movie.avi" subFile="sub.srt" outFile="movie_sub.avi" strExc="-i $inFile -x 'mplayer=-sub $subFile' -w $vidBR -o $outFile -y xvid" echo "transcode $strExc"... (2 Replies)
Discussion started by: tduccuong
2 Replies

8. Programming

C - advice how to catch some weird error

I have some unstable mistake in my program and out-of-idea how to catch it. I am looking for advice with a way to work it out! I have in a pretty complicated program (but one source file) set of int-counters - 15, if exactly. Lately, on final printout I have inpossible value (I am... (3 Replies)
Discussion started by: alex_5161
3 Replies

9. UNIX for Dummies Questions & Answers

Exception while loading DB2 driver Class.forName("com.ibm.db2.jcc.DB2Driver")

Hi... I m working on UNIX z/OS. Actually i have to pass the parameters from the JCL to java-db2 program thru PARM. I am able to pass the arguments but the problem occured is, it is throwing an exception while loading the db2 driver as 'Javaclassnotfound:com.ibm.db2.jcc.DB2Driver'... (0 Replies)
Discussion started by: Sujatha Gowda
0 Replies

10. Shell Programming and Scripting

Data transfer from DB2 to Sybase using Perl?

Hi, Good Morning everybody. I need to write a perl script which will get some data from DB2 table and then put it into Sybase table. I have the experience in Oracle and Unix but new to these perl, DB2 and Sybase technologies. Appreciate if any one can suggest with a sample code. Thanks... (1 Reply)
Discussion started by: rajus19
1 Replies
Login or Register to Ask a Question