由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Quant版 - get value returned by SQLstored procedure from python (转载)
相关主题
run SQL stored procedure from python (转载)python 在windows下连接数据库
error of access IBM Netteza database from C# in Visual Stud (转载)access two databases in one ODBC connection from pyodbc (转载)
create table on SQL server from python pyodbc国内银行都这样吗?
SQL run a stored procedure by fetching from a cursor row by (转载)报个BarCap HongKong的offer
error run SQL query from pyodbc python 3.2.5弱问excel调用c++ function的问题
SQL debug step into a store procedure from another one矿工能用自己的帐户炒股票吗?
error of executing SQL query of string concatenation[合集] 如果只是programmer也是经常加班的吗
WALL STREET Record Bonus Season[合集] 想问个职业规划的问题~
相关话题的讨论汇总
话题: sql话题: value话题: server话题: my话题: procedure
进入Quant版参与讨论
1 (共1页)
l******9
发帖数: 579
1
【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: get value returned by SQLstored procedure from python
发信站: BBS 未名空间站 (Fri Aug 1 18:07:59 2014, 美东)
I need to check the returned value from a stored procedure on SQL server
2008 R2.
import pyodbc
sql_str = """
DECLARE @return_value int
SET @return_value = -1
INSERT INTO [my_database].[dbo].[my_table]
EXEC @return_value = [my_database].[dbo].[my_stored_
procedure]
if @return_value <> 0
BEGIN
EXEC sys.sp_addmessage 60000, 16, ' test sp returns
wrong code ! '
RAISERROR (60000, 16, 1)
END
"""
sql_str_connect_db = " DRIVER={SQL server};SERVER={my_server};DATABASE={my_
db};UID=my_id;PWD=my_password "
cnxn = pyodbc.connect(sql_str_connect_db )
cursor_test = cnxn.cursor()
cursor_test.execute(sql_str)
cnxn_test.commit()
But, I got error:
pyodbc.Error: ('HY007', '[HY007] [Microsoft][ODBC SQL Server Driver]
Associated statement is not prepared (0) (SQLNumResultCols)')
And, how to check the value of "@return_value" in python ?
After searching , I cannot find a solution.
Thanks
1 (共1页)
进入Quant版参与讨论
相关主题
[合集] 想问个职业规划的问题~error run SQL query from pyodbc python 3.2.5
[合集] Front-Offce, Mid-Office and Back-Office区别在那?SQL debug step into a store procedure from another one
Help: learning SQLerror of executing SQL query of string concatenation
金融工程程序大收集WALL STREET Record Bonus Season
run SQL stored procedure from python (转载)python 在windows下连接数据库
error of access IBM Netteza database from C# in Visual Stud (转载)access two databases in one ODBC connection from pyodbc (转载)
create table on SQL server from python pyodbc国内银行都这样吗?
SQL run a stored procedure by fetching from a cursor row by (转载)报个BarCap HongKong的offer
相关话题的讨论汇总
话题: sql话题: value话题: server话题: my话题: procedure