I have a
SELECT which is quite slow and I think it'll be fast when using two
SELECT instead of a subselect or join.
Basically I need to select some numbers from a table and use them in the where-statement of another
At the moment I have working:
DECLARE v_skus VARCHAR2(255); BEGIN SELECT LISTAGG(num,',') WITHIN GROUP (ORDER BY num) INTO v_skus FROM VIEWNAME WHERE parent IN ('1000'); DBMS_OUTPUT.PUT_LINE('v_skus=' || v_skus); END;
That would give me a '
1001,1002' in the variable.
I want to use this now in another SELECT like
... WHERE number IN (v_skus)
If I put the second
SELECT in the
BEGIN block I get the error "INTO clause is expected in this SELECT statement".
So do I have to use another variable for the actual result, and how do I manage to get the actual tablelike result like a plain
SELECT would do?
Is my approach wrong?