0

I want to create a procedure without parameters (In SQL DEVELOPER) but I am not sure how to do it, I have tried it in the following way and it sends me an error in "Num1 NUMBER";

create or replace package PK_MAC as
      PROCEDURE PR_PRUEBAS 
      IS
      Num1 NUMBER;
      BEGIN
      Num1 := 2;
      end;
  end;
  • Does this answer your question? [SQL Server: Query fast, but slow from procedure](https://stackoverflow.com/questions/440944/sql-server-query-fast-but-slow-from-procedure) – Vendetta Feb 04 '20 at 18:56

1 Answers1

4

You're trying to create a procedure or a package, with a procedure?

Here is a working example of what you're doing, as a package.

Your package will have two parts, a SPEC and a BODY.

The SPEC will publicly share the definition of the procedure and the variable, NUM1.

The BODY will define what the procedure actually does. Since NUM1 is defined already in the context of the package in the spec, I can use it in my procedure in the body.

create or replace package PK_MAC as
      num1 integer;
      PROCEDURE PR_PRUEBAS; 

  end;
/

create or replace package body PK_MAC IS
 procedure pr_pruebas is
  BEGIN
      Num1 := 2;
  end pr_pruebas;
end PK_MAC;
/
thatjeffsmith
  • 20,522
  • 6
  • 37
  • 120
  • A Package with procedure. – Myke Andres Feb 04 '20 at 18:41
  • @MykeAndres ok, so here's what you'd start with. figure out what you want your API to look like, and build out the SPEC first. Then start going through the implementation of the body. You'll need to make changes to your SPEC, as you do this, you'll have to re-compile the body - if you don't, you'll see the body is INVALID. – thatjeffsmith Feb 04 '20 at 18:43