2 Replies Latest reply on May 25, 2016 6:44 AM by S Paul RJ

    Wrong number or types of arguments in call to

    Vinod Kumar G M

      Hi ,

      I have created a procedure inside a package, which takes pl/sql table as the input data type .

      When i try to execute from the anonymous block getting the wrong number or types of arguments in cal to error.

       

      Below is the anonymous block:

       

      DECLARE

         TYPE a_wnl_worstcaseestimate IS TABLE OF tbl.worstestimate%TYPE

                                            INDEX BY PLS_INTEGER;

         l_wnl_worstcaseestimate   a_wnl_worstcaseestimate;

      BEGIN

         FOR i IN 1 .. 10

         LOOP

            l_wnl_worstcaseestimate := i;

         END LOOP;

         test_1.prc (i_wnl_worstcaseestimate => l_wnl_worstcaseestimate);

      END;

         test_1.prc (i_wnl_worstcaseestimate => l_wnl_worstcaseestimate);

      END;

       

      Package specification:

      create or replace package test_1

      as

      TYPE a_wnl_worstcaseestimate IS TABLE OF tbl.worstestimate%TYPE

                                            INDEX BY PLS_INTEGER;

      procedure prc( i_wnl_worstcaseestimate in a_wnl_worstcaseestimate) ;

      end test_1;

       

       

      package body:

      create or replace package body test_1

      as

      procedure prc( i_wnl_worstcaseestimate in a_wnl_worstcaseestimate) 

      is

      begin

          for i in i_wnl_worstcaseestimate.first..i_wnl_worstcaseestimate.last loop

          dbms_output.put_line(i_wnl_worstcaseestimate(i));

          end loop;

      end prc;

      end test_1;

        • 1. Re: Wrong number or types of arguments in call to

          I don't see how that has ANYTHING to do with sql developer.

           

          This forum is ONLY for sql developer questions/issues so unless you can connect your problem with sql developer please mark the thread ANSWERED and repost it in the SQL and PL/SQL forum

          SQL & PL/SQL

          When i try to execute from the anonymous block getting the wrong number or types of arguments in cal to error.

          Correct - that message is telling you EXACTLY what the problem is.

           

          Your package declares a collection of type 'a_wnl_worstcaseestimate' and your package procedure REQUIRES you to pass an instance of that type.

           

          Instead you are passing an instance of a DIFFERENT type instead of passing the package type. The anonymous block is defining it's own type and is giving it the same name. But just because it has the same name doesn't mean it is the same type.

           

          Those two type definitions have DIFFERENT scope. The scope of one is the package and it is ONLY available within the package. So you need to call the procedure using an instance of the type that is declared in the package. You can do that by specifying the package name just like you would specify a schema name:  myPackage.myTypeName

           

          If you need more help repost in the proper forum.

          • 2. Re: Wrong number or types of arguments in call to
            S Paul RJ

            Hi vinod,

             

                                There is no need to declare the type again in anonymous block.

                                Try this,

             

                                DECLARE

                                   l_wnl_worstcaseestimate   test_1.a_wnl_worstcaseestimate;

                                BEGIN

                                   FOR i IN 1 .. 10

                                   LOOP

                                      l_wnl_worstcaseestimate(i) := i;

                                   END LOOP;

                                   test_1.prc (i_wnl_worstcaseestimate => l_wnl_worstcaseestimate);

                                END;

             

                                --Package specification:

                                create or replace package test_1

                                as

                                TYPE a_wnl_worstcaseestimate IS TABLE OF tbl.worstestimate%TYPE

                                                                                                                   INDEX BY PLS_INTEGER;

                                procedure prc( i_wnl_worstcaseestimate in a_wnl_worstcaseestimate) ;

                                end test_1;

             

                                --package body:

                                create or replace package body test_1

                                as

                                procedure prc( i_wnl_worstcaseestimate in a_wnl_worstcaseestimate)

                                is

                                begin

                                    for i in i_wnl_worstcaseestimate.first..i_wnl_worstcaseestimate.last loop

                                         dbms_output.put_line(i_wnl_worstcaseestimate(i));

                                    end loop;

                                end prc;

                                end test_1;

             

            Regards,

            S Paul RJ