从python sqlalchemy调用过程时出错

2020-08-22 05:37发布

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


当我使用sqlalchemy lib从表类型输入和python的varchar out参数调用存储过程时遇到错误。以下是错误

从python sqlalchemy.exc.DatabaseError调用过程时出错:(pyhdb.exceptions.DatabaseError)无效参数:输入参数不足以作为表参数:

第一个参数是表类型,第二个参数是varchar

我正在添加尝试使用的代码段

 engine = create_engine(" hana + pyhdb://{username}:{password} @ {host}:{port}"。format(username ='username',password ='password',host ='hostname'  ,port ='30015'))
 output ="
 数据='[{" RULE_ID":1," RULE_NAME":null," SO_SSA":" 1074"," PO_NUMBER":null," CODE":" DDD"," ROUTE_CODE":""," OPERATING":  null," SHIP_TO":" IND"," SHIP_TO_REGION":" MX"," SHIP_TO_CUSTOMER_ID":null," BILL_TO_CUSTOMER_ID":null," END_TO_CUSTOMER_ID":null," SLCA":" AKP123"," HOLD_NAME":" 批准保留"," SHIPPING_PREFERENCE":null," EAD":null," CUSTOMER_REQUEST_TYPE":null," CRD":null," CRSD":null," CURRENT_PROMISE_DATE":null," CURRENT_PROMISE_DELIVERY_DATE"" ATE:null"  null," OPDD":null," ON_HOLD":null," FLOW_STATUS_CODE":null," PICK_RESULT":null," IS_IN_OTM":null," BUSINESS_UNIT":null," REVENUE_FLAG":null," ACTION_CATEGORY":null,  " ACTION_OWNER":null," SS_REVENUE":null," CARTONS":null," INVOICE_ELIGIBILITY_EVENT":null," SALES_CHANNEL":null," CREATED_BY":" NEW"," CREATION_DATE":" 2020-02-11 10:  24PM"," LAST_UPDATED_BY":" NEW"," LAST_UPDATE_DATE":" 2020-03-04 10:39 PM"," FDA_FLAG":null," POE_FLAG":null," CONSOLIDATED_FLAG":null," START_DATE":" 2019  -01-02"," END_DATE":" 2020-01-02"," ACTIVE":" T"}]]'

 test = engine.execute('call SCHEMA.PROC(?,?)',(数据,输出))
 

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


当我使用sqlalchemy lib从表类型输入和python的varchar out参数调用存储过程时遇到错误。以下是错误

从python sqlalchemy.exc.DatabaseError调用过程时出错:(pyhdb.exceptions.DatabaseError)无效参数:输入参数不足以作为表参数:

第一个参数是表类型,第二个参数是varchar

我正在添加尝试使用的代码段

 engine = create_engine(" hana + pyhdb://{username}:{password} @ {host}:{port}"。format(username ='username',password ='password',host ='hostname'  ,port ='30015'))
 output ="
 数据='[{" RULE_ID":1," RULE_NAME":null," SO_SSA":" 1074"," PO_NUMBER":null," CODE":" DDD"," ROUTE_CODE":""," OPERATING":  null," SHIP_TO":" IND"," SHIP_TO_REGION":" MX"," SHIP_TO_CUSTOMER_ID":null," BILL_TO_CUSTOMER_ID":null," END_TO_CUSTOMER_ID":null," SLCA":" AKP123"," HOLD_NAME":" 批准保留"," SHIPPING_PREFERENCE":null," EAD":null," CUSTOMER_REQUEST_TYPE":null," CRD":null," CRSD":null," CURRENT_PROMISE_DATE":null," CURRENT_PROMISE_DELIVERY_DATE"" ATE:null"  null," OPDD":null," ON_HOLD":null," FLOW_STATUS_CODE":null," PICK_RESULT":null," IS_IN_OTM":null," BUSINESS_UNIT":null," REVENUE_FLAG":null," ACTION_CATEGORY":null,  " ACTION_OWNER":null," SS_REVENUE":null," CARTONS":null," INVOICE_ELIGIBILITY_EVENT":null," SALES_CHANNEL":null," CREATED_BY":" NEW"," CREATION_DATE":" 2020-02-11 10:  24PM"," LAST_UPDATED_BY":" NEW"," LAST_UPDATE_DATE":" 2020-03-04 10:39 PM"," FDA_FLAG":null," POE_FLAG":null," CONSOLIDATED_FLAG":null," START_DATE":" 2019  -01-02"," END_DATE":" 2020-01-02"," ACTIVE":" T"}]]'

 test = engine.execute('call SCHEMA.PROC(?,?)',(数据,输出))
 
付费偷看设置
发送
4条回答
jovirus
1楼-- · 2020-08-22 06:02
葫芦娃快救爷爷
2楼-- · 2020-08-22 06:01

感谢您访问SAP社区以获取问题的答案。 由于您是第一次在这里提出问题,因此建议您熟悉 https ://community.sap.com/resources/questions-and-answers (如果您还没有的话),因为它提供了准备问题的技巧,这些问题引起了我们成员的回响。

如果您愿意,可以先选择"操作",然后再"编辑"来修改您的问题(尽管一旦有人回答了您的问题,您将失去编辑问题的能力-但是,如果发生这种情况,您可以在" 评论)。

-Jerry

bbpeas
3楼-- · 2020-08-22 05:59

亲爱的Arunkumar

实际上,DB过程应该使用table [],而不是数据字符串。

所以您可能不得不写这样的东西

开始

 -从表中选择值以填充表
    tabledata = SELECT * from xyz;
        
    
  test = engine.execute('call SCHEMA.PROC(?,?)',(tabledata,output))
 END; 
土豆飞人
4楼-- · 2020-08-22 06:19

感谢 Venkateswaran Krishnamurthy 。这不是一种 表,它是HANA中的一种表类型

表类型数据是从UI以JSON格式提供的,我们在python脚本中使用了表数据,所以我的问题更像是从python脚本发送此输入到过程,第一个参数接受表类型值,我需要 将收到的JSON输入转换为表类型

一周热门 更多>