代码之家  ›  专栏  ›  技术社区  ›  Developer

如何验证给定节点的存在并从azure数据工厂读取值

  •  0
  • Developer  · 技术社区  · 1 年前

    我有一个查找,我正在执行查询以获取 employee_no

    SELECT employee_no FROM HRS.EMPLOYEE_MASTER WHERE SOC_SEC_NO = '@{variables('FE_SoSecNo')}' 这可能会返回如下数据

    {
        "firstRow": {
            "EMPLOYEE_NO": "12345"
        },
        "effectiveIntegrationRuntime": "VMSHIntegrationRuntime",
        "billingReference": {
            "activityType": "PipelineActivity",
            "billableDuration": [
                {
                    "meterType": "SelfhostedIR",
                    "duration": 0.016666666666666666,
                    "unit": "Hours"
                }
            ],
            "totalBillableDuration": [
                {
                    "meterType": "SelfhostedIR",
                    "duration": 0.016666666666666666,
                    "unit": "Hours"
                }
            ]
        },
        "durationInQueue": {
            "integrationRuntimeQueue": 3
        }
    }
    

    或者如果没有找到数据

    {
        "effectiveIntegrationRuntime": "VMSHIntegrationRuntime",
        "billingReference": {
            "activityType": "PipelineActivity",
            "billableDuration": [
                {
                    "meterType": "SelfhostedIR",
                    "duration": 0.016666666666666666,
                    "unit": "Hours"
                }
            ],
            "totalBillableDuration": [
                {
                    "meterType": "SelfhostedIR",
                    "duration": 0.016666666666666666,
                    "unit": "Hours"
                }
            ]
        },
        "durationInQueue": {
            "integrationRuntimeQueue": 3
        }
    }
    

    我添加了一个步骤来读取值,如下所示,但当json节点不存在时,如果节点值不存在,我将尝试插入什么,并通过获取值来更新

    activity('GetEmpBySSN').output.firstRow.employee_no

    enter image description here enter image description here

    我能知道如何写逻辑来读取值吗

    0 回复  |  直到 1 年前
        1
  •  1
  •   Pratik Lad    1 年前

    我创建了一个布尔变量来检查查找的响应是否包含 firstrow 节点与否,而我用来检查属性是否存在的表达式是这样的

    @bool(contains(activity('Lookup1').output, 'firstRow'))
    

    我的布尔变量: enter image description here

    设置变量: enter image description here

    输出

    • 查找输出不存在第一行节点: enter image description here
    • 由于第一行节点不存在,变量返回false: enter image description here

    然后,您可以在 If activity ,根据变量的值,如果节点有条件存在,则获取节点的值。