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

Your script looks fine, as long as you have defined all of the variables (PRI_KEY*, col_name, etc.). Is it not working?

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

Thanks for your reply.