【问题标题】:Unable to get user input in PL in sqldeveloper无法在 sqldeveloper 的 PL 中获取用户输入
【发布时间】:2016-06-04 03:08:00
【问题描述】:

我正在尝试在一个过程中获取用户在 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

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

【问题讨论】:

  • 我在 sqldeveloper 中没有遇到任何错误

标签: plsql oracle-sqldeveloper procedures


【解决方案1】:

请执行以下语句:

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

【讨论】:

  • 感谢您的回复,但我需要用户输入。
【解决方案2】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-09
    • 2012-08-17
    • 1970-01-01
    • 2020-10-01
    相关资源
    最近更新 更多