![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sqlplus call | JohnZ1385 | UNIX for Dummies Questions & Answers | 1 | 06-05-2008 07:48 AM |
| Sqlplus | antkiu | Shell Programming and Scripting | 4 | 09-13-2006 09:36 PM |
| SQLPLUS in script | renichols | Shell Programming and Scripting | 4 | 03-06-2006 08:43 AM |
| sqlplus invocation | new2ss | Shell Programming and Scripting | 4 | 02-07-2006 12:41 AM |
| returning value from sqlplus | malaymaru | Shell Programming and Scripting | 1 | 01-31-2006 12:03 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
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
|
| Forum Sponsor | ||
|
|
|
|||
|
I'm not sure that is the problem shell_life, the problem i seem to be encountering more is that it does not seem to pipe the output to $LogDir/$sqlLogFile , if i run it without this part then the sql file executes correctly although I see the output on the screen.
|
|
|||
|
How are they not arrays?
They have been defined as such at the top of the code: set -A database set -A databaseUser set -A databasePassword set -A packageSpecs set -A packageBodies set -A procedures set -A triggers set -A functions set -A views set -A sqlScripts Its not that its writing the wrong things to the log, its that its not writing anything to the log, I expected to see the output of the sql, which is this case is a simple select statement. It seems to output to the screen as expected when I run it without the '>>' |
|
||||
|
LiquidChild,
Whenever asking for help on a specific shell, please display the entire shell. Anyone can name variables as they wish. Just because it is named as "arrays" it does not mean it is an array. Whithout the "set -A" statements that you later disclosed, your "for" statement leads people to believe that you are looping through a group of strings. Code:
for arrays in packageSpecs packageBodies procedures triggers functions views sqlScripts |
|
|||
|
Quote:
Again though thanks for the help |
|||
| Google The UNIX and Linux Forums |