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

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
有帮助吗?

解决方案

Your procedure has IN OUT parameter. So while calling the procedure you should supply a variable to 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.

DECLARE
   param   NVARCHAR2 (20) := 'hahahahaha';
BEGIN
   disemvowel (param);
END;
/

其他提示

Generate new VARCHAR2 type variable to assign your IN (input) string.

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;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top