Skip to content
Advertisement

Select data from table by reading fetch condition from another table in Oracle

I need to write a plsql code which should read channel_id, retailer_id, start_date and end_date column from table multiple_retailer . Then pass these column data as fetch condition in Register table to retrieve data and finally create a csv file out of it.

Table: Multiple_retailer enter image description here

For example:

create a csv file for above result.

Again go to 2nd row of multiple_retailer, pass these columns in register table, fetch the data and append the result in csv file.

Please help me on this.

Edited: I am able to create single file with all retailer_id. How can i split them into multiple files based on Retailer_id.

For example: As shown in below image, i want to create 2 files : 1 with BUSTREAM-R and 1 with CASTLE-R

enter image description here

Below is my code

Advertisement

Answer

Added my comment as an answer. Please tick it is you’re happy with it as a solution…

If you order your cursor by Retailer_ID then you should be able to use logic in your LOOP to open a new file (and close the previous file) every time the value of Retailer_ID changes

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement