【问题标题】:Power Automate Desktop - Pass User Input as Variable into SQL QueryPower Automate Desktop - 将用户输入作为变量传递到 SQL 查询中
【发布时间】:2023-02-10 01:47:37
【问题描述】:

在 Power Automate Desktop 中获取用户输入并将该输入作为 SQL 查询中的参数/变量传递的正确方法是什么。

例如,如果用户输入值 3,我该如何运行如下所示的 SQL 查询 -

从值 > 3 的表中选择 *

Power Automate Desktop 将用户输入存储在一个变量中,我尝试了多种变体:

select * from table where value > %UserInput%
select * from table where value > "%UserInput%"
select * from table where value > %[UserInput]%

而且我尝试了更多变体,但没有得到任何结果。

任何反馈将不胜感激!

【问题讨论】:

    标签: sql variables input power-automate-desktop


    【解决方案1】:

    你有输入数据的样本吗? 我将创建新问题,因为我想,由于逗号作为分隔符,我在将数字从一个软件转换为 PowerAutomate 变量以将其添加到 decimal(18,2) sql 表列时遇到问题。我尝试使用 Python 脚本替换字符串中的 char,但 Python 将此变量视为元组! 这对我有用 - 在 sql 查询中替换 replace("%totalGrossAmount%",",","."):

    SET QUOTED_IDENTIFIER OFF
    SET ANSI_NULLS ON INSERT INTO vouchers (voucher, organizationId, voucherType, voucherStatus, voucherNumber, voucherDate, shippingDate, dueDate, totalGrossAmount, totalTaxAmount, taxType, useCollectiveContact, contactId, remark, amount, taxAmount, taxRatePercent, categoryId, files, createdDate, updatedDate, version) values ("%voucher%", "%organizationId%", "%type%", "%voucherStatus%", "%voucherNumber%", "%voucherDate%", "%shippingDate%", "%dueDate%", replace("%totalGrossAmount%",",","."), replace("%totalTaxAmount%",",","."), "%taxType%", "%useCollectiveContact%", "%contactId%", "%remark%", replace("%amount%",",","."), replace("%taxAmount%",",","."), replace("%taxRatePercent%",",","."), "%categoryId%", "%files%", "%createdDate%", "%updatedDate%", %version%)
    

    【讨论】:

    • 正如目前所写,您的答案尚不清楚。请edit 添加更多详细信息,以帮助其他人了解这如何解决所提出的问题。你可以在in the help center找到更多关于如何写出好的答案的信息。
    【解决方案2】:

    如果数据库列是VARCHAR

    select * from table where value > '%UserInput%'
    

    如果数据库列是INT

    select * from table where value > %UserInput%
    

    您还必须确保 PAD 中的数据符合您在 where 条件中提到的列的数据类型。

    【讨论】:

      【解决方案3】:

      我有解决方案:

      "%voucher%"
      

      我将 varchar 值的前缀添加到 SQL base 并替换函数以调整十进制值

      【讨论】:

      • A code-only answer is not high quality。虽然此代码可能有用,但您可以通过说明其工作原理、工作原理、应在何时使用以及它的局限性来改进它。请edit你的答案包括解释和相关文档的链接。
      猜你喜欢
      • 2022-06-19
      • 2021-06-03
      • 2021-06-21
      • 1970-01-01
      • 2016-07-02
      • 2021-07-11
      • 2022-12-04
      • 2022-10-13
      • 2019-02-16
      相关资源
      最近更新 更多