473,385 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to evaluate and get results of formula stored in column?

I've a column with a string like this
"=1*.003*2*3" and I want to evalute this formula
to get the result (in the example is 0.018).
How I can get the rusult? Thanks in advance
Feb 5 '11 #1
2 8418
rski
700 Expert 512MB
Remove = with repexp_replace and use dynamic query
Expand|Select|Wrap|Line Numbers
  1. FOR i in SELECT column FROM your_table LOOP
  2. EXECUTE IMMEDIATE 'select '||i.column||' FROM DUAL ' INTO some_defined_variable;
  3. ....
  4. END LOOP;
  5.  
Feb 5 '11 #2
This was what I really need:

SQL> CREATE OR REPLACE FUNCTION calc(pi_val VARCHAR2) RETURN NUMBER IS
2 v_return NUMBER;
3 BEGIN
4 EXECUTE IMMEDIATE 'select '||pi_val||' from dual' INTO v_return;
5 RETURN v_return;
6 END;
7 /

Function created
SQL> SELECT calc('2*6*10') FROM dual;

CALC('2*6*10')
--------------
120

I found the solution at this link:
http://stackoverflow.com/questions/1...ring-in-oracle

Thanks anyway.
Feb 5 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: HumanJHawkins | last post by:
Hi, I am using data from multiple databases and/or queries. It would greatly simplify and speed things up if I could use CONTAINS in processing the results. However, "CONTAINS" requires the data...
4
by: John | last post by:
Hi everyone, I have a stored procedure which I use to query a table. The first part of the stored procedure uses a cursor to update a temp table whilst the second part of the query actually...
9
by: Wolfgang Kreuzer | last post by:
Try hard to become familiar with T-SQL. Can anybodey tell me the best way to deal with set's provided by a stored procedure. Til yesterday I thougt trapping set in temp table using INSERT EXEC...
1
by: S. Olivier | last post by:
Hey, again! How to evaluate a formula (stored in a field as "X / 60") replacing the "X" with a number? I replaced the "X" with a selected number but can't figure out how to obtain the result......
4
by: Bill Moran | last post by:
I'm having a little trouble understanding how to do something. I assume I'm just missing it in the documentation, so a pointer to relevent docs would be as welcome as a direct answer. I have a...
7
by: Paigey | last post by:
Hi all, Having a few problems with a select statement... I have a table containing values similar to results from a form and when submitted I want to get all results from the table that...
3
by: Reshmi Jacob | last post by:
Hello..... In my program I have 3 variables, say a = 10 b = 20 c = 30 I have a variable as string
0
kmartinenko
by: kmartinenko | last post by:
Hi all, I have come up with a solution on how to read a .csv file, perform a simple command on the values in one of the columns and then print the results onto the command prompt screen But...
1
by: japss | last post by:
I have got a column in my table which stores mathematical formulas as strings. The base question is how do I evaluate the "string formula" to get result? For example, I got a value like...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.