|
|||||||
| 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
|
|||
|
|||
|
How to get a numeric value from Oracle to UNIX variable without spaces?
Hi, I am using the below code to get a numeric value from oracle to unix variable: Code:
BD_RC_CNT=`sqlplus -s ${WMD_DM_CONNECT} <<EOF
set heading off
set pagesize 0
Select count(*)
from wmd_bad_data
where proc_id = ${PROC_ID}
and file_id = ${FILE_ID}
and file_dt = to_date(${DATADATE},'yyyymmdd');
exit
EOF`I issued echo command and output is below: Code:
$ echo $BD_RC_CNT 6 How ever when i tried to find the length of the variable it shows 3 instead of 1: $ echo `expr length "$BD_RC_CNT"` 3 Can somebody please help in removing the extra characters ? Thanks in advance!
Last edited by jim mcnamara; 03-15-2013 at 09:06 AM.. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
did you try Code:
... Select trim(count(*)) ... ... |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Hi try this: mind the spaces: "read|space|BD_RC_CNT|space|<|space|<( etc..." Code:
read BD_RC_CNT < <(sqlplus -s ${WMD_DM_CONNECT} <<EOF
set heading off
set pagesize 0
Select count(*)
from wmd_bad_data
where proc_id = ${PROC_ID}
and file_id = ${FILE_ID}
and file_dt = to_date(${DATADATE},'yyyymmdd');
exit
EOF) |
|
#4
|
||||
|
||||
|
Check whether you have tab in BD_RC_CNT Code:
echo "$BD_RC_CNT" |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Thanks, Both the solutions worked perfectly. And yes when i issued the command echo "$BD_RC_CNT" it showed as below Code:
$ echo "$BD_RC_CNT"
6these seem to be some spaces then 6. may be 2 space then 6. Thanks again for the help.
|
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
It might be single tab, space and 6. You can check that using cat Code:
echo "$BD_RC_CNT" | cat -vet |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Agreed with CTSGNB u can filter this in oracle itself using trim...
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to get Oracle variable in UNIX? | Arun Mishra | Shell Programming and Scripting | 7 | 02-27-2013 10:12 AM |
| trim spaces in unix for variable | manish8484 | Shell Programming and Scripting | 6 | 02-09-2012 07:04 AM |
| delete spaces in the variable in unix script? | MARY76 | Shell Programming and Scripting | 14 | 01-17-2007 11:08 AM |
| How to pass unix variable to oracle | chiru | UNIX for Dummies Questions & Answers | 1 | 06-12-2006 04:10 PM |
| Replace spaces with 0's having numeric values. | videsh77 | Shell Programming and Scripting | 1 | 04-15-2005 01:22 AM |
|
|