From my python code, I am trying to execute stored procedure. Stored Procedure return integer value.
CREATE PROCEDURE MY_PROC
@empID char(10),
@oldEmpList XML,
@newEmpList XML,
@Status INT OUTPUT
AS
-- sp body
SET @Status = 1
RETURN
GO
python
t = text('EXEC MY_PROC :empID, :oldEmpList, :newEmpList, :Status',
bindparams=[bindparam('empID', type_=String, value='1234'),
bindparam('oldEmpList', type_=TEXT, value='<emp><id>1</id><id>2</id>'),
bindparam('newEmpList', type_=TEXT, value='<emp><id>e01</id><id>e02</id>'),
bindparam('Status', type_=Integer, value=0, isoutparam=True)])
result = CMS_DBSession.execute(t)
print result.out_parameters
it print nothing as output parameter.
How can I access output paramter
There is a working solution here : https://groups.google.com/forum/#!topic/sqlalchemy/dn-W0rrlwxk
That would give something like :
t = text('SET NOCOUNT ON; declare @Status int; EXEC MY_PROC :empID, :oldEmpList, :newEmpList, @Status; Select @Status; SET NOCOUNT OFF;',
bindparams=[bindparam('empID', type_=String, value='1234'),
bindparam('oldEmpList', type_=TEXT, value='<emp><id>1</id><id>2</id>'),
bindparam('newEmpList', type_=TEXT, value='<emp><id>e01</id><id>e02</id>'))
result = CMS_DBSession.execute(t)
# then get the select result
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.