python error PLS-00306: wrong number or types of arguments in

Discussion in 'Python' started by Adeoluwa Odein, Jul 13, 2011.

  1. Hello
    I am using the zxJDBC package with jython (similar to python), and I
    am having "python error PLS-00306: wrong number or types of arguments"
    error when using the "callproc()" method to execute a stored
    procedure.

    The Oracle stored procedure takes a single OUT varchar2 parameter. My
    code is as follows:

    p = [None]
    c.callproc('pkg1_returns', p);

    ....
    What I am doing corresponds to the examples..but I can seem to know
    why it is not working. Help.


    "Adeoluwa"
     
    Adeoluwa Odein, Jul 13, 2011
    #1
    1. Advertising

  2. Adeoluwa Odein

    John Gordon Guest

    In <> Adeoluwa Odein <> writes:

    > Hello
    > I am using the zxJDBC package with jython (similar to python), and I
    > am having "python error PLS-00306: wrong number or types of arguments"
    > error when using the "callproc()" method to execute a stored
    > procedure.


    > The Oracle stored procedure takes a single OUT varchar2 parameter. My
    > code is as follows:


    > p = [None]
    > c.callproc('pkg1_returns', p);


    If the procedure takes a varchar2 parameter, why are you passing [None]?

    It might help if you posted the method signature of the Oracle stored
    procedure you're trying to call.

    --
    John Gordon A is for Amy, who fell down the stairs
    B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"
     
    John Gordon, Jul 13, 2011
    #2
    1. Advertising

  3. Thanks, your assistance will be greatly appreciated on the right way
    forward. See the Stored Procedure Below -very simple:



    create or replace package c2_pkg
    as
    procedure openc;
    procedure closec;
    procedure RS22(v out varchar);
    end;
    /

    create or replace package body c2_pkg
    as
    v_first_time boolean := TRUE;
    v_cursor number;
    cursor srvr_cur
    is
    select distinct b.mid from SVR a,VAR b where a.mid = b.mid;

    procedure openc
    as
    begin
    if not srvr_cur%ISOPEN
    then
    open srvr_cur;
    end if;

    end openc;

    procedure closec
    as
    begin
    close srvr_cur;
    end closec;


    procedure RS22(v out varchar2)
    as
    -- Server varchar2(64);

    begin
    Server := NULL;
    fetch srvr_cur into Server;
    v := Server;

    end RS22;

    end;
    /




















    On Jul 13, 1:40 pm, John Gordon <> wrote:
    > In <> Adeoluwa Odein <> writes:
    >
    > > Hello
    > > I am using the zxJDBC package with jython (similar to python), and I
    > > am having "python error PLS-00306: wrong number or types of arguments"
    > > error when using the "callproc()" method to execute a stored
    > > procedure.




    > > The Oracle stored procedure takes a single OUT varchar2 parameter.  My
    > > code is as follows:
    > > p = [None]
    > > c.callproc('pkg1_returns', p);

    >
    > If the procedure takes a varchar2 parameter, why are you passing [None]?
    >
    > It might help if you posted the method signature of the Oracle stored
    > procedure you're trying to call.
    >
    > --
    > John Gordon                   A is for Amy, who fell down the stairs
    >              B is for Basil, assaulted by bears
    >                                 -- EdwardGorey, "The Gashlycrumb Tinies"
     
    Adeoluwa Odein, Jul 13, 2011
    #3
  4. Adeoluwa Odein

    John Gordon Guest

    In <> Adeoluwa Odein <> writes:

    > Thanks, your assistance will be greatly appreciated on the right way
    > forward. See the Stored Procedure Below -very simple:


    I don't see a procedure named "pkg1_returns", which is the prodecure
    called by your code. Where is this procedure?

    --
    John Gordon A is for Amy, who fell down the stairs
    B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"
     
    John Gordon, Jul 13, 2011
    #4
  5. The actual jython/python call is:

    p = [None]
    c.callproc('c2_pkg.RS22', p);

    I used a placeholder initially; now that you have the SQL code, there
    it is. It essentially invokes the stored procedure, and it should
    return the OUT variable p, with some value. It doesn't have to be a
    cursor fetch; even a minor text assignment.






    On Jul 13, 2:10 pm, John Gordon <> wrote:
    > In <> Adeoluwa Odein <> writes:
    >
    > > Thanks, your assistance will be greatly appreciated on the right way
    > > forward.  See the Stored Procedure Below -very simple:

    >
    > I don't see a procedure named "pkg1_returns", which is the prodecure
    > called by your code.  Where is this procedure?
    >
    > --
    > John Gordon                   A is for Amy, who fell down the stairs
    >              B is for Basil, assaulted by bears
    >                                 -- EdwardGorey, "The Gashlycrumb Tinies"
     
    Adeoluwa Odein, Jul 13, 2011
    #5
  6. Adeoluwa Odein

    John Gordon Guest

    In <> Adeoluwa Odein <> writes:

    > The actual jython/python call is:


    > p =3D [None]
    > c.callproc('c2_pkg.RS22', p);


    > I used a placeholder initially; now that you have the SQL code, there
    > it is. It essentially invokes the stored procedure, and it should
    > return the OUT variable p, with some value. It doesn't have to be a
    > cursor fetch; even a minor text assignment.


    That procedure is defined as taking one parameter, but you're passing
    an empty parameter list. Why?

    --
    John Gordon A is for Amy, who fell down the stairs
    B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"
     
    John Gordon, Jul 13, 2011
    #6
  7. On Jul 13, 2:26 pm, John Gordon <> wrote:
    > In <> Adeoluwa Odein <> writes:
    >
    > > The actual jython/python call is:

    It's taking an OUT parameter.. I'm just following the examples as
    documented by zxJDBC. How can I fix it?




    > > p =3D [None]
    > > c.callproc('c2_pkg.RS22', p);
    > > I used a placeholder initially; now that you have the SQL code, there
    > > it is.  It essentially invokes the stored procedure, and it should
    > > return the OUT variable p, with some value.  It doesn't have to be a
    > > cursor fetch; even a minor text assignment.

    >
    > That procedure is defined as taking one parameter, but you're passing
    > an empty parameter list.  Why?
    >
    > --
    > John Gordon                   A is for Amy, who fell down the stairs
    >              B is for Basil, assaulted by bears
    >                                 -- EdwardGorey, "The Gashlycrumb Tinies"
     
    Adeoluwa Odein, Jul 13, 2011
    #7
  8. On Jul 13, 2:26 pm, John Gordon <> wrote:
    > In <> Adeoluwa Odein <> writes:
    >
    > > The actual jython/python call is:
    > > p =3D [None]
    > > c.callproc('c2_pkg.RS22', p);
    > > I used a placeholder initially; now that you have the SQL code, there
    > > it is.  It essentially invokes the stored procedure, and it should
    > > return the OUT variable p, with some value.  It doesn't have to be a
    > > cursor fetch; even a minor text assignment.

    >
    > That procedure is defined as taking one parameter, but you're passing
    > an empty parameter list.  Why?
    >
    > --
    > John Gordon                   A is for Amy, who fell down the stairs
    >              B is for Basil, assaulted by bears
    >                                 -- EdwardGorey, "The Gashlycrumb Tinies"


    I'm new to jython...
     
    Adeoluwa Odein, Jul 13, 2011
    #8
  9. Adeoluwa Odein

    John Gordon Guest

    > It's taking an OUT parameter.. I'm just following the examples as
    > documented by zxJDBC. How can I fix it?


    I suspect the example you're looking at was for a procedure which has no
    arguments, so in that case it would make sense to pass an empty parameter
    list.

    I haven't worked with OUT parameters so I don't know if this will work,
    but try it and see what happens:

    my_string = ""
    p = [my_string]
    c.callproc('c2_pkg.RS22', p);
    print p

    --
    John Gordon A is for Amy, who fell down the stairs
    B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"
     
    John Gordon, Jul 13, 2011
    #9
  10. On Jul 13, 4:09 pm, John Gordon <> wrote:
    > > It's taking an OUT parameter.. I'm just following the examples as
    > > documented by zxJDBC.  How can I fix it?

    >
    > I suspect the example you're looking at was for a procedure which has no
    > arguments, so in that case it would make sense to pass an empty parameter
    > list.
    >
    > I haven't worked with OUT parameters so I don't know if this will work,
    > but try it and see what happens:
    >
    >   my_string = ""
    >   p = [my_string]
    >   c.callproc('c2_pkg.RS22', p);
    >   print p
    >
    > --
    > John Gordon                   A is for Amy, who fell down the stairs
    >              B is for Basil, assaulted by bears
    >                                 -- EdwardGorey, "The Gashlycrumb Tinies"



    The same error. The sample were found on the following site --I copied
    exactly what is written there:
    1. http://www.jython.org/archive/21/docs/zxjdbc.html
     
    Adeoluwa Odein, Jul 13, 2011
    #10
  11. Adeoluwa Odein

    John Gordon Guest

    In <> Adeoluwa Odein <> writes:

    > The same error. The sample were found on the following site --I copied
    > exactly what is written there:
    > 1. http://www.jython.org/archive/21/docs/zxjdbc.html


    Ah, I see. You're supposed to call c.fetchall() afterwards to retrieve
    the OUT parameter.

    Also, the example page defines the called object as a function, not a
    procedure. Maybe that's the problem? Try defining RS22 as a function
    and see if that helps.

    You might also try defining it outside of a package, as that is how the
    example code does it.

    --
    John Gordon A is for Amy, who fell down the stairs
    B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"
     
    John Gordon, Jul 13, 2011
    #11
  12. On Jul 13, 5:02 pm, John Gordon <> wrote:
    > In <> Adeoluwa Odein <> writes:
    >
    > > The same error. The sample were found on the following site --I copied
    > > exactly what is written there:
    > > 1.http://www.jython.org/archive/21/docs/zxjdbc.html

    >

    if you define the function in the execute() method, it works (as seen
    on the page). But this is a stored procedure already residing on the
    DB. A function/procedure outside of a package, actually works, but
    then you lose access to private data; which is while I used a package.



    > Ah, I see.  You're supposed to call c.fetchall() afterwards to retrieve
    > the OUT parameter.
    >
    > Also, the example page defines the called object as a function, not a
    > procedure.  Maybe that's the problem?  Try defining RS22 as a function
    > and see if that helps.
    >
    > You might also try defining it outside of a package, as that is how the
    > example code does it.
    >
    > --
    > John Gordon                   A is for Amy, who fell down the stairs
    >              B is for Basil, assaulted by bears
    >                                 -- EdwardGorey, "The Gashlycrumb Tinies"
     
    Adeoluwa Odein, Jul 13, 2011
    #12
  13. Adeoluwa Odein

    Terry Reedy Guest

    Terry Reedy, Jul 13, 2011
    #13
  14. Adeoluwa Odein

    John Gordon Guest

    In <> Adeoluwa Odein <> writes:

    > if you define the function in the execute() method, it works (as seen
    > on the page). But this is a stored procedure already residing on the
    > DB. A function/procedure outside of a package, actually works, but
    > then you lose access to private data; which is while I used a package.


    Did you try changing RS22 from a procedure to a function inside the
    package?

    --
    John Gordon A is for Amy, who fell down the stairs
    B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"
     
    John Gordon, Jul 13, 2011
    #14
  15. On Jul 13, 5:19 pm, John Gordon <> wrote:
    > In <> Adeoluwa Odein <> writes:
    >
    > > if you define the function in the execute() method, it works (as seen
    > > on the page).  But this is a stored procedure already residing on the
    > > DB.  A function/procedure outside of a package, actually works, but
    > > then you lose access to private data; which is while I used a package.

    >
    > Did you try changing RS22 from a procedure to a function inside the
    > package?
    >
    > --
    > John Gordon                   A is for Amy, who fell down the stairs
    >              B is for Basil, assaulted by bears
    >                                 -- EdwardGorey, "The Gashlycrumb Tinies"


    Correction, the previous actually works, and still gives me access to
    private data. So I will most likely use it.
    Basically, just call a function, outside a package. It resolves this
    entire dilemma.
    Implementing similar program in Perl DBI, works without any problem.
    Python/Jython seem quite difficult to work with Store Procedures, in
    my opinion. Thanks a lot.
     
    Adeoluwa Odein, Jul 13, 2011
    #15
  16. On Jul 13, 5:19 pm, John Gordon <> wrote:
    > In <> Adeoluwa Odein <> writes:
    >
    > > if you define the function in the execute() method, it works (as seen
    > > on the page).  But this is a stored procedure already residing on the
    > > DB.  A function/procedure outside of a package, actually works, but
    > > then you lose access to private data; which is while I used a package.

    >
    > Did you try changing RS22 from a procedure to a function inside the
    > package?
    >
    > --
    > John Gordon                   A is for Amy, who fell down the stairs
    >              B is for Basil, assaulted by bears
    >                                 -- EdwardGorey, "The Gashlycrumb Tinies"


    The same problem, if done inside a package. I just left it outside a
    package, and it works.
     
    Adeoluwa Odein, Jul 13, 2011
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page