[python-sybase] Problems invoking stored procedures

hopfgartner hopfgartner at rolmail.net
Thu, 28 Nov 2002 08:18:25 +0100


On 28 Nov 2002 13:42:01 +1100
 Dave Cole <djc@object-craft.com.au> wrote:
> 
> > 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.
> 
Sorry, I've forgot to mention it. Indeed, I'm using FreeTDS
0.6. 

> > 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?
> 
This should not be an error from the SQL server, but I will
look closer to it. This is simply a message telling that
there are no FK referencing this table. When running from
Query Analyser, this message appears in the 'Messages' tab,
wheras results are in the 'Grid' tab.

Anyway, I've tryed it with a table that has FK-constraints,
and what I get is the following:

bonobo@bonobo:~/devel/dbweaver$ python spTest.py
[('DEFAULT on column PAPOS', 'DF_positionen_PAPOS',
'(n/a)', '(n/a)', '(n/a)', '(n/a)', '(0)'), ('DEFAULT on
column PARTI', 'DF_positionen_PARTI', '(n/a)', '(n/a)',
'(n/a)', '(n/a)', "(' ')"), ('DEFAULT on column
pos_menge_ist', 'DF_positionen_pos_menge_ist', '(n/a)',
'(n/a)', '(n/a)', '(n/a)', '(0)'), ('DEFAULT on column
pos_status', 'DF_positionen_pos_status', '(n/a)', '(n/a)',
'(n/a)', '(n/a)', '(30)'), ('FOREIGN KEY',
'FK_positionen_personal', 'No Action', 'No Action',
'Enabled', 'Is_For_Replication', 'pers_id'), (' ', ' ', '
', ' ', ' ', ' ', 'REFERENCES lager01_sap.dbo.personal
(pers_id)'), ('FOREIGN KEY',
'FK_positionen_transport_auftraege', 'No Action', 'No
Action', 'Enabled', 'Is_For_Replication', 'taft_id'), (' ',
' ', ' ', ' ', ' ', ' ', 'REFERENCES
lager01_sap.dbo.transport_auftraege (taft_id)'), ('PRIMARY
KEY (clustered)', 'PK_Positionen', '(n/a)', '(n/a)',
'(n/a)', '(n/a)', 'pos_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
 
The same stored procedure does not give any error messages
when run from Query Analyser.

> > 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
> 

Let me know if I can help in the diagnosis. 

Peter