[python-sybase] newbie problem

Laurent VASSEUR vasseur at titus.u-strasbg.fr
Tue, 14 Jan 2003 09:43:50 +0100


hi,

I've just installed the Sybase module on solaris 2.7 / python 2.2. I tried=
=20
the following program to test it, but it fails...

#!/bin/env python
import Sybase
Sybase._ctx.debug =3D 1
import sys

db=3DSybase.connect('DB','USR', 'PWD', database=3D'test')
c=3Ddb.cursor()

db.begin()
c.callproc('sp_help')
db.commit()

c.close ()
db.close ()
sys.exit()

I get the following output :

ct_con_alloc(ctx0, &conn) -> CS_SUCCEED, conn0
ct_con_props(conn0, CS_SET, CS_USERNAME, "USR", CS_NULLTERM, NULL) ->=20
CS_SUCCEED
ct_con_props(conn0, CS_SET, CS_PASSWORD, "PWD", CS_NULLTERM, NULL) ->=20
CS_SUCCEED
servermsg_cb
ct_connect(conn0, "DB", CS_NULLTERM) -> CS_SUCCEED
ct_options(conn0, CS_SET, CS_OPT_CHAINXACTS, 1, CS_UNUSED, NULL) ->=
 CS_SUCCEED
ct_cmd_alloc(conn0, &cmd) -> CS_SUCCEED, cmd0
ct_command(cmd0, CS_LANG_CMD, "use test", CS_NULLTERM, CS_UNUSED) ->=
 CS_SUCCEED
ct_send(cmd0) -> CS_SUCCEED
servermsg_cb
ct_results(cmd0, &result) -> CS_SUCCEED, CS_CMD_SUCCEED
ct_results(cmd0, &result) -> CS_SUCCEED, CS_CMD_DONE
ct_results(cmd0, &result) -> CS_END_RESULTS, CS_FALSE
ct_cmd_drop(cmd0) -> CS_SUCCEED
ct_cmd_alloc(conn0, &cmd) -> CS_SUCCEED, cmd1
ct_cmd_alloc(conn0, &cmd) -> CS_SUCCEED, cmd2
ct_command(cmd2, CS_LANG_CMD, "begin transaction", CS_NULLTERM, CS_UNUSED)=
=20
-> CS_SUCCEED
ct_send(cmd2) -> CS_SUCCEED
ct_results(cmd2, &result) -> CS_SUCCEED, CS_CMD_SUCCEED
ct_results(cmd2, &result) -> CS_SUCCEED, CS_CMD_DONE
ct_results(cmd2, &result) -> CS_END_RESULTS, CS_FALSE
ct_cmd_drop(cmd2) -> CS_SUCCEED
ct_command(cmd1, CS_RPC_CMD, "sp_help", CS_NULLTERM, CS_UNUSED) ->=
 CS_SUCCEED
ct_send(cmd1) -> CS_SUCCEED
ct_results(cmd1, &result) -> CS_SUCCEED, CS_ROW_RESULT
ct_res_info(cmd1, CS_NUMDATA, &value, CS_UNUSED, NULL) -> CS_SUCCEED, 3
ct_describe(cmd1, 1, &fmt) -> CS_SUCCEED, datafmt0=3D[name:"Name"=20
type:CS_CHAR_TYPE status:CS_UPDATABLE format:CS_FMT_UNUSED count:0=20
maxlength:30]
ct_bind(cmd1, 1, &datafmt0->fmt=3D[name:"Name" type:CS_CHAR_TYPE=20
status:CS_UPDATABLE format:CS_FMT_UNUSED count:1 maxlength:30],=20
databuf0->buff, databuf0->copied, databuf0->indicator) -> CS_SUCCEED,=
 databuf0
ct_describe(cmd1, 2, &fmt) -> CS_SUCCEED, datafmt1=3D[name:"Owner"=20
type:CS_CHAR_TYPE status:48 format:CS_FMT_UNUSED count:0 maxlength:30]
ct_bind(cmd1, 2, &datafmt1->fmt=3D[name:"Owner" type:CS_CHAR_TYPE status:48=
=20
format:CS_FMT_UNUSED count:1 maxlength:30], databuf1->buff,=20
databuf1->copied, databuf1->indicator) -> CS_SUCCEED, databuf1
ct_describe(cmd1, 3, &fmt) -> CS_SUCCEED, datafmt2=3D[name:"Object_type"=20
type:CS_CHAR_TYPE status:48 format:CS_FMT_UNUSED count:0 maxlength:22]
ct_bind(cmd1, 3, &datafmt2->fmt=3D[name:"Object_type" type:CS_CHAR_TYPE=20
status:48 format:CS_FMT_UNUSED count:1 maxlength:22], databuf2->buff,=20
databuf2->copied, databuf2->indicator) -> CS_SUCCEED, databuf2
ct_cmd_alloc(conn0, &cmd) -> CS_SUCCEED, cmd3
ct_command(cmd3, CS_LANG_CMD, "commit transaction", CS_NULLTERM, CS_UNUSED)=
=20
-> CS_SUCCEED
clientmsg_cb
ct_send(cmd3) -> CS_FAIL
Traceback (most recent call last):
   File "t.py", line 11, in ?
     db.commit()
   File "/usr/local/lib/python2.2/site-packages/Sybase.py", line 696, in=
 commit
     self.execute('commit transaction')
   File "/usr/local/lib/python2.2/site-packages/Sybase.py", line 724, in=20
execute
     status =3D cmd.ct_send()
   File "/usr/local/lib/python2.2/site-packages/Sybase.py", line 141, in=20
_clientmsg_cb
     raise DatabaseError(_fmt_client(msg))
Sybase.DatabaseError: Layer: 1, Origin: 1
ct_send(): couche api utilisateur: erreur externe: Impossible d'appeler=20
cette routine car une autre structure de commande est en attente de=
 r=E9sultats.
clientmsg_cb
ct_cmd_drop(cmd3) -> CS_FAIL
ct_cancel(conn0, NULL, CS_CANCEL_ALL) -> CS_SUCCEED
ct_cmd_drop(cmd1) -> CS_SUCCEED
ct_con_props(conn0, CS_GET, CS_CON_STATUS, &value, CS_UNUSED, NULL) ->=20
CS_SUCCEED, CS_CONSTAT_CONNECTED
ct_close(conn0, CS_FORCE_CLOSE) -> CS_SUCCEED
ct_con_drop(conn0) -> CS_SUCCEED


The error in english is : "user api layer: external error: This routine=20
cannot be called because another command structure has results pending."
I have the same pb if I perform an insert + select in the same transaction.=
=20
Any idea on what is going wrong ?

Note : in order to compile the module, I had to add the library "itl" to=20
EXTRA_LIBS. My installation was done whith :
"python setup.py build_ext -U WANT_BULKCOPY"


Thanks,
Laurent