kulercan
kulercan

Reputation: 15

PL/SQL call to procedure

I wrote a PL/SQL procedure to update the salary of the table Employee

create table Employee
(ID                 VARCHAR2(4 BYTE)         NOT NULL,
First_Name         VARCHAR2(10 BYTE),
   Last_Name          VARCHAR2(10 BYTE),
   Start_Date         DATE,
   End_Date           DATE,
    Salary             Number(8,2),
   City               VARCHAR2(10 BYTE),
    Description        VARCHAR2(15 BYTE)
)
 /

And this is the procedure

CREATE OR REPLACE PROCEDURE update_employee_salary(
   p_factor IN NUMBER
    ) AS
    v_employee_count INTEGER;
    BEGIN
        UPDATE employee
       SET salary = salary * p_factor;
       COMMIT;
    EXCEPTION
     WHEN OTHERS THEN
       ROLLBACK;
   END update_employee_salary;
   /

When I try to call the procedure

CALL update_employee_salary (1.5)

oracle displays ORA-00900: invalid SQL statement

Upvotes: 1

Views: 37220

Answers (3)

mahi_0707
mahi_0707

Reputation: 1062

It is incorrect way of calling procedure. You can use the below method :

    Begin
    update_employee_salary(1.5);
    End;

Read more here : PL/SQL Procedure

Upvotes: 5

SocketM
SocketM

Reputation: 574

You can call a procedure with CALL as you did. The reason for not working could be related to a previous sql statement that hasn't been closed with ;. Moreover a piece of advice: you should not use oracle/plsql reserved words as table column name as you did (id is a reserved word).

Upvotes: 0

Erich Kitzmueller
Erich Kitzmueller

Reputation: 36987

You can also execute it like this, in SQL*PLUS and SQL-Developer:

EXEC update_employee_salary(1.5)

Upvotes: 1

Related Questions