I am trying to lay the foundation for a package but am having trouble even getting started. I have successfully created a basic package spec and want to just test the package body but I’m having trouble getting it to compile. The spec code is:
CREATE OR REPLACE PACKAGE synchronize_my_data
AS
PROCEDURE synchronize_data(p_run_date IN date);
END synchronize_my_data;
and here is the package body code:
CREATE OR REPLACE PACKAGE BODY synchronize_my_data
IS
PROCEDURE synchronize_data(p_run_date IN date) IS
PROCEDURE process_deletes(p_run_date IN date) IS
BEGIN
dbms_output.put_line('Run Date: ' || to_char(p_run_date, 'MM/DD/YYYY'));
END process_deletes;
BEGIN
process_deletes(p_run_date);
END synchronize_data;
END synchronize_my_data;
I keep getting a compilation error but can’t figure out what’s wrong with the code. It seems like basic code, am I just missing something obvious?
That code seems to compile for me. What error are you getting?
From a general stylistic standpoint, it generally makes very little sense to define a procedure within another procedure in a package body. One of the benefits of using packages is that you can have both public and private procedures. You can create the
process_deletesprocedure as a private procedure simply by defining it in the body without defining it in the spec.That shouldn’t have anything to do with whatever error you’re getting. But it should make your code easier to deal with.