Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

How is use sselect statement o/p in insert statement.

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 08-06-2008   -   Original Discussion by nkosaraju
nkosaraju nkosaraju is offline
Registered User
 
Join Date: Jul 2008
Last Activity: 6 August 2008, 9:26 PM EDT
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
How is use sselect statement o/p in insert statement.

Hi All,

I am using Unix ksh script.

I need to insert values to a table using the o/p from a slelect statement.

Can anybody Help!

My script looks like tihs.

---`sqlplus -s username/password@SID << EOF
set heading off
set feedback off
set pages 0
insert into ${TB_NAME}_D
(select
A.${PRI_KEY1},
A.${PRI_KEY2,
A.${PRI_KEY3},
${col_name}, - this is variable from script
A.${col_name},
B.${col_name}
from
${TB_NAME} A,
${DEV_DB}.${TB_NAME} B
where
A.${PRI_KEY1}=B.${PRI_KEY1} and
A.${PRI_KEY2}=B.${PRI_KEY2} and
A.${PRI_KEY3}=B.${PRI_KEY3} and
A.${col_name}!=B.${col_name} and
ROWNUM <= ${THRESHOLD})
;
commit;
exit;
EOF`


Thanks in advance
Sponsored Links
    #2  
Old Unix and Linux 08-06-2008   -   Original Discussion by nkosaraju
Annihilannic Annihilannic is offline Forum Advisor  
 
Join Date: May 2008
Last Activity: 28 October 2009, 7:03 PM EDT
Location: Sydney, Australia
Posts: 1,009
Thanks: 0
Thanked 2 Times in 2 Posts
Your script looks fine, as long as you have defined all of the variables (PRI_KEY*, col_name, etc.). Is it not working?
Sponsored Links
    #3  
Old Unix and Linux 08-06-2008   -   Original Discussion by nkosaraju
nkosaraju nkosaraju is offline
Registered User
 
Join Date: Jul 2008
Last Activity: 6 August 2008, 9:26 PM EDT
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
I got the script to run

I forgot to close the brace after Primary_key2 and quotes for the shell variable.

Thanks for your reply.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to insert date in a statement? pinpe Shell Programming and Scripting 8 07-09-2011 01:49 PM
How to insert numbers to a in between statement pinpe Shell Programming and Scripting 14 06-19-2011 05:33 PM
error in insert statement ragavhere Shell Programming and Scripting 2 12-08-2008 03:44 AM
Insert TAB in echo statement sunils27 Shell Programming and Scripting 5 08-26-2005 04:36 AM
awk command for INSERT statement nattynatty Shell Programming and Scripting 4 05-10-2002 03:11 PM



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