This may be very basic. I am very beginner of PL/SQL, but I am stuck with this issue. If somebody know the solution, please let me know.
This code
DECLARE
v_objectID VARCHAR2(100);
v_account VARCHAR2(100);
BEGIN
v_objectID :='21,22';
DBMS_OUTPUT.PUT_LINE(v_objectID);
END;
/
Output is
21,22
Then,
This code
DECLARE
v_objectID VARCHAR2(100);
v_account VARCHAR2(100);
BEGIN
SELECT LISTAGG(x.ACCOUNT, ',') WITHIN GROUP (ORDER BY NULL) AS ACCOUNT
INTO v_account
FROM acctx x
where x.OBJECT_ID IN (21,22);
DBMS_OUTPUT.PUT_LINE(v_account);
END;
/
OUTPUT is
1001,2002
Then I try to do like this
DECLARE
v_objectID VARCHAR2(100);
v_account VARCHAR2(100);
BEGIN
v_objectID :='21,22';
SELECT LISTAGG(x.ACCOUNT, ',') WITHIN GROUP (ORDER BY NULL) AS ACCOUNT
INTO v_account
FROM acctx x
where x.OBJECT_ID IN (v_objectID);
DBMS_OUTPUT.PUT_LINE(v_account);
END;
/
I added v_objectID :='21,22';; This is causing the problem
The error is
ORA_07122: Invalid number ORA-06512: at line 9
How should I assign variable appropriately to output 1001,2002?
Thanks