What is a purity level? How it is should be taken into consideration when your writing any database objects i.e., trigger,function, procedure etc.,

Questions by kameshakundy   answers by kameshakundy

Showing Answers 1 - 7 of 7 Answers

Ritu

  • Apr 25th, 2006
 

Purity level defines what type of datastructure function reads and modify.

Threre are 4 types of purity level

1)WNDS(Write No Database State)

2) RNDS(Read No Database State)

3)WNPS(Write No Package State)

2) RNPS(Read No Package State)

For package function , PRAGMA RESTRIC_REFRENCES is required.

Ex.    PRAGMA RESTRICT_REFRENCES(functionname,WNPS,RNPS)

pari

  • Mar 14th, 2007
 

pragma_restrict_references is a compiler directive to check the purity level of functions used in packages.
The restriction on a function that it cannot do update, insert or delete when used in select statement does not stop it from compiling the err is given only at run time.
So the compiler directive provides hints to the compiler to avoid any such problem.
The four states are given above are absolutely correct 

  Was this answer useful?  Yes

asrafpa

  • Sep 26th, 2010
 

The function purity level defines what structures the function reads or modifies.

Following are the purity levels

1) WNDS - Writes No Database State i.e. Function does not modify any database tables (No DML)
2) RNDS - Reads No Database State i.e. Function does not read any tables (No select)
3) WNPS - Writes No Package State i.e. Function does not modify any packaged variables (packaged variables are variables declared in a package specification)
4) RNPS - Reads No Package State i.e. Function does not read any packaged variables

You can write the following in your package specification

CREATE PACKAGE loans AS
FUNCTION credit_ok RETURN BOOLEAN;
PRAGMA RESTRICT_REFERENCES (credit_ok, WNDS, RNPS);
END loans;
/
The package will execute depending on the purity level you have specified. You can give multiple purity levels too.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions