DEV Community

AntDB
AntDB

Posted on

AntDB-Oracle Compatibility Developer’s Manual P4–17

Assignment

The function of the assignment statement is to assign the computed expression to the left of the assignment symbol to the variable to the right of the assignment symbol := or to a formal parameter in IN or IN OUT mode.

variable := expression;

The variable argument is the identifier of the declared variable, which can be an OUT, or IN OUT mode formal parameter. The expression argument is an expression that produces a single value. The value generated by the expression must be compatible with the variable's data type.

The dept_salary_rpt example shows the assignment statement at variable declaration time. What is different in this example is the way the assignment statement is used in the procedure execution.

\set PLSQL_MODE on
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;
/
\set PLSQL_MODE off
Enter fullscreen mode Exit fullscreen mode

Top comments (0)