SSIS 包中使用的表达式是否有嵌套级别限制?

发布于 2025-01-05 06:52:48 字数 1374 浏览 1 评论 0原文

使用 SQL Server 2008。我第一次尝试 SSIS 脚本,我需要模拟一些用 VB.net 编写的 if/then 条件逻辑。我找不到任何以前处理表达式中嵌套条件的问题,并且相信我正在遵循我通过谷歌在派生列中的嵌套条件上发现的内容。

我在尝试在派生列转换编辑器中使用嵌套条件时收到错误。我收到的错误表明 SSIS 无法解析我的表达式。实际的异常:“来自 HRESULT 的异常:0xC0204006 (Microsoft.SqlServer.DTSPipelineWrap)”

答案可能会立即回答我的问题(并创建新问题)的问题:

  • 是否存在嵌套级别限制?
  • 可以在 [表达式] 的条件1部分中执行嵌套吗? [条件1]:[条件2]

我将给出两个片段,第一个是我实际插入的内容,第二个是更适合读者的版本。希望有人能指出我的错误。

不确定它是否具有方位,但请注意 [BusArea] 是在上一步中导出的列。

实际表达:

[BusArea] == "CCC" || [BusArea] == "NBU" || [BusArea] == "CA" ? (ISNULL([CASE_MORG]) or TRIM([CASE_MORG]) == "" ? ( ISNULL([TRX_MORG]) or TRIM([TRX_MORG]) == "" ? NULL(DT_WSTR,50) : [TRX_MORG]) : [CASE_MORG]) : (ISNULL([CASE_AGT]) or TRIM([CASE_AGT]) == "" ? ( ISNULL([TRX_AGT]) or TRIM([TRX_AGT]) == "" ? NULL(DT_WSTR,50) : [TRX_AGT]) : [CASE_AGT])

为了便于阅读而格式化:

[BusArea] == "CCC" || [BusArea] == "NBU" || [BusArea] == "CA" ? 
    (ISNULL([CASE_MORG]) or TRIM([CASE_MORG]) == "" ?
        ( ISNULL([TRX_MORG]) or TRIM([TRX_MORG]) == "" ?
            NULL(DT_WSTR,50)
            : [TRX_MORG]
        )
        : [CASE_MORG]
    )
    : (ISNULL([CASE_AGT]) or TRIM([CASE_AGT]) == "" ?
        ( ISNULL([TRX_AGT]) or TRIM([TRX_AGT]) == "" ?
            NULL(DT_WSTR,50)
            : [TRX_AGT]
        )
        : [CASE_AGT]
    )

Working in SQL Server 2008. My first stab at an SSIS script and I need to emulate some if/then conditional logic written in VB.net. I couldn't find any previous questions dealing with nested conditions in expressions and believe I'm following what I've been able to uncover via google on nested conditions in a derived column.

I'm receiving an error while attempting to use nested conditions in the derived column transformation editor. The error I'm receiving indicates that SSIS could not parse my expression. The actual exception: "Exception from HRESULT: 0xC0204006 (Microsoft.SqlServer.DTSPipelineWrap)"

Questions for which the answers might immediately answer my question (and create a new problem):

  • is there a nesting levels limit?
  • can nesting be performed in the condition1 portion of [expression] ? [condition1] : [condition2]

I'll give two snippets, the first is what I'm actually inserting, the second is a more reader-friendly version. Hopefully someone can point out my error.

Not sure that it has bearing, but please note that [BusArea] is a column derived in a previous step.

actual expression:

[BusArea] == "CCC" || [BusArea] == "NBU" || [BusArea] == "CA" ? (ISNULL([CASE_MORG]) or TRIM([CASE_MORG]) == "" ? ( ISNULL([TRX_MORG]) or TRIM([TRX_MORG]) == "" ? NULL(DT_WSTR,50) : [TRX_MORG]) : [CASE_MORG]) : (ISNULL([CASE_AGT]) or TRIM([CASE_AGT]) == "" ? ( ISNULL([TRX_AGT]) or TRIM([TRX_AGT]) == "" ? NULL(DT_WSTR,50) : [TRX_AGT]) : [CASE_AGT])

formatted for easier reading:

[BusArea] == "CCC" || [BusArea] == "NBU" || [BusArea] == "CA" ? 
    (ISNULL([CASE_MORG]) or TRIM([CASE_MORG]) == "" ?
        ( ISNULL([TRX_MORG]) or TRIM([TRX_MORG]) == "" ?
            NULL(DT_WSTR,50)
            : [TRX_MORG]
        )
        : [CASE_MORG]
    )
    : (ISNULL([CASE_AGT]) or TRIM([CASE_AGT]) == "" ?
        ( ISNULL([TRX_AGT]) or TRIM([TRX_AGT]) == "" ?
            NULL(DT_WSTR,50)
            : [TRX_AGT]
        )
        : [CASE_AGT]
    )

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一影成城 2025-01-12 06:52:48

我认为嵌套条件没有任何限制。即使有,我也不认为我们会达到我们创建的处理业务流程的包的限制。

你几乎一切都正确了。您的条件语句的问题是您使用了 or 而不是 ||

我复制了您的确切语句并粘贴到数据流任务内的派生转换并收到错误,因为包无法解析表达式。我用正确的逻辑或||)运算符替换了所有,并且表达式计算正确。

带有条件语句的问题

I don't think there is any limit with nesting conditions. Even if there is one, I don't think we will reach the limit in the packages that we create handle our business processes.

You almost got everything correct. The issue with your conditional statement is that you have used or instead of ||

I copied your exact statement and pasted in Derived Transformation within a Data Flow task and got an error because the package couldn't parse the expression. I replaced all the or's with correct Logical OR (||) operator and the expression evaluated correctly.

Issue with conditional statement

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文