Oracle: eval function

The function takes some expression as the argument and executes it, returning output in the varchar string

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;
/

The discussion and examples could be found there

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>