Stored procedure do not work if they require chainedMode to be off
[email protected] Thu, 26 Oct 2006 15:16:44 +0200
| Newsgroups | gmane.comp.python.sybase |
|---|---|
| Message-ID | <OF5E21D55C.74021A39-ONC1257213.00483639-C1257213.0048A2A5@nxbp.fr> |
Message en plusieurs parties au format MIME --=_Boundary_XGBhnMJvrqSuOTJmapO4 Content-Type: message/rfc822 Content-Disposition: attachment; filename=originalmail.eml Received: from SDPIVO01.intranet (unknown [10.254.3.106]) by slpint04.nxbp.fr (Postfix) with ESMTP id 6971A148002 for <[email protected]>; Thu, 26 Oct 2006 15:13:27 +0200 (CEST) To: [email protected] Subject: Stored procedure do not work if they require chainedMode to be off MIME-Version: 1.0 X-Mailer: Lotus Notes Release 6.5.2 June 01, 2004 Message-ID: <OF5E21D55C.74021A39-ONC1257213.00483639-C1257213.0048A2A5@nxbp.fr> From: [email protected] Date: Thu, 26 Oct 2006 15:16:44 +0200 X-MIMETrack: Serialize by Router on SDPIVO01/NXBP/FR(Release 6.53FP1 | December 22, 2004) at 26/10/2006 15:13:27, Serialize complete at 26/10/2006 15:13:27 Content-Type: multipart/alternative; boundary="=_alternative 0048A2A2C1257213_=" Message en plusieurs parties au format MIME --=_alternative 0048A2A2C1257213_= Content-Type: text/plain; charset="US-ASCII" To be executed, some store procedure need the chainedMode to be turned off. If the chained mode is set to true, executing the stored procedure produce this error: Traceback (most recent call last): File "D:\_Projects\NorthToSophisMatching\src\test\TestSybase.py", line 14, in ? c.callproc('up_future_list', False) File "C:\Program Files\Python\Lib\site-packages\Sybase.py", line 729, in callproc self.description = fetcher.start(self.arraysize, out_params) File "C:\Program Files\Python\Lib\site-packages\Sybase.py", line 391, in start return _FetchNow.start(self, arraysize) File "C:\Program Files\Python\Lib\site-packages\Sybase.py", line 315, in start raise e Sybase.DatabaseError: Msg 7713, Level 16, State 2, Line 1 Stored procedure 'up_future_list' may be run only in unchained transaction mode. The 'SET CHAINED OFF' command will cause the current session to use unchained transaction mode. The exemple code(to reproduce this problem) is: db = Sybase.connect('SYBST24', 'ufbe01', '01ebfu', 'dacsa') c = db.cursor() c.callproc('up_future_list') To solve this problem, I have added an optionnal parameter to the callproc of the Cursor class (def callproc(self, name, chainedOff = False, params = ())) and I have insert this peace of code just before the "status = cmd.ct_command(CS_RPC_CMD, name)" line: if chainedOff: cmd.ct_command(CS_LANG_CMD, 'SET CHAINED OFF') for name, value in params.items(): buf = DataBuf(value) buf.name = name status = cmd.ct_param(buf) if status != CS_SUCCEED: fetcher._raise_error(Error, 'ct_param') Cheers, Franck ---------------------------------------------------------------- Franck BOISSON Equity Derivatives Natexis Banques Populaires Tel: (+33)1 58 32 64 06 ---------------------------------------------------------------- --=_alternative 0048A2A2C1257213_= Content-Type: text/html; charset="US-ASCII" <br><font size=2 face="Verdana">To be executed, some store procedure need the chainedMode to be turned off.</font> <br> <br> <br><font size=2 face="Verdana">If the chained mode is set to true, executing the stored procedure produce this error:</font> <br><font size=2 color=red face="Courier New">Traceback (most recent call last):</font> <br><font size=2 color=red face="Courier New"> </font><font size=2 color=#000080 face="Courier New"><u>File "D:\_Projects\NorthToSophisMatching\src\test\TestSybase.py", line 14, in ?</u></font> <br><font size=2 color=red face="Courier New"> c.callproc('up_future_list', False)</font> <br><font size=2 color=red face="Courier New"> </font><font size=2 color=#000080 face="Courier New"><u>File "C:\Program Files\Python\Lib\site-packages\Sybase.py", line 729, in callproc</u></font> <br><font size=2 color=red face="Courier New"> self.description = fetcher.start(self.arraysize, out_params)</font> <br><font size=2 color=red face="Courier New"> </font><font size=2 color=#000080 face="Courier New"><u>File "C:\Program Files\Python\Lib\site-packages\Sybase.py", line 391, in start</u></font> <br><font size=2 color=red face="Courier New"> return _FetchNow.start(self, arraysize)</font> <br><font size=2 color=red face="Courier New"> </font><font size=2 color=#000080 face="Courier New"><u>File "C:\Program Files\Python\Lib\site-packages\Sybase.py", line 315, in start</u></font> <br><font size=2 color=red face="Courier New"> raise e</font> <br><font size=2 color=red face="Courier New">Sybase.DatabaseError: Msg 7713, Level 16, State 2, Line 1</font> <br><font size=2 color=red face="Courier New">Stored procedure 'up_future_list' may be run only in unchained transaction mode. The 'SET CHAINED OFF' command will cause the current session to use unchained transaction mode.</font> <br> <br><font size=2 face="Verdana">The exemple code(to reproduce this problem) is:</font> <br><font size=2 face="Courier New">db = Sybase.connect(</font><font size=2 color=#00a000 face="Courier New"><i>'SYBST24'</i></font><font size=2 face="Courier New">, </font><font size=2 color=#00a000 face="Courier New"><i>'ufbe01'</i></font><font size=2 face="Courier New">, </font><font size=2 color=#00a000 face="Courier New"><i>'01ebfu'</i></font><font size=2 face="Courier New">, </font><font size=2 color=#00a000 face="Courier New"><i>'dacsa'</i></font><font size=2 face="Courier New">)</font> <br><font size=2 face="Courier New">c = db.cursor()</font> <br><font size=2 face="Courier New">c.callproc(</font><font size=2 color=#00a000 face="Courier New"><i>'up_future_list'</i></font><font size=2 face="Courier New">)</font> <br> <br><font size=2 face="Verdana">To solve this problem, I have added an optionnal parameter to the </font><font size=2 face="Courier New">callproc</font><font size=2 face="Verdana"> of the Cursor class (</font><font size=2 color=blue face="Courier New">def</font><font size=2 face="Courier New"> <b>callproc</b>(<i>self</i>, name, chainedOff = </font><font size=2 color=blue face="Courier New">False</font><font size=2 face="Courier New">, params = ())</font><font size=2 face="Verdana">) and I have insert this peace of code just before the "</font><font size=2 face="Courier New">status = cmd.ct_command(CS_RPC_CMD, name)</font><font size=2 face="Verdana">" line:</font> <br><font size=2 color=blue face="Courier New">if</font><font size=2 face="Courier New"> chainedOff:</font> <br><font size=2 face="Courier New"> cmd.ct_command(CS_LANG_CMD, </font><font size=2 color=#00a000 face="Courier New"><i>'SET CHAINED OFF'</i></font><font size=2 face="Courier New">)</font> <br><font size=2 color=blue face="Courier New"> for</font><font size=2 face="Courier New"> name, value </font><font size=2 color=blue face="Courier New">in</font><font size=2 face="Courier New"> params.items():</font> <br><font size=2 face="Courier New"> buf = DataBuf(value)</font> <br><font size=2 face="Courier New"> buf.name = name</font> <br><font size=2 face="Courier New"> status = cmd.ct_param(buf)</font> <br><font size=2 color=blue face="Courier New"> if</font><font size=2 face="Courier New"> status != CS_SUCCEED:</font> <br><font size=2 face="Courier New"> fetcher._raise_error(Error, </font><font size=2 color=#00a000 face="Courier New"><i>'ct_param'</i></font><font size=2 face="Courier New">)</font> <br> <br><font size=2 face="Courier New">Cheers,</font> <br> <br><font size=2 face="Courier New">Franck</font> <br><font size=2 face="Courier New"> </font> <br><font size=2 face="Verdana">----------------------------------------------------------------<br> Franck BOISSON<br> Equity Derivatives<br> Natexis Banques Populaires<br> Tel: (+33)1 58 32 64 06<br> ----------------------------------------------------------------<br> </font> --=_alternative 0048A2A2C1257213_=-- --=_Boundary_XGBhnMJvrqSuOTJmapO4 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Ensemble, faisons un geste pour l'environnement : n'imprimons nos mails que= si n=E9cessaire. L'integrite de ce message n'etant pas assuree sur internet, Natexis Banques Populaires ne peut etre tenu responsable de son contenu. Toute utilisation ou diffusion non autorisee est interdite. Si vous n'etes pas destinataire de ce message, merci de le detruire et d'avertir l'expediteur. Let us mind the environment : let's print our mails only when necessary The integrity of this message cannot be guaranteed on the Internet. Natexis Banques Populaires can not therefore be considered responsible for the contents.Any unauthorized use or= dissemination is prohibited. If you are not the intended recipient of this message, then please delete= it and=0D notify the sender. --=_Boundary_XGBhnMJvrqSuOTJmapO4 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Python-sybase mailing list [email protected] https://www.object-craft.com.au/cgi-bin/mailman/listinfo/python-sybase --=_Boundary_XGBhnMJvrqSuOTJmapO4--