[python-sybase] Problems invoking stored procedures

Dave Cole djc at object-craft.com.au
28 Nov 2002 13:42:01 +1100


> Hello, since we are suning SQL Server 2000 the whole day I'm working
> on some tools that should help us to:
> 
> 1) get quickly all objects as text files in DDL, that can be
> processed by CVS
> 
> 2) export the database schme to DIA.
> 
> 3) eventually help porting the objects to SQL:1999 or PostgreSQL
> 
> Many things work now, but when I try to run a stored procedure,
> sp_helpconstraint, I get a lot of problems.
> 
> The system I'm working on is:
> 
> Server:
>     Windows 2000 SP2
>     SQL Server 2000 SP2
> 
> Client:
>     Debian testing
>     Python 2.1.2 and Python 2.3 pre-packages
>     sybase-3.6pre1
> 
> The problem is included in the 2 attachments. They contain 2
> different invokations of the the stored procedure.

You don't say whether or not you are using FreeTDS.  I also get
segfaults in FreeTDS 0.60 when I try to call stored procedures.  I
have not tried the current CVS version of FreeTDS.  Something to try a
bit later.

> The first test gives me:
> 
> bonobo@bonobo:~/devel/dbweaver$ python spTest.py
> [('DEFAULT on column alrm_time', 'DF_Alarme_Time', '(n/a)',
> '(n/a)', '(n/a)', '(n/a)', '(getdate())'), ('PRIMARY KEY
> (non-clustered)', 'PK_Alarme', '(n/a)', '(n/a)', '(n/a)',
> '(n/a)', 'alrm_id')]
> Traceback (most recent call last):
>   File "spTest.py", line 8, in ?
>     curs.close()
>   File "/usr/lib/python2.1/site-packages/Sybase.py", line
> 350, in close
>     self._close()
>   File "/usr/lib/python2.1/site-packages/Sybase.py", line
> 262, in _close
>     status = self._cmd.ct_cancel(CS_CANCEL_ALL)
>   File "/usr/lib/python2.1/site-packages/Sybase.py", line
> 145, in _servermsg_cb
>     raise DatabaseError(_fmt_server(msg))
> Sybase.DatabaseError: State 1, Procedure sp_helpconstraint,
> Line 276
>  Msg 15470, State 1, Procedure sp_helpconstraint, Line 287
> No foreign keys reference this table.

Is it an error to have the stored procedure error message reported as
an exception?

> The second gives simply:
> 
> bonobo@bonobo:~/devel/dbweaver$ python spTest2.py
> Segmentation fault

This is exactly what I get with FreeTDS.

- Dave

-- 
http://www.object-craft.com.au