Oracle 在&;线

Oracle 在&;线,oracle,plsql,oracle-sqldeveloper,Oracle,Plsql,Oracle Sqldeveloper,代码: 是否发生了错误?我使用sql developer时出现了什么错误。对字符串类型的绑定变量使用引号: DECLARE NAME VARCHAR2(20); begin DBMS_OUTPUT.PUT_LINE('enter the name'); NAME := &NAME1; DBMS_OUTPUT.PUT_LINE(name); end; 当提示输入NAME1的值时,您当然需要输入不带引号的名称。e、 g.当提示输入名称值时,输入JOHN而不是'JOHN'。这是答案的一半。另

代码:


是否发生了错误?我使用sql developer时出现了什么错误。

对字符串类型的绑定变量使用引号:

DECLARE
NAME VARCHAR2(20);
begin
DBMS_OUTPUT.PUT_LINE('enter the name');
NAME := &NAME1;
DBMS_OUTPUT.PUT_LINE(name);
end;

当提示输入NAME1的值时,您当然需要输入不带引号的名称。e、 g.当提示输入名称值时,输入
JOHN
而不是
'JOHN'

这是答案的一半。另一半是OP还可以在传递给替换变量的值中加引号。当提示输入名称时,用户可以输入
'JOHN'
,而不是
JOHN
(如果PL/SQL代码中没有单引号,这将不起作用)。一个解决方案或另一个解决方案都会起作用;在不同的情况下,每种方法都可能是更好的选择。
DECLARE
NAME VARCHAR2(20);
begin
DBMS_OUTPUT.PUT_LINE('enter the name');
NAME := '&NAME1';
DBMS_OUTPUT.PUT_LINE(name); -- by the way, i assume your serveroutput option is on, if not just issue "set serveroutput on" before this statement.
end;
/