Can you please eloborate on the part where you mentioned about caching the result set in a temporary table or object. I want a trigger on a table XXX to read data from a table YYY every time it gets triggered. This will prove to be expensive without any caching. Please give your suggestions with some code templates if possible.
Thanks in advance.
Main Topics
Browse All Topics





by: DrSQLPosted on 2008-07-17 at 18:26:24ID: 22032037
Well, you can make the table a cached table:
alter table MyTable cache;
Which says that it stays in the small table cache until the buffers absolutley need to be flushed.
But, if you want the RESULTS to be cached, you would need to create another object (probably a table) that could be cached. A package can also maintain data across calls to entry point within it, but that is usually session specific (you write an addition block os pl/sql code that initializes your variables and the first time a procedure from that package is called the block is run and any global variables retain their values). But, if you were to set up a service that ran as a daemon of scheduled job you could use a package that would keep the results in a cursor and then use advanced queue or messaging (which Oracle has built into supplied pl/sql packages) to transmit the data to the trigger.
Another approach is to use an index that contains all of the column, with the most selective columns listed first. If all of the columns that the trigger might use (in any way, not just in a where clause), then there's no need for the table to be read.
Good luck!