Hello and welcome to the forum,
First - make sure you use proper/consistent terms. Database tables do not have records - they have rows.
and it does not work.
Basically gives no information that can be used to help you. . . What does "didn't work" mean? Did it not compile? Was there an abend? Was the wrong output written? Was no output written?
To do what you want you need to read the GOLD record, open the cursor and fetch all of the GOLD rows, and write them to the output, and close the cursor . Then read the SILVER record, and repeat the process. The cursor open and processing would be code that is performed for each record in the original input file. The external files should be opened at the beginning of the program and closed after all processing is done.