web analytics

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 […]