命令ACCEPT sql plus

时间:2015-09-14 08:16:10

标签: sql plsql sqlplus

我在sql plus中遇到ACCEPT命令的问题。我不知道我做错了什么 - 一直都有一个错误,上面写着:“当遇到下列情况之一时遇到符号”......“ 任何人? 提前谢谢。

select concat('poid_id: ',poid_id0) from przykladowa3 ;

set serveroutput ON;
declare
begin
DBMS_OUTPUT.PUT_LINE('Czy usuwamy? T/N');
end;
/
set scan on;
declare
mark char;
cursor cur is select * from przykladowa3;
rowtype cur%rowtype;
begin
ACCEPT mark char PROMPT 'Enter smth:  '
open cur;
  if (mark='T') THEN
    loop
        fetch cur into rowtype;
        exit when cur%notfound;
        delete from przykladowa3 where poid_id0=rowtype.poid_id0;
        DBMS_OUTPUT.PUT_LINE('Successfully removed: ' || rowtype.poid_id0);
        commit;
    end loop;  
  else 
        DBMS_OUTPUT.PUT_LINE('SOME TEXT');
  end if;
end;
/

错误:

ORA-06550: linia 6, kolumna 8:
PLS-00103: Encountered the symbol "MARK" when expecting one of the following:
:= . ( @ % ;

1 个答案:

答案 0 :(得分:3)

ACCEPT是一个sqlplus函数。不是PL / SQL。所以你不能在pl / sql范围内拥有它,因为解释器/引擎不会接受它。

/* sqlplus scope */
set serveroutput on
ACCEPT lastname CHAR FORMAT 'A20' PROMPT 'Enter employee lastname: ';

/*PLSQL engine */
begin
    dbms_output.put_line ('Variable is: &lastname');
end;
/

将接受移出pl / SQL作用域(加上sqlplus适用于sqlplus变量,而不是pl / sql)

相关问题