All,
I have the following Package Description:
CREATE OR REPLACE PACKAGE ashish.PKG_Customer AUTHID CURRENT_USER AS
TYPE cursorType IS REF CURSOR;
PROCEDURE CreateCustomerTable;
PROCEDURE SelectCustomers(o_ResultSet OUT cursorType);
END PKG_Customer;
and here is the package body:
CREATE OR REPLACE PACKAGE BODY ashish.PKG_Customer AS
PROCEDURE CreateCustomerTable AS
sQuery VARCHAR2(1000);
BEGIN
sQuery := 'CREATE TABLE tblCustomer2(
CustomerID INTEGER PRIMARY KEY,
FirstName VARCHAR2(50),
LastName VARCHAR2(50),
City VARCHAR2(200),
State_Province VARCHAR2(100),
PostalCode VARCHAR2(25)
)';
EXECUTE IMMEDIATE sQuery;
END CreateCustomerTable;
PROCEDURE SelectCustomers(o_ResultSet OUT cursorType) AS
BEGIN
OPEN o_ResultSet FOR
SELECT CustomerID,
FirstName,
LastName,
City,
State_Province,
PostalCode
FROM tblCustomer;
END SelectCustomers;
END PKG_Customer;
The issue I am facing is that my package will not compile because the table does not currently exist. Surely I should be able to create stored procedures in advance for tables that currently don’t exist in Oracle right? Am I doing something wrong here?
The server version is Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – 64bit.
Thanks!
-Ashish
Not that I’m aware of. How can you compile something against objects that don’t exist? Oracle doesn’t know if you’ve mistyped the table name trying to reference an existing table or are hoping to create the table at a later time.
Why not create your tables first then create/compile your packages?