RE: newbie problem

Laurent VASSEUR <[email protected]>
Newsgroups gmane.comp.python.sybase
Message-ID <[email protected]>
Ok, it solved the problem.
Thanks

Laurent

A 16:49 14/01/2003 +0200, vous avez écrit :
>Hi,
>
>You need to close the cursor before you can commit your work:
>
>db.begin()
>c=db.cursor()
>c.callproc('sp_help')
>c.close()
>db.commit()
>
>works for me.
>
>Have fun,
>         Shai.
>
>-----Original Message-----
>From: Laurent VASSEUR [mailto:[email protected]]
>Sent: Tuesday, January 14, 2003 10:44
>To: [email protected]
>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 = 1
>import sys
>
>db=Sybase.connect('DB','USR', 'PWD', database='test')
>c=db.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) ->
>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, 
>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)
>-> 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=[name:"Name"
>type:CS_CHAR_TYPE status:CS_UPDATABLE format:CS_FMT_UNUSED count:0
>maxlength:30]
>ct_bind(cmd1, 1, &datafmt0->fmt=[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=[name:"Owner"
>type:CS_CHAR_TYPE status:48 format:CS_FMT_UNUSED count:0 maxlength:30] 
>ct_bind(cmd1, 2, &datafmt1->fmt=[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=[name:"Object_type"
>type:CS_CHAR_TYPE status:48 format:CS_FMT_UNUSED count:0 maxlength:22] 
>ct_bind(cmd1, 3, &datafmt2->fmt=[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 
> commit
>      self.execute('commit transaction')
>    File "/usr/local/lib/python2.2/site-packages/Sybase.py", line 724, in
>execute
>      status = 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 
>résultats. 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 
>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
>[email protected] 
>https://object-craft.com.au/cgi-bin/mailman/listinfo/python-sybase


         Laurent VASSEUR
Ingénieur développement IGBMC
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.