从用户获取 2 个输入并在 PLSQL 中调用过程

Taking 2 inputs from user and calling procedure in PLSQL

嘿,我正在尝试调用一个包含两个参数的过程,这两个参数都应该取自 user.So 我想出了这个不起作用的代码。(我正在使用 SQL开发者)

create or replace procedure upd( x in binary_double , y in char) as
res binary_double;
begin
  dbms_output.put_line('Hello World');
end;

/*User input and calling of function*/
accept X binary_double prompt 'Enter percentage X (lower case)';
accept Y char(2) prompt 'Enter product type (lower case)';
call upd(&X, &Y);

提示输入两次后出现如下错误

old:call upd(&X, &Y)
new:call upd(12, a)

Error starting at line 69 in command:
call upd(&X, &Y)
Error report:
SQL Error: ORA-06576: not a valid function or procedure name
06576. 00000 -  "not a valid function or procedure name"
*Cause:    Could not find a function (if an INTO clause was present) or
           a procedure (if the statement did not have an INTO clause) to
           call.
*Action:   Change the statement to invoke a function or procedure

如果我像这样调用程序“call upd(&X,'a')”,它会顺利运行,但如果我在上面调用它,它会惨败manner.So问题是为什么会发生这种情况以及如何摆脱它?

首先,accept不让你指定字符长度,只是一个SQL*Plus风格的格式,所以提示应该是:

accept Y char format a2 prompt 'Enter product type (lower case): '

(我更喜欢以冒号和空格结束每个提示 space,因为它让输入值的人更清楚,但这取决于您。)

其次,您需要引用字符串值。试试这个:

call upd(&X, '&Y')