I have a procedure that is using a temp table. I want to get rid of the temp table and use a collection to remove I/O. it has about 5000 records.
I want to insert data into this collection then I want to access the collection like:
select * from table(my_type_for_gtt)
I could not find an example of this. I’m confused, do I have to first create a record type and then create as table of?
can someone please show a quick small example?
You are heading in the right direction – first create your types
Next some example functions returning ‘rows’ of your collection
Variation – this time we use pipelining, so that the results are returned to the query as they are created. Note that despite being a function, there is no end RETURN for a PIPELINED function.
To replace your temp table with purely in-memory data, you will need something to store your collection in – i.e. a package with state.