Jython zxJDBC / Python cx_oracle wrong number or types of arguments when calling to oracle's stored procedure

187 views
Skip to first unread message

Akira Kir

unread,
Dec 21, 2011, 12:41:53 AM12/21/11
to django...@googlegroups.com

Trying to make a django test application which will use stored oracle's procedures to insert/get data.

Using jython with zxJDBC but same error applies with python and cx_oracle too.

here is some code snipets:

models.py

from django.db import models
from django.db import connection

class ALEX_TEST_PKG
():
    def get_data
(self, inparam1):
       
cursor = connection.cursor()
        ret
= cursor.callproc("ALEX_TEST_PKG.test0", inparam1)
       
cursor.close
       
return ret

views.py

class TestForm(forms.Form):
    inparam1
= forms.IntegerField()


def message
(request):
   
if request.method == 'POST':
        form
= TestForm(request.POST)
   
else:
        form
= TestForm()
   
if form.is_valid():
        my_util
= ALEX_TEST_PKG()
        ret
= my_util.get_data(request.POST['inparam1'])
       
return HttpResponse(ret)
   
return render_to_response('form.html', {'form':form}, context_instance=RequestContext(request))


oracle's procedures:

CREATE OR REPLACE PACKAGE BODY ALEX.alex_test_pkg
IS
   
PROCEDURE test0 (inparam1 IN integer)
   
IS
   
BEGIN
     
insert into alex_debug(col1) values(inparam1);
   
END test0;
END alex_test_pkg;
/


Django error log:

Environment:


Request Method
: POST
Request URL
: http://localhost:8000/form/

Django Version
: 1.3.1
Python Version
: 2.7.0
Installed Applications
:
['django.contrib.auth',
 
'django.contrib.contenttypes',
 
'django.contrib.sessions',
 
'django.contrib.sites',
 
'django.contrib.messages',
 
'django.contrib.staticfiles',
 
'django.contrib.admin',
 
'dbtest']
Installed Middleware
:
('django.middleware.common.CommonMiddleware',
 
'django.contrib.sessions.middleware.SessionMiddleware',
 
'django.middleware.csrf.CsrfViewMiddleware',
 
'django.contrib.auth.middleware.AuthenticationMiddleware',
 
'django.contrib.messages.middleware.MessageMiddleware')


Traceback
:
File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\core\handlers\base.py" in get_response
 
111.                         response = callback(request, *callback_args, **callback_kwargs)
File "E:\WatchTower\workspace3\erwtwe\erwtwe\dbtest\views.py" in message
 
19.         ret = my_util.get_data(request.POST['inparam1'])
}File "E:\WatchTower\workspace3\erwtwe\erwtwe\dbtest\models.py" in get_data
 
7.         ret = cursor.callproc("ALEX_TEST_PKG.test0", inparam1)

Exception Type
: DatabaseError at /form/
Exception Value
: ORA-06550: line 1, column 7:
PLS-00306
: wrong number or types of arguments in call to 'TEST0'
ORA-06550
: line 1, column 7:
PL
/SQL: Statement ignore

 
Any help is appriciated. breaking my head with this for 4 days already.

{stackoverflow xposted}

Daniel Roseman

unread,
Dec 21, 2011, 6:49:10 AM12/21/11
to django...@googlegroups.com
On Wednesday, 21 December 2011 05:41:53 UTC, Akira Kir wrote:

<snip>

{stackoverflow xposted}

Answered on SO.
--
DR. 

Python_Junkie

unread,
Dec 22, 2011, 11:21:25 PM12/22/11
to Django users
I presume that the stored procedure has been created.

I use the python module pyodbc. Google has good documentation how to
set this up.

then after creating the connection you can execute the stored
procedure

4 lines of code will then create the crsr followed by the execution

crsr.execute('stored_procedure')
Reply all
Reply to author
Forward
0 new messages