To get value from oracle & assign it in UNIX variable

Hi Team,

I need to get data from oracle table & need to assign that value to unix variable. I have serched the same in other threads. I found the following code.

I have tried code to get the value from oracle. but it is not working. The error shows invalid identifier "NAM" & then list all the files which is in current folder. but if i execute same SELECT query in oracle SQL*PLUS it is working fine.

v_test=$(sqlplus -s apps/apps <<END
set feedback off;
set heading off;
select c_code from tab_code where c_name = 'NAM';
EXIT;
END)

To enable sqlplus, first i need to enter . /files/common/setenv_common.

Thanks & Regards.

That code looks fine to me. What shell are you running it in? Are you sure you copied it correctly? Did you include the . /files/common/setenv_common somewhere in your own version?

Please post your code rather than the code that you found in the other thread.

Hi

. /files/common/setenv_common
v_test1=$(sqlplus -s d_owner/d_ower12@ciw <<END
set feedback off;
set heading off;
select fed_dt from tab_nam_owner where source_desc = 'NAM';
EXIT;
END)

This is my code.

Looks fine to me too. What shell is it running under, and on what OS exactly?

If you run it like this, does the correct query result get displayed?

. /files/common/setenv_common 
sqlplus -s d_owner/d_ower12@ciw <<END 
set feedback off;
set heading off;
select fed_dt from tab_nam_owner where source_desc = 'NAM';
EXIT;
END

Run the block mentioned by Annihilannic (after removing -s; no need to be silent when we are debugging) and post the output.

Hi All,

v_test1=`sqlplus -s CASHDT_STG_OWNER/cashdt_stg_phoenix1@iws <<END
set feedback off;
set heading off;
select fed_dt from tab_nam_owner where source_desc = 'NAM';
EXIT;
END`

Following is working fine now.

Thank you all for your help...