Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> ACCEPT in SQL*Plus script

ACCEPT in SQL*Plus script

From: Andy Kent <andykent.bristol1095_at_virgin.net>
Date: 3 Feb 2005 03:11:34 -0800
Message-ID: <1107429094.816554.289950@z14g2000cwz.googlegroups.com>


I'm trying to run the following shellscript containing SQL*Plus code. The ACCEPT statement is completely ignored and at no point does &yn get prompted for. The script just flies through as though the ACCEPT wasn't there.

I know there are limitations on how you can mix SQL*Plus, SQL and PL/SQL code but I can't work out what I need to do to get the script to work as intended. Can anyone help please?

It works fine if I just paste the code text into a SQL*Plus session.

#!/bin/ksh
sqlplus oracle/oracle <<EOF
define yn=n

select * from test.tab1
where status = 'P'
and id in
(select id from test.tab2);

accept yn default 'n' prompt "Update rows? (y/n)"

update test.tab1
set status = null
where status = 'P'
and id in
  (select id from test.tab2)
and '&yn' = 'y';

EOF Received on Thu Feb 03 2005 - 05:11:34 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US