From: Laurent V. <va...@ti...> - 2003-01-15 10:03:02
|
Ok, it solved the problem. Thanks Laurent A 16:49 14/01/2003 +0200, vous avez =E9crit : >Hi, > >You need to close the cursor before you can commit your work: > >db.begin() >c=3Ddb.cursor() >c.callproc('sp_help') >c.close() >db.commit() > >works for me. > >Have fun, > Shai. > >-----Original Message----- >From: Laurent VASSEUR [mailto:va...@ti...] >Sent: Tuesday, January 14, 2003 10:44 >To: pyt...@ob... >Subject: [python-sybase] newbie problem > > >hi, > >I've just installed the Sybase module on solaris 2.7 / python 2.2. I tried >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,= =20 >CS_USERNAME, "USR", CS_NULLTERM, NULL) -> >CS_SUCCEED >ct_con_props(conn0, CS_SET, CS_PASSWORD, "PWD", CS_NULLTERM, NULL) -> >CS_SUCCEED >servermsg_cb >ct_connect(conn0, "DB", CS_NULLTERM) -> CS_SUCCEED ct_options(conn0,=20 >CS_SET, CS_OPT_CHAINXACTS, 1, CS_UNUSED, NULL) -> CS_SUCCEED=20 >ct_cmd_alloc(conn0, &cmd) -> CS_SUCCEED, cmd0 ct_command(cmd0,=20 >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,=20 >&result) -> CS_SUCCEED, CS_CMD_DONE ct_results(cmd0, &result) ->=20 >CS_END_RESULTS, CS_FALSE >ct_cmd_drop(cmd0) -> CS_SUCCEED >ct_cmd_alloc(conn0, &cmd) -> CS_SUCCEED, cmd1 ct_cmd_alloc(conn0, &cmd) ->= =20 >CS_SUCCEED, cmd2 ct_command(cmd2, CS_LANG_CMD, "begin transaction",=20 >CS_NULLTERM, CS_UNUSED) >-> CS_SUCCEED >ct_send(cmd2) -> CS_SUCCEED >ct_results(cmd2, &result) -> CS_SUCCEED, CS_CMD_SUCCEED ct_results(cmd2,=20 >&result) -> CS_SUCCEED, CS_CMD_DONE ct_results(cmd2, &result) ->=20 >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,=20 >CS_NUMDATA, &value, CS_UNUSED, NULL) -> CS_SUCCEED, 3 ct_describe(cmd1, 1,= =20 >&fmt) -> CS_SUCCEED, datafmt0=3D[name:"Name" >type:CS_CHAR_TYPE status:CS_UPDATABLE format:CS_FMT_UNUSED count:0 >maxlength:30] >ct_bind(cmd1, 1, &datafmt0->fmt=3D[name:"Name" type:CS_CHAR_TYPE >status:CS_UPDATABLE format:CS_FMT_UNUSED count:1 maxlength:30], >databuf0->buff, databuf0->copied, databuf0->indicator) -> CS_SUCCEED, >databuf0->databuf0 >ct_describe(cmd1, 2, &fmt) -> CS_SUCCEED, datafmt1=3D[name:"Owner" >type:CS_CHAR_TYPE status:48 format:CS_FMT_UNUSED count:0 maxlength:30]=20 >ct_bind(cmd1, 2, &datafmt1->fmt=3D[name:"Owner" type:CS_CHAR_TYPE status:48 >format:CS_FMT_UNUSED count:1 maxlength:30], databuf1->buff, >databuf1->copied, databuf1->indicator) -> CS_SUCCEED, databuf1 >ct_describe(cmd1, 3, &fmt) -> CS_SUCCEED, datafmt2=3D[name:"Object_type" >type:CS_CHAR_TYPE status:48 format:CS_FMT_UNUSED count:0 maxlength:22]=20 >ct_bind(cmd1, 3, &datafmt2->fmt=3D[name:"Object_type" type:CS_CHAR_TYPE >status:48 format:CS_FMT_UNUSED count:1 maxlength:22], databuf2->buff, >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) >-> 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= =20 > commit > self.execute('commit transaction') > File "/usr/local/lib/python2.2/site-packages/Sybase.py", line 724, in >execute > status =3D cmd.ct_send() > File "/usr/local/lib/python2.2/site-packages/Sybase.py", line 141, in >_clientmsg_cb > raise DatabaseError(_fmt_client(msg)) >Sybase.DatabaseError: Layer: 1, Origin: 1 >ct_send(): couche api utilisateur: erreur externe: Impossible d'appeler >cette routine car une autre structure de commande est en attente de=20 >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) -> >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 >cannot be called because another command structure has results pending." I= =20 >have the same pb if I perform an insert + select in the same transaction. >Any idea on what is going wrong ? > >Note: in order to compile the module, I had to add the library "itl" to >EXTRA_LIBS. My installation was done whith : >"python setup.py build_ext -U WANT_BULKCOPY" > > >Thanks, >Laurent > >_______________________________________________ >Python-sybase mailing list >Pyt...@ob...=20 >https://object-craft.com.au/cgi-bin/mailman/listinfo/python-sybase Laurent VASSEUR Ing=E9nieur d=E9veloppement IGBMC va...@ig... |