项目作者: frankiechapson

项目描述 :
An Oracle PL/SQL solution to get the value of an expression independently of its type
高级语言: PLSQL
项目地址: git://github.com/frankiechapson/EVALUATE_EXPRESSION.git
创建时间: 2019-03-18T11:43:27Z
项目社区:https://github.com/frankiechapson/EVALUATE_EXPRESSION

开源协议:GNU General Public License v3.0

下载


Value of an expression

An Oracle PL/SQL solution to get the value of an expression independently of its type

This simple, but usefull function returns with the value of an expression.
If you got the original expression instead of its value (in case if they are different) that means the expression is wrong and the function handle its as a constant string.

Example:

  1. exec dbms_output.put_line('constant number : ' || EVALUATE_EXPRESSION ( '42' ) );
  2. exec dbms_output.put_line('constant string : ' || EVALUATE_EXPRESSION ( 'Dog' ) );
  3. exec dbms_output.put_line('sql expression : ' || EVALUATE_EXPRESSION ( 'decode( 1, 2, 3, 4 )' ) );
  4. exec dbms_output.put_line('a select : ' || EVALUATE_EXPRESSION ( 'select * from dual' ) );
  5. exec dbms_output.put_line('plsql expression : ' || EVALUATE_EXPRESSION ( 'sqlerrm' ) );
  6. exec dbms_output.put_line('math expression : ' || EVALUATE_EXPRESSION ( '23*54/75*44' ) );
  7. exec dbms_output.put_line('date expression : ' || EVALUATE_EXPRESSION ( 'add_months(trunc(sysdate,''mm''),4) + 3' ) );
  8. exec dbms_output.put_line('boolean expression : ' || EVALUATE_EXPRESSION ( '1=2' ) );

Results:

  1. constant number : 42
  2. constant string : Dog
  3. sql expression : 4
  4. select : X
  5. plsql expression : ORA-0000: normal, successful completion
  6. math expression : 728,64
  7. date expression : 2019.07.04 00:00:00
  8. boolean expression : FALSE