想知道语法含义

时间:2019-04-15 13:57:36

标签: oracle sql-loader

任何人都可以解释以下语法的含义以及如果我的捐赠金额为12345.67889889,如果我只想加载12345.67,则必须在上述语法中进行哪些更改。

DONATION_AMOUNT NULLIF DONATION_AMOUNT = BLANKS DEFAULTIF DONATION_AMOUNT = 'NULL' "REGEXP_REPLACE(TRIM(:DONATION_AMOUNT),'[,/$]')",

2 个答案:

答案 0 :(得分:0)

您是否可以不使用CAST cast(round(DONATION_MOUNT) as numeric(x,2)),其中x是最大位数?

答案 1 :(得分:0)

NULLIF DONATION_AMOUNT = BLANKS
  If the donation_amount field in the file is blank, set it to NULL in the table.

DEFAULTIF DONATION_AMOUNT = 'NULL'
  If the donation_amount field in the file = the string 'NULL', set it to NULL in the table.

"REGEXP_REPLACE(TRIM(:DONATION_AMOUNT),'[,/$]')"
  The TRIM() call removes blanks from either end of the string read from the file, 
then removes commas, slashes and dollar signs.

除上述规则外,要截断到2个小数位,请将其包装在REGEXP_SUBSTR()中,该匹配匹配锚定在字符串开头的1个或多个数字,后跟一个小数点,然后是最多2个可选数字

REGEXP_SUBSTR(REGEXP_REPLACE(TRIM(:DONATION_AMOUNT),'[,/$]'), '^\d+\.\d?\d?', 1, 1)