Pass parameters using named and mixed notation.

In named notation, you include the name of the parameter when calling a procedure.


CREATE TABLE EMP (EMPNO NUMBER(4) NOT NULL,
                  ENAME VARCHAR2(10),
                  JOB VARCHAR2(9),
                  SAL NUMBER(7, 2),
                  DEPTNO NUMBER(2));

INSERT INTO EMP VALUES (1, 'SMITH', 'CLERK',     800,    20);
INSERT INTO EMP VALUES (2, 'ALLEN', 'SALESMAN', 1600,    30);
INSERT INTO EMP VALUES (3, 'WARD',  'SALESMAN', 1250,    30);
INSERT INTO EMP VALUES (4, 'JONES', 'MANAGER',  2975,    20);

SQL> CREATE PROCEDURE update_salary(p_id IN emp.empno%TYPE,p_factor IN NUMBER) AS
  2     v_count INTEGER;
  3  BEGIN
  4     SELECT COUNT(*) INTO v_count FROM emp WHERE empno = p_id;
  5
  6     IF v_count = 1 THEN
  7        UPDATE emp SET sal = sal * p_factor WHERE empno = p_id;
  8        COMMIT;
  9     END IF;
 10  EXCEPTION
 11  WHEN OTHERS THEN
 12   ROLLBACK;
 13  END update_salary;
 14  /

Procedure created.

SQL>

CALL update_salary (p_factor => 1.3, p_id => 2);

In mixed notation, you use both positional and named notation.


CALL update_salary(3, p_factor => 1.7);
Home »
Oracle »
PL/SQL » 

Procedures:
  1. Creating a Procedure
  2. Pass parameters using named and mixed notation.
  3. Information on Procedures
  4. Dropping a Procedure
  5. Viewing Errors in a Procedure
Related: