Pablo
Pablo

Reputation: 29519

How to execute procedure in APEX SQL script?

I am trying to understand how to use multiple procedures in APEX SQL script. First I don't really need stored procedure, but not sure how to declare simple procedure in APEX SQL script. So this is my attempt:

create or replace procedure test1 as
begin
    DBMS_OUTPUT.ENABLE;
    dbms_output.put_line('test1');
end;

execute test1;

This gives me an error:

Error at line 7: PLS-00103: Encountered the symbol "EXECUTE"    

So questions - how to create regular/not stored/ procedures in one SQL script and then call them. What is the entry point of execution in APEX SQL script?

Upvotes: 1

Views: 8795

Answers (1)

Dmitriy
Dmitriy

Reputation: 5565

UPD (At the first time I understood question totally wrong)

Correct version of a script:

create or replace procedure test1 as
begin
    DBMS_OUTPUT.ENABLE;
    dbms_output.put_line('test1');
end;
/
begin
  test1;
end;
/

Documentation says, that script can contain inly SQL and PL/SQL commands. Commands of sqlplus will be ignored.

OLD VERSION (Let stay here)

In APEX pages you can use PL/SQL anonymous blocks. For example, you can create process (APEX has some types of them) or PL/SQL region, and use following:

declare
   ...
begin
   some_proc(:P_MY_ITEM);
end;

Here you can invoke any procedure and do anything else that allowed by PL/SQL. Also you can use parameters like :P_ITEM_NAME to get and set values of page and application items.

Upvotes: 1

Related Questions