Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

List values in a variable

user11334489Jul 28 2023

Hi All,

DECLARE
v_deptnos sys.odcinumberlist;
BEGIN
v_deptnos := (10,20,30);
EXECUTE IMMEDIATE 'CREATE TABLE TEST_EMP
AS SELECT * FROM EMP
WHERE DEPTNO IN(SELECT column_value
FROM TABLE ('||v_deptnos||'))';
END;

Error starting at line : 1 in command -
DECLARE
v_deptnos sys.odcinumberlist;
BEGIN
v_deptnos := (10,20,30);
EXECUTE IMMEDIATE 'CREATE TABLE TEST_EMP
AS SELECT * FROM EMP
WHERE DEPTNO IN(SELECT column_value
FROM TABLE ('||v_deptnos||'))';
END;

Getting below error while executing the above script.

Error report -
ORA-06550: line 4, column 18:
PLS-00382: expression is of wrong type
ORA-06550: line 4, column 5:
PL/SQL: Statement ignored
ORA-06550: line 5, column 23:
PLS-00306: wrong number or types of arguments in call to '||'
ORA-06550: line 5, column 5:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:

I am using Oracle 19c database.

How to solve it.

Thanks in advance.

Best Regards,

Abu

Comments
Post Details
Added on Jul 28 2023
6 comments
2,191 views