![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | 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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Add single quotes in string | mrjunsy | UNIX for Dummies Questions & Answers | 1 | 07-18-2008 10:09 AM |
| Double quotes or single quotes when using ssh? | password636 | Shell Programming and Scripting | 3 | 05-29-2008 08:52 PM |
| awk to print ' (single quotes) | orahi001 | UNIX for Dummies Questions & Answers | 2 | 03-11-2008 04:30 PM |
| echo using single quotes | chella | Shell Programming and Scripting | 3 | 10-29-2007 12:54 AM |
| im stuck! 'single quotes' | satnamx | UNIX for Dummies Questions & Answers | 4 | 03-29-2006 06:44 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
||||
|
Hi.
please help me to write the following query in a shell script. the Query is :select no,salary from emp_info where name='$var_name' the following is my code. #! /bin/sh var_name=$1 sqlplus -s user/pwd@DB << EOF select no,salary from emp_info where name="'$var_name'"; exit EOF Note: I can use the code for the number comparision. please help me to get the sigle quotes in that query.. Thankyou all for your valuable answers.. |
|
||||
|
Hi little_wonder,
Just remove the double quotes it will work fine in normal case ( where the names wont hav single quotes in it) Code:
select no,salary from emp_info where name='$var_name'; Last edited by panyam; 05-08-2009 at 03:47 AM.. |
|
||||
|
Some Problem with the suggestion.
Hi Panyam,
Thankyou so much for the given solution. But this i have tried already. but with this i feel a issue that the filed reterived from that query is with spaces and new linr char.. For example when you try to display the result. #! /bin/sh var_name=$1 no=` sqlplus -s user/pwd@DB << EOF select no,salary from emp_info where name="'$var_name'"; exit EOF` echo "No is $no" The result is like, no is 123 please give me a solution. |
|
||||
|
Your query is returning name as well as number , but your output shows only number value.
how ever try the following , which is working fine for me. Code:
#! /bin/sh
var_name=$1
op=`sqlplus -s user/pwd<< EOF
set head off
set feed off
set echo off
set line 999
select no,salary from emp_info where name='$var_name';
exit
EOF`
no=`echo $op |awk '{ print $1}'`
salary=`echo $op |awk '{ print $2}'`
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|