PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Sabherwal, Balvinder (MBS)" <Balvinder dot Sabherwal at mortgagefamily dot com>
Subject: Error in the script execution
Date: Jan 13 2003 4:45PM

Gurus,

I have a script to perform the dump and load for given database. The section
of the script is given below. There are 2 parts of this script. Part 1
handles the dump of the database and part 2 handles the load of the
database.

I'm trying to debug the script as it's not loading the database. The command
it send to the server is working in the isql session, not from the script.
The dump command is working fine and the same way is used to do the load.
Could anyone help me figure this out as why my load command would not from
the script?? Secondly, When I check for the errors after executing the load
command, I'm getting error as "Can't use string
("ARRAY(0x42987c)ARRAY(0x429888)") as an ARRAY ref while "strict refs" in
use at DBDumpLoad.pl line 313.". 

Thanks for all your help.

###############################################
## Execute the Database Dump command
###############################################

      $dlog = $sdbh->ct_sql("$dumpcmd");

###############################################
## Check for the errors in the dump command execution
###############################################

## I don't know if this is ok. I get no errors on execution ##
if ( @$dlog =~ /Msg/m || @$dlog =~ /Error/m ) 
{
      $errmsg .= "\n\n*** ERROR *** Dump of the database $opt_D on $opt_S
failed \n";
          $errmsg .= @$dlog ;
      msg_send("$opt_M","DBDumpLoad.pl FAILED for $opt_S","$errmsg");
      exit(1);
}

###############################################
## Connect to the Target Server
###############################################
my $tdbh = Sybase::CTlib->ct_connect("$opt_u", "$tpwd" ,"$opt_s");

if($tdbh eq undef)
{
       $errmsg .= "\n\n*** ERROR *** Cannot open connection to $opt_s
dataserver. \n The user id is $opt_u The location for the pwd file
is $tfile \n ";
      msg_send("$opt_M","DBDumpLoad.pl FAILED for $opt_s","$errmsg");
      exit(1);
}
else
{
      if ( uc("$opt_K") eq "Y" )
      {
	###############################################
	## Kill the users in the database before load
	###############################################
         my $killcmd = $tdbh->ct_sql("select \"kill \"+convert(char,spid)
from master..sysprocesses where db_name(dbid) = \"$opt_d\"");
         foreach my $cmd (@$killcmd)
         {
            $tdbh->ct_sql("@$cmd");
         }
      }

###########################################################################
##  LOAD DATABASE COMMAND
###########################################################################
   if ( uc("$opt_t") eq "DISK" and uc("$opt_O") eq "L" and $opt_P > 1 )
   {
       open(FL,"< $opt_f");
       while ( FL )
       {
         chomp($_);
         $dmpfile .= "stripe  on $_";
       }
   }
   my $cmd = substr($dmpfile,10);
   $dmpfile = $cmd;

   if ( uc("$opt_t") eq "DISK" and ( !$opt_G or uc("$opt_G") eq "N" ) )
   {   
       $dmpfile = "$opt_f"."/"."$opt_D.dmp";
   }

   if ( uc("$opt_t") eq "TAPE" )
   {
        $dmpfile = "$opt_f";
   }

   if ( uc("$opt_T") eq "D" )
   {
      if ( $opt_C )
      {
           $dumpcmd = "Load database $opt_d from
\"compress::"."$opt_C"."::$dmpfile\"" ;
      }
      else
      {
           $dumpcmd = "Load database $opt_D from \"$dmpfile\"" ;
      }
   }
   else {
      if ( $opt_C )
      {
           $dumpcmd = "Load tran $opt_D from
\"compress::"."$opt_C"."::$dmpfile\"" ;
      }
      else
      {
           $dumpcmd = "Load tran $opt_D from \"$dmpfile\"" ;
      }
   }

	###############################################
	## Execute the Database Load command
	###############################################
      $llog = $tdbh->ct_sql("$dmpfile");  

	###############################################
	## Execute the online Database command
	###############################################
      if ( uc("$opt_o") eq "Y")
      {
           $llog .= $tdbh->ct_sql("online database $opt_d");
      }
	###############################################
	## Check for the errors in load and online database commands
	###############################################
	
####################################
      foreach my $l ( @$llog )	## This is line 313 in the script ##
      {					####################################
          if ( @$l =~ /Msg/m )
          {
                $errmsg .= "\n\n*** ERROR *** Load of the database $opt_d
failed \n";
                $errmsg .= @$llog ;
                msg_send("$opt_M","DBDumpLoad.pl FAILED for
$opt_S","$errmsg");
                exit(1);
          }
      }

############################
## DEBUG Screen Outputs
############################
#######################################
## Load cmd being sent to dataserver ##
#######################################
  DB<8> p $dumpcmd
Load database RepStd from "compress::3::/tmp/RepAct.dmp"

#######################################
## value for the database handle     ##
#######################################
  DB<9> p $tdbh
Sybase::CTlib=HASH(0x429894)