oracle 表达式“字符串”不能用作赋值目标 -SQL PLUS
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22270423/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
expression 'string' cannot be used as an assignment target -SQL PLUS
提问by COOLBEANS
I wrote the following procedure which was meant to be anonymous and remove all the vowels from a string, but when I call it I get an error: I've followed the advice given in a similar post, but it didn't help:Oracle PLS-00363: expression '' cannot be used as an assignment target
我编写了以下程序,该程序旨在匿名并从字符串中删除所有元音,但是当我调用它时出现错误:我遵循了类似帖子中给出的建议,但没有帮助:Oracle PLS-00363: 表达式 '' 不能用作赋值目标
SQL> CREATE OR REPLACE PROCEDURE disemvowel (string IN OUT NVARCHAR2)
2 IS
3 BEGIN
4 DBMS_OUTPUT.PUT_LINE(translate(string,'euioa',''));
5 END disemvowel;
6 /
Procedure created.
So good so far, but now I call it:
到目前为止很好,但现在我称之为:
SQL> BEGIN
2 disemvowel('hahahahaha');
3 END;
4 /
The Error message says:
错误消息说:
disemvowel('hahahahaha');
*
ERROR at line 2:
ORA-06550: line 2, column 12:
PLS-00363: expression 'hahahahaha' cannot be used as an assignment target
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored
回答by Noel
Your procedure has IN OUT parameter. So while calling the procedure you should supply a variableto it, so that it can hold the value that the procedure gives back. You cannot supply a value directly, as it cannot be modified by the procedure.
你的程序有 IN OUT 参数。因此,在调用过程时,您应该为其提供一个变量,以便它可以保存过程返回的值。您不能直接提供值,因为它不能被过程修改。
DECLARE
param NVARCHAR2 (20) := 'hahahahaha';
BEGIN
disemvowel (param);
END;
/
回答by elfekz
Generate new VARCHAR2 type variable to assign your IN (input) string.
生成新的 VARCHAR2 类型变量以分配您的 IN(输入)字符串。
PROCEDURE sp_name(
ps_list IN VARCHAR2,
...
write here other IN's and OUT's
...
)
AS
ps_list_copy VARCHAR2 (32000);
BEGIN
ps_list_copy := ps_list;
...
do your works with ps_list_copy
...
...
EXCEPTION WHEN OTHERS THEN
....
END sp_name;