Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Oracle eval() function?

2,208 views
Skip to first unread message

thyc...@my-deja.com

unread,
Mar 27, 2000, 3:00:00 AM3/27/00
to
Does anybody know how to get Oracle to evaluate a string
as an expression in PL/SQL?
Something similar to the eval functions of VB, JavaScript and Perl.
e.g. eval("5+2*(3+200)/2")
Not having to write a custom function would be preferable...
TIA,
J


Sent via Deja.com http://www.deja.com/
Before you buy.

Chris Weiss

unread,
Mar 27, 2000, 3:00:00 AM3/27/00
to
<thyc...@my-deja.com> wrote in message news:8bogpp$q84$1...@nnrp1.deja.com...

> Does anybody know how to get Oracle to evaluate a string
> as an expression in PL/SQL?
> Something similar to the eval functions of VB, JavaScript and Perl.
> e.g. eval(" ")

> Not having to write a custom function would be preferable...
> TIA,
> J


You should read up on EXECUTE IMMEDIATE and SELECT <SOME EXPRESSSION> FROM
DUAL;

For example,

select 5+2*(3+200)/2 from dual;

Returns 208.

In a script you would use

EXECUTE IMMEDIATE 'SELECT '||<YOUR EXPRESSION> INTO <SOME VAR> FROM DUAL;

Chris
ch...@intralect.com


Barry Evans

unread,
Mar 28, 2000, 3:00:00 AM3/28/00
to
You can just do a select from dual

select (5+2*(3+200)/2)
from dual

and just use SELECT INTO to get it into a variable


DECLARE
sample_num number(10);
BEGIN
SELECT (5+2*(3+200)/2) INTO sample_num FROM dual;
END;

Barry

<thyc...@my-deja.com> wrote in message news:8bogpp$q84$1...@nnrp1.deja.com...
> Does anybody know how to get Oracle to evaluate a string
> as an expression in PL/SQL?
> Something similar to the eval functions of VB, JavaScript and Perl.

> e.g. eval("5+2*(3+200)/2")


> Not having to write a custom function would be preferable...
> TIA,
> J
>
>

0 new messages