Oracle uses a package specification and package body. Effectively, the specification defines all of the procedures/functions/variables/etc that you want to be accessible by other areas of code (for example, another package). The body then contains definitions of other procedures and functions that are "private" and also the logic behind the definitions in your package specification.
The example that you have provided above would go as follows:
CREATE OR REPLACE PACKAGE XX_EXAMPLE_PACKAGE AS
-- Variable that is visible to any code
n_visible_outside NUMBER := 1;
-- Procedure that is visible to any code
PROCEDURE p_visible_outside ( );
END XX_PACKAGE_SPECIFICATION;
/
CREATE OR REPLACE PACKAGE BODY XX_EXAMPLE_PACKAGE AS
-- A variable that is visible to the whole package body but not
-- to external code
v_dummy VARCHAR2(100);
-- Procedure visible to any code through the specification
PROCEDURE p_visible_outside AS
-- declaring a variable that is only visible to this procedure
n_not_visible_outside NUMBER := 14922016;
BEGIN
-- Logic
END p_visible_outside;
-- Function not visible outside as not declared in specification
-- can be accessed by code within this package
FUNCTION f_not_visible_outside RETURN BOOLEAN IS
--Logic
END f_not_visible_outside;
END;
/
You could then call the "visible" procedure in this way from another package:
XX_EXAMPLE_PACKAGE.p_visible_outside;
And, likewise, you can call the "visible" global variable in this way from another package:
-- You could use this in your code as say, a parameter
XX_EXAMPLE_PACKAGE.n_visible_outside;
-- You could assign the value to another variable in your code
v_dummy := XX_EXAMPLE_PACKAGE.n_visible_outside;
As a beginner it isn't as important to follow development standards, however, in the future you should. Hopefully, you have some local development standards however, you could probably find some Oracle PL/SQL standards somewhere on google.
CREATEstatement. - Chris Hep