oracle - When does a deterministic function use the previous calculated value? -


Consider a deterministic function such as:

  create or function SCHEMA.GET_NAME (Ss_id nvarchar2) Returns nvarchar2 DATRMist is TMPVR Discussion 2 (500); Select the name from the log into tmpvar from logistics. Organizations_item where id = ss_id; Return tmpvar; END ss_name;  

Using Todd I called SCHEMA.GET_NAME (1) and gives it A . I changed the value again from a to the b table and returned SCHEMA.GET_NAME (1) to B .

This is a good result but I am afraid that the price is not being updated, which is said:

When in the Oracle Database One of the contexts faces a deterministic function, compared to reexecuting the function, if you later change the words of the function, you manually reconstruct all the function-based indexes and physical views manually. Do not be.

In the case of GET_NAME (1) an old cached value ( a instead of B )?

If you select from a table, then not the result of your function Deterministic A. It is that always will produce the same output by looking at the same initial conditions.

It is possible to change information in a table, so to quote from a function that chooses from a table is not deterministic:

returns the results of the function Can use any kind of package variable that does not otherwise specify this section to define a function that accesses the database in any way. The results of doing so are not captured if the data Function again chooses not to refine.

In other words, Oracle does not guarantee that the results of the function will be accurate (they are just). If your table is stable and is unlikely to change anytime, then it should be fine, but it is not something I would ever like to trust. To answer your question, let's say that Oracle will return anything other than the cached value within the same transaction / session.

If you need to sharpen it then there are two ways first of all, check that you have an index on id !

  1. Just join this table if your function is only this then there is no need for the existence of the function.

  2. Usage (Not necessarily possible but worth trying). Select

      from (your_table  

    ), get_name (: id), create a memory hash in the results of the oracle function, such as Result cache If you are executing the same function multiple times, the oracle will kill the cache instead of the function.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -