468,117 Members | 1,493 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,117 developers. It's quick & easy.

fetching data from database after switching the user inside scritp

1
Hi,

I need to fetch the data from database and based on the user type i have to start some service based on user type from withing my script. I am getting some syntax error that i am not able to resolve. It will be much appreciated if some one can help me out. Error block is followed by code block.
Code block:

sqlquery="sqlPlus << ENDCOMM \
SET ECHO OFF; \
SPOOL user_details.dat ; \
SELECT DISTINCT UNIX_NAME,USER_TYPE from OPERATION_USERS where UNIX_NAME IS NOT NULL ; \
SPOOL OFF; \
ENDCOMM"

su ${UnixUser} -c "${sqlquery}" 1>>/var/log/acs 2>&1


Error block:

bash: -c: line 1: syntax error near unexpected token `('
bash: -c: line 1: `sqlPlus << ENDCOMM SET ECHO OFF; SPOOL user_details.dat ; SELECT DISTINCT UNIX_NAME,USER_TYPE from OPERATION_USERS where UNIX_NAME IS NOT NULL AND LENGTH(trim(UNIX_NAME))>0 and (UNIX_NAME,USER_TYPE) in(SELECT UNIX_NAME,max(USER_TYPE) from OPERATION_USERS where UNIX_NAME IS NOT NULL AND LENGTH(trim(UNIX_NAME))>0 group by UNIX_NAME) ; SPOOL OFF; ENDCOMM'
Oct 9 '07 #1
0 1131

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by markaelkins | last post: by
2 posts views Thread by asad | last post: by
9 posts views Thread by Jenden0 | last post: by
1 post views Thread by nasirmajor | last post: by
22 posts views Thread by Sandman | last post: by
13 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.