在 PowerAutomate(SQL Server) 中循环存储过程结果集的每个元素

Loop each element of a stored Procedure ResultSet in PowerAutomate(SQL Server)

我想向我的 Flow 添加一个操作,它循环遍历 ResultSet 中的所有项目并将它们添加到 SQL 服务器 Table。

使用如下所示的存储过程检索结果集:

return 值如下所示:

如果使用 SQL 服务器,我可以访问 "ReturnCode" "Insert Row" 操作如下:

但我不知道如何对该 ResultSet 中的每个元素执行插入操作,因为 我在使用 foreach 操作时无法访问它:

如果解决方案很明显,请原谅我,我是 PowerAutomate 的新手,不太明白 return 类型是如何处理的。另外,如果缺少任何必需的信息,请告诉我,以便我可以在此处添加。

你的回复对我来说看起来像 JSON,因此,你可以使用流程中的 "Parse JSON" cction 创建一个你可以使用其属性的 "object"。

例如:

您的 JSON 回复:

{
    "glossary": {
        "title": "example glossary",
        "GlossDiv": {
            "title": "S",
            "GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
                    "SortAs": "SGML",
                    "GlossTerm": "Standard Generalized Markup Language",
                    "Acronym": "SGML",
                    "Abbrev": "ISO 8879:1986",
                    "GlossDef": {
                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
                        "GlossSeeAlso": [
                            "GML",
                            "XML"
                        ]
                    },
                    "GlossSee": "markup"
                }
            }
        }
    }
}

当您将其粘贴到 "Generate from Template" 对话框并单击 "Done" 时,您将获得如下所示的架构:

{
    "type": "object",
    "properties": {
        "glossary": {
            "type": "object",
            "properties": {
                "title": {
                    "type": "string"
                },
                "GlossDiv": {
                    "type": "object",
                    "properties": {
                        "title": {
                            "type": "string"
                        },
                        "GlossList": {
                            "type": "object",
                            "properties": {
                                "GlossEntry": {
                                    "type": "object",
                                    "properties": {
                                        "ID": {
                                            "type": "string"
                                        },
                                        "SortAs": {
                                            "type": "string"
                                        },
                                        "GlossTerm": {
                                            "type": "string"
                                        },
                                        "Acronym": {
                                            "type": "string"
                                        },
                                        "Abbrev": {
                                            "type": "string"
                                        },
                                        "GlossDef": {
                                            "type": "object",
                                            "properties": {
                                                "para": {
                                                    "type": "string"
                                                },
                                                "GlossSeeAlso": {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "string"
                                                    }
                                                }
                                            }
                                        },
                                        "GlossSee": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

根据您的 JSON 回复,您可能想要重命名架构中的一些属性,甚至更改它们的类型 - 这将有助于您在下一步操作中查看属性:

编辑:您的数组类型对象(来自架构)可以在 Foreach 循环中使用