Assignment v16

The assignment statement sets a variable or a formal parameter of mode OUT or IN OUT specified on the left side of the assignment := to the evaluated expression specified on the right side of the assignment.

<variable> := <expression>;

variable is an identifier for a previously declared variable, OUT formal parameter, or IN OUT formal parameter.

expression is an expression that produces a single value. The value produced by the expression must have a data type compatible with that of variable.

This example shows the typical use of assignment statements in the executable section of the procedure:

CREATE OR REPLACE PROCEDURE dept_salary_rpt (
    p_deptno        NUMBER
)
IS
    todays_date     DATE;
    rpt_title       VARCHAR2(60);
    base_sal        INTEGER;
    base_comm_rate  NUMBER;
    base_annual     NUMBER;
BEGIN
    todays_date := SYSDATE;
    rpt_title := 'Report For Department # ' || p_deptno || ' on '
        || todays_date;
    base_sal := 35525;
    base_comm_rate := 1.33333;
    base_annual := ROUND(base_sal * base_comm_rate, 2);

    DBMS_OUTPUT.PUT_LINE(rpt_title);
    DBMS_OUTPUT.PUT_LINE('Base Annual Salary: ' || base_annual);
END;