Hi,
I am not new to Oracle but I am new to creating packages.
Trying to convert to Oracle from MSSQL and getting my feet wet I have created the following package that has 1 procedure in it. No problems compiling.
CREATE OR REPLACE PACKAGE dataObj
AS
TYPE CURSOR_TYPE IS REF CURSOR;
PROCEDURE column_view (results_cursor OUT CURSOR_TYPE);
END;
/
package created.
CREATE OR REPLACE PACKAGE BODY dataObj
AS
PROCEDURE column_view (results_cursor OUT CURSOR_TYPE)
AS
BEGIN
OPEN results_cursor FOR
SELECT NAME FROM STRINGS
ORDER BY NAME;
END;
END;
/
package created.
This is a very simple package that I am trying to get to work so I can build on the concept from here.
Now I know this is going to sound like really dumb for someone more familiar with this, but a couple of questions:
1. Can the procedure in the package only be called within a block statement?
e.g.
BEGIN
dataObj.column_view;
END;
/
Cuz I don't seem to have any luck attempting something like:
EXEC <packageName>.<packageFunctionOrProcedure>
2. Am I taking the right approach for creating a procedure that will encapsulate and output the results of a select statement from a Cursor? I don't seem to have a problem creating procedures that are performing an INSERT, DELETE, or UPDATE but when I want to return a result set from a SELECT statement things tend to get a bit sticky. Oracle and MSSQL seem to differ a lot in this respect.
In either case I always get this error when I try to execute though I have clearly specified that no arguments are to be taken:
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'COLUMN_VIEW'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
I understand the error but don't understand where its coming from in this case.
Any help is appreciated.
Thanks