Oracle/Sql Query

Advertisement


Question
Dear Suchitra,

How do I execute a Formula which is stored in a Field for e.g.
I have a formula (X*Y)/2+Y*2) stored in a field and X & Y are other fields of a table .

Best Regards
Natraj

Answer
Hello Natrajan,

You can evaluate the formulas this way in Oracle 11g version, by using function-based virtual columns as below -

create table tab1
( x number,
 y number,
 formula generated always as ((X*Y)/2+Y*2));

insert into tab1 (x,y) values (2,4);
insert into tab1 (x,y) values (5,3);
commit;

select * from tab1;

The value of the formula will be calculated and shown by the select statement.

Hope this helps.

Regards

Suchitra

Oracle

All Answers


Answers by Expert:


Ask Experts

Volunteer


Suchitra Joshi

Expertise

I can answer questions regarding SQL, PL/SQL, Procedures, Functions, Triggers, SQL Loader, Oracle Forms, Oracle Reports, and some basic dba and performance tuning activities.

Experience

15+ years of Oracle PL/SQL Development

Education/Credentials
B.Sc (Electronics), Diploma in Computer Applications (DCA)

Awards and Honors
Oracle PL/SQL Developer Certified Associate (OCA)
Oracle Database: SQL Certified Expert
Brainbench certifications in Oracle Administration, PL/SQL, Developer 2000

©2016 About.com. All rights reserved.