The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



Thread: Sqlplus
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 06-01-2007
LiquidChild LiquidChild is offline
Registered User
 

Join Date: Jul 2005
Location: Belfast
Posts: 49
Sqlplus

I am looking to loop round a load of files and execute each in sqlplus, I have looked at the forum to see what was posted in the past, but most of the examples seem to use the sql being passed in through the script, which is not really what I am looking for, can someone tell me if the code below is wrong, as it does not seem to work correctly:

Code:
for arrays in packageSpecs packageBodies procedures triggers functions views sqlScripts
      do
         eval count=\${#${arrays}[*]}

         writeHeaderToLog "Executing contents of ${arrays}"

         if [ $count -eq 0 ]
         then
            writeToLog "Nothing to be executed"
         else
            counter=0

            while [ $counter -lt $count ]
            do
               writeToLog

               eval fileToExecute=\${${arrays}[${counter}]}

               sqlLogFile=$fileToExecute.log

               # Log into sql plus, we log in for each script incase
               # the script contains an exit statement

               writeToLogFile "Executing $fileToExecute"
               sqlplus $databaseUser/$databasePassword@$databaseSID @$fileToExecute whenever sqlerror exit sql.sqlcode >> $LogDir/$sqlLogFile 2>&1

               errorCode=$?

               if [ $errorCode != 0 ]
               then
                   writeErrorToLog "SQLPlus failed for $fileToExecute with errorcode: $errorCode"
               else
                   writeToLog "$fileToExecute: EXECUTED SUCCESSFULLY"
                   exit
               fi

               counter=$counter+1
           done
fi
      done

      writeHeaderToLog "Execution Complete"
   fi
Reply With Quote
Remove advertisements
!!
Forum Sponsor