这是什么意思?LEN(TRIM(Weight)) == 0 ?(DT_STR,50,1252)NULL(DT_STR,50,1252) : (DT_STR,50,1252)重量 [英] What does this mean? LEN(TRIM(Weight)) == 0 ? (DT_STR,50,1252)NULL(DT_STR,50,1252) : (DT_STR,50,1252)Weight

查看:26
本文介绍了这是什么意思?LEN(TRIM(Weight)) == 0 ?(DT_STR,50,1252)NULL(DT_STR,50,1252) : (DT_STR,50,1252)重量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是派生列ReplaceWeight"的表达式

Here's an expression for a derived column "ReplaceWeight"

LEN(TRIM(Weight)) == 0 ? (DT_STR,50,1252)NULL(DT_STR,50,1252) : (DT_STR,50,1252)Weight

我不清楚这个 IF 语句的 True 部分的语法...

I'm unclear about the syntax of the True portion of this IF statement...

我将其读作如果修剪后的列 'Weight' 的长度为零,则分配派生列 ReplaceWeight 字符串类型的 NULL 值?? 否则将 Weight 列转换为字符串并将此值分配给派生列"

I read this as "If the length of the trimmed column 'Weight' is zero, assign the derived column ReplaceWeight the a NULL value of type string?? ELSE convert the Weight column to a string and assign this value to the derived column"

表达式生成器告诉我

NULL(DT_STR,50,1252) 

...返回指定数据类型 DT_STR 的 NULL 值.这对我来说有点奇怪,因为我习惯于将 NULL 作为各种类型的数据库列的值.

...returns a NULL value of the specified data type, DT_STR. This is a little weird to me, since I am used to NULL being a value that database columns of various types.

我是否可以解释以下意思是将 STRING 数据类型的空值转换为 STRING 数据类型?"

Am I to interpret that the following means "convert the null value of a STRING data type to a STRING data type?"

(DT_STR,50,1252)NULL(DT_STR,50,1252)

我认为这是有效的:

   LEN(TRIM(Weight)) == 0 ? NULL : (DT_STR,50,1252)Weight

我是否正确地解释了这段代码?

Am I interpreting this code propertly?

推荐答案

您发布的第一个表达式是正确的.

The first expression that you posted is correct.

表达式根据它在表达式中看到"的值定义派生列的数据类型.您没有机会像定义表时那样手动定义派生列的数据类型.因此,所有可能的返回值都必须正确定义数据类型.

The expression defines the data type of the derived column based on the values that it "sees" in the expression. You do not get the chance to manually define the data type of a derived column as you do when defining a table. So it is important that all possible return values have the data type defined correctly.

这是一个函数:NULL(DT_STR,50,1252)

This is a function: NULL(DT_STR,50,1252)

该函数返回 NULL 并定义字段类型.您会认为这对于 SSIS 来说已经足够了,但是您还必须对返回值进行类型转换,从而导致有些多余:(DT_STR,50,1252)NULL(DT_STR,50,1252)

The function returns NULL with the field type defined. You would think that this would be sufficient for SSIS, but you must also typecast the returned value, resulting in the somewhat redundant: (DT_STR,50,1252)NULL(DT_STR,50,1252)

如果有人能解释为什么 SSIS 需要对已经定义了数据类型的值进行类型转换,我很想听听解释.

If someone can explain why SSIS requires typecasting values that already have a data type defined, I'd be interested to hear the explanation.

干杯,彼得

这篇关于这是什么意思?LEN(TRIM(Weight)) == 0 ?(DT_STR,50,1252)NULL(DT_STR,50,1252) : (DT_STR,50,1252)重量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆