Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can update statement be used in result cache function?

unknown-879931Mar 27 2015 — edited Apr 8 2015

Hi All,

I just came across an interesting question. In the following function UPDATE statement is used, even though the function is created RESULT_CACHE. It seems illogical. I am just wondering, is it possible?

If so, why RESULT_CACHE is used?  Because it means "do not execute the function, look the hash table for the result and return result to the user" if there is UPDATE statement, so doesn't that mean it has to execute for each call and using with RESULT_CACHE and UPDATE/DELETE/MERGE is illogical or wrong?

Thanks for your help.

CREATE OR REPLACE FUNCTION plch_get_data (id_in IN INTEGER)

   RETURN VARCHAR2

   RESULT_CACHE

IS

BEGIN

   DBMS_OUTPUT.put_line ('Executed');

   UPDATE plch_data

      SET nm = UPPER (nm)

    WHERE id = id_in;

   COMMIT;

   RETURN 'UPPER';

END;

/

This post has been answered by Steven Feuerstein-Oracle on Mar 30 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 6 2015
Added on Mar 27 2015
23 comments
3,829 views