I am having a set of records say AA : SELECT SINGLE_COLUMN FROM SAMPLE_TABLE1 WHERE SOME_FILTER
. It returns a set of numbers
Now I need to execute a query which will get the input from A and get the extract (say B) for that output. B : SELECT COL1,COL2,COL3 FROM SAMPLE_TABLE2 WHERE COL1 IN (A)
. Taking input from A the above query will return a result set
This extract is expected to have more than 50 Million records.
I've tried to write a cursor to fetch this but couldn't find the right way.
DECLARE
CURSOR cur_insert
IS
SELECT single_column
FROM sample_table1
WHERE some_filter;
TYPE ty IS TABLE OF output_data_table%ROWTYPE;
ty_cursor ty;
BEGIN
OPEN cur_insert;
FOR i IN ty_cursor.FIRST .. ty_cursor.LAST
LOOP
SELECT col1, col2, col3
FROM sample_table2
WHERE col1 IN (i);
END LOOP;
END;
Need help to find a way to get this big extract. Currently I am having only SQL Developer in my workplace and Input tables are all my DB's internal tables
The simpliest way will be to use one single select:
SELECT COL1,COL2,COL3
FROM SAMPLE_TABLE2
WHERE COL1 IN ((SELECT SINGLE_COLUMN FROM SAMPLE_TABLE1 WHERE SOME_FILTER))
or
SELECT s2.COL1,s2.COL2,s2.COL3
FROM SAMPLE_TABLE1 s1
JOIN SAMPLE_TABLE2 s2
ON s2.COL1 = s1.SINGLE_COLUMN
WHERE s1.SOME_FILTER
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.