无法在sqldeveloper中获得PL中的用户输入

时间:2016-06-04 03:08:01

标签: plsql oracle-sqldeveloper procedures

我试图在一个过程中在SQLDeveloper中获取用户输入。但是,我得到了一些错误,例如"缺少定义"。请帮我解决这个问题。提前谢谢。

DECLARE
a NUMBER(5);    
BEGIN
a := :a;
DBMS_OUTPUT.PUT_LINE('We took the number as ' || a);
END;

错误看起来像这样。

Error starting at line : 1 in command -
DECLARE
a NUMBER(5);    
BEGIN
a := :a;
DBMS_OUTPUT.PUT_LINE('We took the number as ' || a);
END;
Error report -
Missing defines
We took the number as 15

虽然我在底部得到了正确答案,但为什么会出现这种错误?

2 个答案:

答案 0 :(得分:0)

请执行以下声明:

  DECLARE
    a NUMBER(5):=15;    
    BEGIN
    a := a;
    DBMS_OUTPUT.PUT_LINE('We took the number as ' || a);
    END;

答案 1 :(得分:0)

为了在PLSQL Block中输入用户,我们使用&,& givenumber将在运行时获得用户输入。

DECLARE
a NUMBER(5);    
BEGIN
a := &givenumber;
DBMS_OUTPUT.PUT_LINE('We took the number as ' || a);
END;