如果为空,如何为参数设置默认值?
How to set a default value for a parameter if null?
如果运行时未提供,我需要将 SYSTEM DATE
设置为我的 load_date
参数的默认值。我可以通过检查传递的值并根据 NULL 检查相应地分配它来实现这一点。是否有内置功能可以实现此目的?
我什至尝试使用 if_null 步骤,但它似乎是个问题。
这是我在日志中得到的
2017/11/10 14:19:13 - Spoon - Transformation opened.
2017/11/10 14:19:13 - Spoon - Launching transformation [123]...
2017/11/10 14:19:13 - Spoon - Started the transformation execution.
2017/11/10 14:19:13 - 123 - Dispatching started for transformation [123]
2017/11/10 14:19:19 - get_variables.0 - Finished processing (I=0, O=0, R=1, W=1, U=0, E=0)
2017/11/10 14:19:19 - Write to log.0 -
2017/11/10 14:19:19 - Write to log.0 - ------------> Linenr 1------------------------------
2017/11/10 14:19:19 - Write to log.0 - load_date = null
2017/11/10 14:19:19 - Write to log.0 -
2017/11/10 14:19:19 - Write to log.0 - ====================
2017/11/10 14:19:19 - get_system_info.0 - Finished processing (I=0, O=0, R=1, W=1, U=0, E=0)
2017/11/10 14:19:19 - if_null.0 - Finished processing (I=0, O=0, R=1, W=1, U=0, E=0)
2017/11/10 14:19:19 - Write to log.0 - Finished processing (I=0, O=0, R=1, W=1, U=0, E=0)
2017/11/10 14:19:22 - Spoon - The transformation has finished!!
这就是我转型的样子。每个步骤的图片中嵌入了详细信息。
事实上 If Null
不接受 replace by value
中的字段,只接受一个值。
虽然其他解决方案也是可能的,但您可能希望使用 Modify JavaScript Value
。根据作业如何为您的转换提供参数,您可能必须将条件替换为 if(load_date!='null')
或 if(!load_date.isEmpty())
。
如果运行时未提供,我需要将 SYSTEM DATE
设置为我的 load_date
参数的默认值。我可以通过检查传递的值并根据 NULL 检查相应地分配它来实现这一点。是否有内置功能可以实现此目的?
我什至尝试使用 if_null 步骤,但它似乎是个问题。
这是我在日志中得到的
2017/11/10 14:19:13 - Spoon - Transformation opened.
2017/11/10 14:19:13 - Spoon - Launching transformation [123]...
2017/11/10 14:19:13 - Spoon - Started the transformation execution.
2017/11/10 14:19:13 - 123 - Dispatching started for transformation [123]
2017/11/10 14:19:19 - get_variables.0 - Finished processing (I=0, O=0, R=1, W=1, U=0, E=0)
2017/11/10 14:19:19 - Write to log.0 -
2017/11/10 14:19:19 - Write to log.0 - ------------> Linenr 1------------------------------
2017/11/10 14:19:19 - Write to log.0 - load_date = null
2017/11/10 14:19:19 - Write to log.0 -
2017/11/10 14:19:19 - Write to log.0 - ====================
2017/11/10 14:19:19 - get_system_info.0 - Finished processing (I=0, O=0, R=1, W=1, U=0, E=0)
2017/11/10 14:19:19 - if_null.0 - Finished processing (I=0, O=0, R=1, W=1, U=0, E=0)
2017/11/10 14:19:19 - Write to log.0 - Finished processing (I=0, O=0, R=1, W=1, U=0, E=0)
2017/11/10 14:19:22 - Spoon - The transformation has finished!!
这就是我转型的样子。每个步骤的图片中嵌入了详细信息。
事实上 If Null
不接受 replace by value
中的字段,只接受一个值。
虽然其他解决方案也是可能的,但您可能希望使用 Modify JavaScript Value
。根据作业如何为您的转换提供参数,您可能必须将条件替换为 if(load_date!='null')
或 if(!load_date.isEmpty())
。