Home » SQL & PL/SQL » SQL & PL/SQL » Wrong number or types of arguments error (Oracle 10g on UNIX)
Wrong number or types of arguments error [message #342551] Fri, 22 August 2008 14:45 Go to next message
soham.desai@gmail.com
Messages: 21
Registered: August 2008
Junior Member
Hi

I am facing an error PLS-00306: wrong number or types of arguments in call to 'SPRINTF'. Any help? (Everything in a single file)

I have declared and defined the function sprintf as

CREATE OR REPLACE PACKAGE MyPkg
AS
TYPE arg_list IS TABLE OF VARCHAR2(4000);
FUNCTION sprintf(format IN varchar2, parms IN arg_list)
RETURN varchar2;
END MyPkg;

CREATE OR REPLACE PACKAGE BODY MyPkg
AS
FUNCTION sprintf(format IN varchar2, parms IN arg_list)
RETURN VARCHAR2 IS
ret varchar2(4000);
….
….
END MyPkg;

And using it as

Declare
buff VARCHAR2(4000);
TYPE arg_list IS TABLE OF VARCHAR2(4000);
Begin
buff := MyPkg.sprintf('%10d', arg_list('17'));
DBMS_OUTPUT.PUT_LINE('Buff is ' || buff);
return;

END;
Re: Wrong number or types of arguments error [message #342553 is a reply to message #342551] Fri, 22 August 2008 14:57 Go to previous messageGo to next message
szogu
Messages: 21
Registered: July 2008
Junior Member
You already declared the arg list in your package specification , why are you creating again on anonymous procedure. sprintf fuction has a parameter of arg_list type defined in the package

Regards,
Re: Wrong number or types of arguments error [message #342554 is a reply to message #342553] Fri, 22 August 2008 15:00 Go to previous messageGo to next message
soham.desai@gmail.com
Messages: 21
Registered: August 2008
Junior Member
Thanks.

If I do not declare it, I get an error

PLS-00201: identifier 'ARG_LIST' must be declared

Thanks

Soham
Re: Wrong number or types of arguments error [message #342557 is a reply to message #342554] Fri, 22 August 2008 15:08 Go to previous messageGo to next message
szogu
Messages: 21
Registered: July 2008
Junior Member
Declare it as type of arg_list defined in package, not as a new type.
arg_list MyPkg.arg_list

Regards,
Re: Wrong number or types of arguments error [message #342558 is a reply to message #342551] Fri, 22 August 2008 15:13 Go to previous messageGo to next message
soham.desai@gmail.com
Messages: 21
Registered: August 2008
Junior Member
Noy my calling routine looks like

Declare
buff VARCHAR2(4000);
arg_list MyPkg.arg_list;
Begin
buff := MyPkg.sprintf('%10d', arg_list(17));
DBMS_OUTPUT.PUT_LINE('Buff is ' || buff);
return;

END;

(I am declaring arg_list as told by you and changed '17' to 17.

But still getting the same error.

Thanks

Re: Wrong number or types of arguments error [message #342560 is a reply to message #342558] Fri, 22 August 2008 15:23 Go to previous messageGo to next message
szogu
Messages: 21
Registered: July 2008
Junior Member
Please read here
http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/05_colls.htm#19661
Re: Wrong number or types of arguments error [message #342562 is a reply to message #342551] Fri, 22 August 2008 15:41 Go to previous message
soham.desai@gmail.com
Messages: 21
Registered: August 2008
Junior Member
The following code worked

Declare
buff VARCHAR2(4000);
arg MyPkg.arg_list;
Begin
arg := MyPkg.arg_list(17);
buff := MyPkg.sprintf('%-010d', arg);
DBMS_OUTPUT.PUT_LINE(buff);
return;

END;

Thanks
Previous Topic: Using Bulkinsert
Next Topic: Job scheduler - SQL Error ORA-06550
Goto Forum:
  


Current Time: Thu Dec 08 21:52:51 CST 2016

Total time taken to generate the page: 0.06966 seconds