473,395 Members | 2,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Package Execution and Error PLS-00306

37
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
Mar 21 '07 #1
2 6143
Dave44
153 100+
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
Hi Mivey4,

1. Well the reason for the error is that your compiled procedure column_view has an out parameter of type ref cursor. that means whatever is calling this procedure will have to accept that datatype and do whatever it needs to do with it.

Its no different than any programming language, the API for the call says the calling method or procedure must accept a parameter or this type and direction.

2. as for is it the right approach... only you can answer that. you are trying to display the name column from the table, is it for a report or is it part of a larger process being performed.

for most procedures, yes, you will call them from a block named or anonymous.

so you would need to have a block with the same datatype then call
objdata.column_view(my_param_of_same_typ);

then open the results cursor and do what you need to do with it.

Is this helping?
Mar 22 '07 #2
mivey4
37
Hi Mivey4,

1. Well the reason for the error is that your compiled procedure column_view has an out parameter of type ref cursor. that means whatever is calling this procedure will have to accept that datatype and do whatever it needs to do with it.

Its no different than any programming language, the API for the call says the calling method or procedure must accept a parameter or this type and direction.

2. as for is it the right approach... only you can answer that. you are trying to display the name column from the table, is it for a report or is it part of a larger process being performed.

for most procedures, yes, you will call them from a block named or anonymous.

so you would need to have a block with the same datatype then call
objdata.column_view(my_param_of_same_typ);

then open the results cursor and do what you need to do with it.

Is this helping?
Dave44,

Yes, actually this helped a lot. For some reason all the documentation I've read led me to think that the requirement of an argument at the time of execution was directly related to the specifications of the argument list at the time the procedure was created for Oracle Stored Procedures.

So with this mindset, parameters specifying the keyword IN required an argument and OUT parameters didn't. That's what had me confused wondering why the error was getting thrown.

If I were calling a function, I'd immediately recognize the need for an argument if it required one but unlike the procedures, if a function doesn't require a passing argument it wouldn't complain if one weren't provided one at execution time.

Like -

CREATE OR REPLACE FUNCTION myFunction
RETURN varchar2
AS
myReturn varchar2(25);
BEGIN
myReturn:='Hello World';
RETURN myReturn;
END;
/

Could be executed as

select myFunction Value from dual;

VALUE
--------------
Hello World


Your explanation and more specifically your use of the keyword API started me viewing the problem from a different angle. In other words, if I were to write a program using the windows API; a call to most any of those structures would require a provided datatype to store the returned results back to the caller, even if the variable wasn't assigned any value initially.

Using this concept I declared a variable to pass to the procedure to return the results as you suggested:

var myReturn refcursor;
objdata.column_view(myReturn);

print myReturn;

NAME
------
HDV203
HFE230
JHN334
JHN500
JMV500
JMV500
MIV203
MIV334
MVE230

This is good. Now that I understand the concept a bit more clearly and believe I can put the remaining parts of my puzzle together.

Thanks for your assistance Dave44!
Mar 22 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Per Magnus L?vold | last post by:
Hi, I am trying to create a package under the apps schema, and I keep getting PLS-00201 and ORA-00942 when refering to types from other apps-packages and other views / tables. I even get this...
4
by: chris.dunigan | last post by:
I'm looking for an example of how to execute an existing DTS­ package from an ASP (VB)script and would appreciate any and all response. ­I don't even know if it's possible Thanks - Chuck...
2
by: Gopal Krish | last post by:
Folks, My ASPX page uses a custom user control. What happens here is that when a runtime error occurs in the ASPX page, the error is caught in the error handler and then strangely, the execution...
6
by: Page Horton | last post by:
I have a ASP.NET (VB) web application running. The DTS package is suppose to generates a flat file to a file path (aka: \\myStation\outputFiles\). When it runs it generates the following error on...
7
by: anilcool | last post by:
Hi all. I am running a stored procedure in a loop -- this Stored procedure inserts one record at a time. After inserting about 1326 records, my thread crashes and I get the following error:...
1
by: Al-Pacino | last post by:
Hello All, I am am having a strange problem. I am trying to execute a DTS package from VB .NET (.aspx) page. The DTS package takes 21 minutes to execute. When the aspx page sends a command to...
2
by: ssrirao | last post by:
Hi, We have DTS package which imports data from an Excel file into an SQL Server 2000 table. The DTS package runs fine when exectued from SQL Server Enterprise Manager, but when we run the...
0
by: shark | last post by:
Hi All, i am getting the error as posted below while executing Transfer logins using Dts package - sql server 2000 standard edition Can any body help? Microsoft Windows (C) Copyright...
0
by: debug03 | last post by:
I am executing a DTS package on a Windows 2000 sp4 server running SQL Server 2000 and IBM DB2 V7 client. The DTS package source data(SQL Server) is selected from SQL server table and inserts data to...
0
debasisdas
by: debasisdas | last post by:
The following thread contains some useful tips/sample codes regarding PACKAGES in oracle, that the forum members may find useful. A package is a collection of procedures,functions,cursors,global...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.