From: Stephen M. <mo...@gm...> - 2008-06-19 14:42:31
|
Ah, yes, that seems to have worked as one would expect with the raw sql. Should this check be enriched for the next version perhaps? On Thu, Jun 19, 2008 at 10:20 AM, Sébastien Sablé <sa...@us...> wrote: > Great, now can you try the following code (adding select=False at the end of > execute): > > import apresdb > c2 = apresdb.instance.cursor() > c2.execute("select iv0.ProdId, iv0.Account, iv0.StartPos, iv0.CurrPos, > sum(iv1.StartPos) 'SumStartPos', sum(iv1.CurrPos) 'SumCurrPos' into > tempdb..a_sum from PortfolioInv iv0, PortfolioInv iv1 where iv1.ProdId = > iv0.ProdId", select=False) > > > In python-sybase 0.39, the execute will activate the use of sybase cursors > (ct_cursors) instead of commands when the request starts with "select". > > This is done because ct_cursor is the only way I know in Sybase to overlap > requests, for example doing an update while retrieving the results of a > select. > > The test which decide if we use a ct_cursor or not should probably be > enriched. > > -- > Sébastien Sablé > > > Stephen Mock a écrit : >> >> Ok, i did that and reinstalled version 3.9. I'm still getting the >> same error, but the traceback is definitely different. Here's the >> newest version of the error: >> >>>>> import apresdb >>>>> c2 = apresdb.instance.cursor() >>>>> c2.execute("select iv0.ProdId, iv0.Account, iv0.StartPos, iv0.CurrPos, >>>>> sum(iv1.StartPos) 'SumStartPos', sum(iv1.CurrPos) 'SumCurrPos' into >>>>> tempdb..a_sum from PortfolioInv iv0, PortfolioInv iv1 where iv1.ProdId = >>>>> iv0.ProdId") >> >> Traceback (most recent call last): >> File "<stdin>", line 1, in ? >> File "build/bdist.linux-x86_64/egg/Sybase.py", line 546, in execute >> File "build/bdist.linux-x86_64/egg/Sybase.py", line 695, in _start >> File "build/bdist.linux-x86_64/egg/Sybase.py", line 709, in _mainloop >> File "build/bdist.linux-x86_64/egg/Sybase.py", line 753, in _raise_error >> Sybase.DatabaseError: Msg 3803, Level 16, State 1, Line 1 >> The statement used to define the cursor 'ctmp2a98a1e560' is neither a >> SELECT nor an EXECUTE. >> >> >> >> On Thu, Jun 19, 2008 at 4:02 AM, Sébastien Sablé >> <sa...@us...> wrote: >>> >>> Hi Stephen, >>> >>> are you sure that you are using python-sybase 0.39? >>> >>> sable@incubus:~/sybase/python-sybase-0.39$ grep -r _LAZY_END_RESULT * >>> sable@incubus:~/sybase/python-sybase-0.39$ >>> >>> I think your backtrace corresponds to a prior version of python-sybase. >>> >>> This may be linked to the use of setuptools in python-sybase 0.39. >>> Setuptools will install a python_sybase-0.39-py2.4-linux-i686.egg file in >>> your site-package, but not remove the old python-sybase files. >>> >>> I think this could be solved by removing in >>> /apps/python/lib/python2.4/site-packages/ >>> the following files: >>> Sybase.pyc >>> Sybase.py >>> sybasect* >>> >>> and then reinstalling version 0.39. >>> >>> Then we can see if there is still a problem. >>> >>> regards >>> >>> -- >>> Sébastien Sablé >>> >>> Stephen Mock a écrit : >>>> >>>> I recently upgraded to version .039 from .037 and am having a problem >>>> with some basic sql. It should create a temp table on the fly for me >>>> to select from, but i get an error caused by the "select ... into" >>>> statement. It works perfectly fine with the older version. Here's >>>> the code: >>>> >>>>>>> import apresdb >>>>>>> c2 = apresdb.instance.cursor() >>>>>>> c2.execute("select iv0.ProdId, iv0.Account, iv0.StartPos, >>>>>>> iv0.CurrPos, >>>>>>> sum(iv1.StartPos) 'SumStartPos', sum(iv1.CurrPos) 'SumCurrPos' into >>>>>>> tempdb..a_sum from PortfolioInv iv0, PortfolioInv iv1 where >>>>>>> iv1.ProdId = >>>>>>> iv0.ProdId") >>>> >>>> Traceback (most recent call last): >>>> File "<stdin>", line 1, in ? >>>> File "/apps/python/lib/python2.4/site-packages/Sybase.py", line 546, >>>> in execute >>>> self._set_state(_LAZY_END_RESULT) >>>> File "/apps/python/lib/python2.4/site-packages/Sybase.py", line 695, in >>>> _start >>>> if self._closed: >>>> File "/apps/python/lib/python2.4/site-packages/Sybase.py", line 709, >>>> in _mainloop >>>> # Send parameters. >>>> File "/apps/python/lib/python2.4/site-packages/Sybase.py", line 753, >>>> in _raise_error >>>> raise ProgrammingError('cursor is closed') >>>> Sybase.DatabaseError: Msg 3803, Level 16, State 1, Line 1 >>>> The statement used to define the cursor 'ctmp2a956073b0' is neither a >>>> SELECT nor an EXECUTE. >>>> >>>> >>>> >>>> Any help would be greatly appreciated. >>>> >>>> >>>> ------------------------------------------------------------------------- >>>> Check out the new SourceForge.net Marketplace. >>>> It's the best place to buy or sell services for >>>> just about anything Open Source. >>>> http://sourceforge.net/services/buy/index.php >>>> _______________________________________________ >>>> Python-sybase-misc mailing list >>>> Pyt...@li... >>>> https://lists.sourceforge.net/lists/listinfo/python-sybase-misc >>> > > |