1

I have a PL/SQL function FN_CALC(emp_sal) which returns a Value. PL/SQL Function is working properly. Using the return value of the function I need to update the my oracle query(ie when function returns 1000 one condition else another condition).

Based on the output of Function I need to update the query. Below is my query.

update EMPLOYEE_MASTER 
set EMP_GRADE = case 
    when EMP_GRADE < (FN_CALC(emp_sal)) 
    then EMP_GRADE ='A'
    end;

Kindly help to solve.That is depending on the output of PL/SQL Function the udpate statement should work.

Regards Prakash

2
  • You can call a function from sql query as follows : select function_name(param) from dual; You may execute the update statement I've posted as the answer and accept & up vote it if that works fine, otherwise, post the result/error so that its clear to suggest next steps Commented Jul 3, 2015 at 13:17
  • upvote pls, being greedy for reputation :) Commented Jul 6, 2015 at 5:41

1 Answer 1

1

Try this

UPDATE employee_master 
    SET emp_grade = (
    CASE 
        WHEN (emp_grade < (SELECT FN_CALC(emp_sal) FROM DUAL))
        THEN 'A'
        ELSE emp_grade
    END);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.