Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
We are trying to load random rows from the source table in Oracle to do validation of what is in our target. Is there a way to do that?
A query in Oracle would look something like:
SELECT * FROM <TABLE>
SAMPLE(<sample percentage>)
Thank you!
Hello @JamieKay ,
It looks like you are trying to replicate random rows using a Full Load ONLY task, which may not be meaningful for the CDC (Change Processing) stage. If my understanding is correct, here are a few possible approaches:
Filter Random Rows Using a Primary Key (PK) Range
WHERE PK BETWEEN TRUNC(DBMS_RANDOM.VALUE(1, 30000))
AND TRUNC(DBMS_RANDOM.VALUE(1, 30000)) * 2Use a View to Select Random Rows
SELECT <column_list> FROM <table> SAMPLE(10);
SELECT <column_list> FROM <table>
ORDER BY DBMS_RANDOM.VALUE
FETCH FIRST 10 ROWS ONLY;
Hope this helps!
John.
That worked - thank you!!!
Can I do the same using a Record Selection Condition?
What I am wanting is 10 records randomly chosen where <some date column> >= to_char(current_date - 180, 'YYYY-MM-DD').
Thank you again, @john_wang!
Hello @JamieKay ,
Thanks for the update. Yes, you can; however, the passthrough filter offers the best performance since it eliminates unnecessary rows before they are retrieved from the source database. Please see my comments on the comparison of the three filters.
Regards,
John.
Hello @JamieKay ,
It looks like you are trying to replicate random rows using a Full Load ONLY task, which may not be meaningful for the CDC (Change Processing) stage. If my understanding is correct, here are a few possible approaches:
Filter Random Rows Using a Primary Key (PK) Range
WHERE PK BETWEEN TRUNC(DBMS_RANDOM.VALUE(1, 30000))
AND TRUNC(DBMS_RANDOM.VALUE(1, 30000)) * 2Use a View to Select Random Rows
SELECT <column_list> FROM <table> SAMPLE(10);
SELECT <column_list> FROM <table>
ORDER BY DBMS_RANDOM.VALUE
FETCH FIRST 10 ROWS ONLY;
Hope this helps!
John.
That worked - thank you!!!
Can I do the same using a Record Selection Condition?
What I am wanting is 10 records randomly chosen where <some date column> >= to_char(current_date - 180, 'YYYY-MM-DD').
Thank you again, @john_wang!
Hello @JamieKay ,
Thanks for the update. Yes, you can; however, the passthrough filter offers the best performance since it eliminates unnecessary rows before they are retrieved from the source database. Please see my comments on the comparison of the three filters.
Regards,
John.
Thank you @john_wang!
Thank you so much for your support @JamieKay