Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute an oracle stored procedure?

I am using oracle 10g express edition. It has a nice ui for db developers. But i am facing some problems executing stored procedures.

Procedure:

create or replace procedure temp_proc is begin   DBMS_OUTPUT.PUT_LINE('Test'); end 

it is created successfully. But when i execute:

execute temp_proc;

it shows ORA-00900: invalid SQL statement

So help needed here

like image 727
Rahbee Alvee Avatar asked Dec 06 '09 05:12

Rahbee Alvee


People also ask

How do I execute a stored procedure?

In Object Explorer, connect to an instance of the SQL Server Database Engine, expand that instance, and then expand Databases. Expand the database that you want, expand Programmability, and then expand Stored Procedures. Right-click the user-defined stored procedure that you want and select Execute Stored Procedure.

How do I run a procedure in SQLPlus?

To run a stored procedure in SQLPlus the command is something like this. SQL> EXECUTE procedure_name('passed_value');

Can you execute a stored procedure in the database?

A stored procedure is a prepared SQL code that you can save, so the code can be reused over and over again. So if you have an SQL query that you write over and over again, save it as a stored procedure, and then just call it to execute it.


2 Answers

Execute is sql*plus syntax .. try wrapping your call in begin .. end like this:

begin      temp_proc; end; 

(Although Jeffrey says this doesn't work in APEX .. but you're trying to get this to run in SQLDeveloper .. try the 'Run' menu there.)

like image 96
Thorsten Avatar answered Sep 20 '22 11:09

Thorsten


Oracle 10g Express Edition ships with Oracle Application Express (Apex) built-in. You're running this in its SQL Commands window, which doesn't support SQL*Plus syntax.

That doesn't matter, because (as you have discovered) the BEGIN...END syntax does work in Apex.

like image 28
Jeffrey Kemp Avatar answered Sep 19 '22 11:09

Jeffrey Kemp