Skip to content
Advertisement

Remove duplicate of collection in oracle

I have this type in my package:

Then I have this procedure where I populate this collection looping a table:

After this loop, I have my collection full of l_list_a.

I need a procedure to remove duplicates of this list based on some columns of its definition (table).

I thought to use the SET function but keeps giving me an error.

The table TABLE_A has 30 columns. I got a ‘key’ of 5 columns to determine if the record could be duplicated or not…

Any tips?

Thanks

Advertisement

Answer

In general you have to create a MAP MEMBER FUNCTION for the record. I don’t think it can be based on TABLE_A%ROWTYPE, you have to define the type manually.

See this example. Object STATIC_ROUTE has 6 attributes and IP_ADDRESS,NETWORK_MASK,NEXT_HOP is the key.

Now you can use SET function on STATIC_ROUTES variables.

However, you should try to get the result in a single SLQ statement. It could be similar to this one:

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