【问题标题】:pass string parameter to remote process in kdb将字符串参数传递给 kdb 中的远程进程
【发布时间】:2021-11-27 17:06:07
【问题描述】:

您好,我正在尝试将字符串变量传递给 ipc 查询。对我不起作用。 任何意见将不胜感激。

例子:

[`EDD.RDB; "?[`tab;enlist(like;`OrderId;",("string Number),");();(?:;`Actions)]"]

我正在尝试查询这个 RDB,其中 OrderId 像 Number(string) Number 是一个参数,但是当我作为字符串传递给远程进程时,Number 不再是字符串。我尝试将字符串放在前面,但仍然得到相同的结果。

我想传递给远程进程的是这个

Number:"abc"
"?[`tab;enlist(like;`OrderId;"abc");();(?:;`Actions)]"

【问题讨论】:

    标签: kdb


    【解决方案1】:

    在您更新问题后进行编辑。

    这里很难给出可靠的答案,因为您的示例缺少信息。

    您发布的内容不是 KDB+ 中的有效 IPC 调用。我怀疑你可能试图运行的是这样的:

    h(`EDD.RDB; "?[`tab;enlist(like;`OrderId;",("string Number),");();(?:;`Actions)]"])
    

    假设 Number 是一个 int(例如 Number:123),那么在这种情况下,您可以将其重写为:

    h(`EDD.RDB;"select distinct Actions from t where orderID like \"",string[Number],"\"")
    

    哪个更易于阅读和使用。假设 Number 是在客户端定义的,那么上面应该返回一个答案。

    如果您确实想使用函数形式,那么您可以尝试以下方法:

    "?[`tab;enlist (like;`orderID;string[",string[Number],"]);1b;(enlist`Actions)!enlist`Actions]"
    

    作为您的查询字符串。

    如果 Number 已经是您进程中的字符串,例如 Number:"123",那么您应该能够:

    h(`EDD.RDB;"select distinct Actions from t where orderID like \"",Number,"\"")
    OR
    h(`EDD.RDB;"?[`tab;enlist (like;`orderID;string[",Number,"]);1b;(enlist`Actions)!enlist`Actions]")
    

    【讨论】:

      【解决方案2】:

      IPC 查询必须是字符串吗?使用 IPC 的 (func;params) 语法传递参数会更简洁。

      handleToRdb ({[number] ?[`tab;enlist(like;`OrderId;number);();(?:;`Actions)]};"abc")
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-07-19
        • 1970-01-01
        • 2016-06-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-03-16
        • 1970-01-01
        相关资源
        最近更新 更多