|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | 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 and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Use sqlplus statement inside case sentence
Hello, I have a problem. I want to launch a different sql queries for different shell parameter values, something like this. Code:
#/bin/bash
case $1 in
"A")
sqlplus -s user/pass << SQL
query A;
SQL
"B") sqlplus -s user/pass << SQL2
query B;
SQL2
*) echo "something"
esacThe problem is that the first sqlplus connection does not finish (with SQL string) and the rest of the code is considered "A" case, esac included. So case statment is bad defined. Anyone can help me? I was looking inside this forum and I didnīt find something similar Thanks a lot!! and sorry about me english |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
The ending SQL is not seen. It needs to be in the leftmost column. Or structured differently Your here doc need to be one of these: Code:
sqlplus -s user/pass <<-SQL
query A;
SQL
## OR this way
sqlplus -s user/pass << SQL
query A;
SQLNote the red dash. |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Yes!! It was the dash!!
Thank you so much!! And you understood me, that was nice Last edited by Vares; 03-01-2013 at 08:29 AM.. |
|
#4
|
|||
|
|||
|
Pls be aware that the indenting chars need to be <TAB>s in the first case! cf.
man bash .
|
| Sponsored Links | ||
|
![]() |
| Tags |
| case, shell, sqlplus |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Connecting sqlplus from UNIX with multiple select statement | lovelysethii | Shell Programming and Scripting | 1 | 03-01-2013 01:06 AM |
| SQLPlus Case statement on a substring | chris01010 | Programming | 1 | 10-16-2012 04:01 PM |
| how to use sqlplus command inside for loop | deepakprasad29@ | Shell Programming and Scripting | 1 | 09-29-2011 04:55 AM |
| Regular expression inside case statement notworking | proactiveaditya | Shell Programming and Scripting | 5 | 06-17-2011 03:30 PM |
| multiple lines inside a case statement | gotam | Shell Programming and Scripting | 2 | 04-23-2010 07:41 AM |
|
|