Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to call function with column that is a result of another function call

Pavel_pOct 5 2015 — edited Oct 5 2015

Hi all,

I would like to know how to write efficiently a query that calls a function with a result of another function call. Something that would look like

select empno, very_long_calculation(empno) as calc_result, calc_result * 5 as multiplied_calc_result from emp;

It's possible to write

select empno, very_long_calculation(empno) as calc_result, very_long_calculation(empno) * 5  as multiplied_calc_result from emp;

but, if I'm not wrong, in such case the same calculation would be performed twice (and I already have the result). It would be certainly possible to use the WITH clause but I'm curious if there is some more elegant way.

Regards,

Pavel

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 2 2015
Added on Oct 5 2015
12 comments
2,001 views