Monday, May 12, 2008

EVAL function

In several other languages I have written in, there is a native function that will evaluate an expression. Unfortunately, Oracle does not have this natively. From another web site I found a simple way to achieve this function.


create or replace function eval (expr varchar2)
return varchar2
as

ret varchar2(4000);

begin
execute immediate 'begin :result := ' || expr || '; end;'
using out ret;
return ret;
end;


source: http://www.adp-gmbh.ch/blog/2005/may/5.html

No comments: