Use sqlplus statement inside case sentence | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Use sqlplus statement inside case sentence

Shell Programming and Scripting


Tags
case, shell, sqlplus

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-01-2013
Vares Vares is offline
Registered User
 
Join Date: Mar 2013
Last Activity: 1 March 2013, 8:29 AM EST
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
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"
  

esac

The 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  
Old 03-01-2013
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 18 April 2014, 11:10 PM EDT
Location: NM
Posts: 10,058
Thanks: 250
Thanked 756 Times in 711 Posts
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;
SQL

Note the red dash.
The Following 3 Users Say Thank You to jim mcnamara For This Useful Post:
panyam (03-01-2013), Vares (03-01-2013), Yoda (03-01-2013)
Sponsored Links
    #3  
Old 03-01-2013
Vares Vares is offline
Registered User
 
Join Date: Mar 2013
Last Activity: 1 March 2013, 8:29 AM EST
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
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  
Old 03-01-2013
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 17 April 2014, 7:46 AM EDT
Location: Aachen, Germany
Posts: 3,514
Thanks: 51
Thanked 819 Times in 782 Posts
Pls be aware that the indenting chars need to be <TAB>s in the first case! cf. man bash .
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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



All times are GMT -4. The time now is 02:53 AM.