有人能指出我在这里遗漏了什么吗?
下面是一个最小的例子:
var c clob
exec dbms_lob.append(:c, 'test')
print c
它产生这个错误:
BEGIN dbms_lob.append(:c, 'test'); END;
Error report -
ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275
ORA-06512: at "SYS.DBMS_LOB", line 656
ORA-06512: at line 1
06502. 00000 - "PL/SQL: numeric or value error%s"
*Cause: An arithmetic, numeric, string, conversion, or constraint error
occurred. For example, this error occurs if an attempt is made to
assign the value NULL to a variable declared NOT NULL, or if an
attempt is made to assign an integer larger than 99 to a variable
declared NUMBER(2).
*Action: Change the data, how it is manipulated, or how it is declared so
that values do not violate constraints.
我检查了Oracle文档关于绑定变量,它说
当您执行 VARIABLE ... CLOB 或 NCLOB 命令时,SQL*Plus 将 LOB 定位器与绑定变量相关联。
所以我不认为这是因为没有分配给
c
的定位器。
在像这样使用它之前,您需要“创建”lob。
SQL> var c clob
SQL> exec dbms_lob.createtemporary(:c,false);
PL/SQL procedure successfully completed.
SQL> exec dbms_lob.append(:c,'acb');
PL/SQL procedure successfully completed.
SQL> print :c
C
--------------------------------------------------------------------------------
acb