Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
CREATE OR REPLACE FUNCTION getsal(id_param NUMBER)
RETURN NUMBER
IS
    sal_increase employees.salary%TYPE;
    tenure NUMBER;
    sal NUMBER;
BEGIN
    SELECT
        salary,
        MONTHS_BETWEEN(SYSDATE, hire_date)/12
    INTO
         sal_increase,
         tenure
    FROM employees
    WHERE employee_id = id_param;
    IF tenure <= 12 THEN
        sal_increase := 0;
    ELSIF tenure BETWEEN 13 AND 36 THEN
        sal_increase := sal_increase+(sal_increase * .05);
    ELSIF tenure BETWEEN 37 AND 60 THEN
        sal_increase := sal_increase+(sal_increase * .1);
    ELSIF tenure BETWEEN 61 AND 120 THEN
        sal_increase := sal_increase+(sal_increase * .15);
    ELSE
        sal_increase := sal_increase+(sal_increase * .2);
    END IF;
        RETURN sal_increase;
END;

DECLARE
    newsalary NUMBER;
BEGIN
    newsalary := getsal(101);
    DBMS_OUTPUT.PUT_LINE('New Salary:'|| newsalary);
END;
Posted
Updated 13-Sep-10 0:19am
v3
Comments
Tom Deketelaere 13-Sep-10 6:01am    
And your question is?
What is this function supposed to do and do you get a error?
Have you posted everything including comments in the function. When receiving a error line number the comments are counted as well so...
Sandeep Mewara 13-Sep-10 6:21am    
It would be better if you add on what are you trying to do and line 14 is?

1 solution

SELECT INTO statement is not correst. but u might get more syntax errors.

Regards
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900