2012-03-17 31 views
0

我被这个问题困住了一段时间,需要您的意见。如何从Python中获取输出参数Sybase模块

我必须用2个输出参数(int和varchar)处理供应商的过程调用。我选择Python的Sybase模块,一切正常,直到我发现我找不到描述如何使用输出参数调用存储过程的文档。

总是在Google上找到的主要文档是http://python-sybase.sourceforge.net/news.html。他们介绍了函数调用很快:

Output parameters from stored procedures are supported via the OUTPUT() function. The parameter to OUTPUT() determines the type and size of the buffer which will be allocated to receive the output value.

c.callproc('test_proc', {'@type': 'business', 
         '@tot_sales': 5, 
         '@num_books': Sybase.OUTPUT(1)}) 

如果输出类型是整数,则Sybase.OUTPUT(1)是正确的工作,但我不知道 如何处理VARCHAR(和其他类型)。

不正确的参数类型,我总是得到错误:

DatabaseError: Msg 257, Level 16, State 1, Procedure sp_caller_id_manage Implicit conversion from datatype 'VARCHAR' to 'INT' is not allowed. Use the CONVERT function to run this query.

任何想法?

回答

0

尝试将CS​​_DATAFMT()的实例传递给OUTPUT而不是1(它们使用其他地方的参数传递给Sybase.py中的DBMS)。 尝试设置它的字段数据类型和最大长度(以及可能的状态)。