由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
_Python版 - get value returned by SQLstored procedure from python (转载)
相关主题
run SQL stored procedure from python (转载)run SQL stored procedure from python (转载)
create table on SQL server from python pyodbc (转载)run SQL stored procedure from python
pypyodbc error access netezza SQL server on win7 (转载)run SQL stored procedure from python (转载)
access two databases in one ODBC connection from pyodbc (转载)DSN-less connection to SQL server
Declarative GUI for Tkinter[转载] how to link to remote access database?
get value returned by SQLstored procedure from pythonhow to link to remote access database?
get value returned by SQLstored procedure from python (转载)Oracle XE DBconnection from ASPX (转载)
get value returned by SQLstored procedure from python (转载)error of access IBM Netteza database from C# in Visual Stud (转载)
相关话题的讨论汇总
话题: sql话题: value话题: server话题: my话题: procedure
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页)
相关主题
error of access IBM Netteza database from C# in Visual Stud (转载)Declarative GUI for Tkinter
create table on SQL server from python pyodbc (转载)get value returned by SQLstored procedure from python
pypyodbc error access netezza SQL server on win7 (转载)get value returned by SQLstored procedure from python (转载)
问一个db2的弱问题get value returned by SQLstored procedure from python (转载)
run SQL stored procedure from python (转载)run SQL stored procedure from python (转载)
create table on SQL server from python pyodbc (转载)run SQL stored procedure from python
pypyodbc error access netezza SQL server on win7 (转载)run SQL stored procedure from python (转载)
access two databases in one ODBC connection from pyodbc (转载)DSN-less connection to SQL server
相关话题的讨论汇总
话题: sql话题: value话题: server话题: my话题: procedure