My favorites | Sign in
Project Home Downloads Wiki
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 110: Could not find stored procedure
2 people starred this issue and may be notified of changes. Back to list
Status:  Hold
Owner:  ----


 
Reported by min...@gmail.com, Jul 20, 2010
What steps will reproduce the problem?
1. Compile pyodbc 
2. cnxn = pyodbc.connect('DRIVER={FreeTDS};SERVER=%s;DATABASE=DB;UID=%s;PWD=%s' 
	
3. cursor.execute('EXEC STORED_PROCEDURE_NAME')

What is the expected output? What do you see instead?
Resultset of Stored Procedure
I get an error
[42000] [FreeTDS][SQL Server]Could not find stored procedure 'e'. (2812) (SQLExecDirectW)
although the STORED PROCEDURE is not name 'e'

What version of the product are you using? On what operating system?
Ubuntu Lucid
Django 1.2.1
pyodbc 2.1.7

Please provide any additional information below.


Jul 26, 2010
#1 giotis.n...@gmail.com
I can also confirm this.

cnx_string = 'DSN=devsrv;UID=sa;PWD=...;DATABASE=...'
cnx = pyodbc.connect(cnx_string)
args = (int_arg1, int_arg2, int_arg3, string_arg4)
results = cnx.cursor().execute("EXEC stored_proc (%s, %s, %s, '%s') % args).fetchone()

This fails with the same error as above.

I am using the freetds-patched driver from ibiblio.org (date 20 jul 2010)
I tested with pyodbc 2.1.6 and 2.1.7 on sql server 2000 and 2008.
The os is lucid server x86_64


As a workaround, this works (tested with pyodbc 2.1.6, will test also with pyodbc 2.1.7)

cnx = pyodbc.connect(...)
args = (int_arg1, int_arg2, int_arg3, string_arg4.encode("utf-8"))
results = cnx.cursor().execute("{CALL stored_proc(?, ?, ?, ?)}", args).fetchone()

so.. using the odbc call format seems to work
Jul 26, 2010
#2 min...@gmail.com
I tried the ODBC call in 2.1.7, but it reports 
('HY000', 'The driver did not supply an error!')
Jul 26, 2010
#3 giotis.n...@gmail.com
I am using this driver

http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-patched.tgz
Compiled with
./configure
make
make install

This installs the driver in /usr/local/lib, and the configuration is inside /usr/local/etc/freetds.conf

also tested with pyodbc 2.1.7 and it works. I am using a DSN to connect to the db.

Also I got this error (HY000) when I passed the arguments inside the {CALL...} string. Maybe you should try passing the arguments as tuple in execute, like above

arguments = (arg1, arg2)
cur.execute("{CALL stored_proc(?, ?)}", arguments)

What i also noticed is that i need to pass string arguments as string.encode("utf-8")
Nov 21, 2010
Project Member #4 mkleehammer
It sounds like the issue is a character encoding mismatch.  pyodbc 2.x will call the ANSI APIs if you supply an ANSI SQL statement, and it will call the Unicode ones if you provide a Unicode SQL statement.  Per the ODBC specification, the Unicode versions will be passed as SQLWCHAR, which is usually UCS2 encoding.  I am seeing that a lot of drivers think that decoding ANSI as UTF8 is acceptable, but it really isn't

Double check your connection's encoding.


Status: Hold

Powered by Google Project Hosting