Ok,

I've got a table called CUSTOMER_DIM with about 4.5 million rows. I need to send a copy of this table to ORACLE with only 5000 rows. The table needs to have about the same distribution of data on a column called SOURCE_SYSTEM that mimics the distribution in the larger table

Basically I need a table where

CUSTOMER_DIM.SOURCE_SYSTEM =
'tms_frc' (21 rows)
'tms_clr' (72 rows)
'fas' (157 rows)
'ccss' (344 rows)
'tms_fas' (348 rows)
'corp' (704 rows)
'uty' (1171 rows)
'tms_ren' (2183 rows)

I was thinking I could write a simple cursor over each
of the distinct values and set a counter and then do a
while loop until counter = number of rows needed for
each distinct value until the table was populated.

The problem is that there are about 300 column values
in the table and the cursor is messy trying to define a
variable for each column type.

I know there is a ROWTYPE that you can specify for an
entire row. I'm hoping I can use that somehow but haven't
done a lot of this type of thing. Can anyone suggest a way to do this?

Is there a simple and clean way to loop through the CUSTOMER_DIM table and select, in the first case, 21 rows where source_system = 'tms_frc' and insert them into a table called CUSTOMER_DIM_SMALL? Then I would just change the where clause for each subsequent value.

Thanks,

Joe