【发布时间】:2019-04-15 12:50:20
【问题描述】:
我有一个数据类型为 VARCHAR2(18) 的列 nse_credit_rating。
它包含189.00-250.00 形式的值。
但有些记录在字符串末尾有空值,即即使与我相关的数据长度为 13 (189.00-250.00) 但 length(nse_credit_rating) 返回 17 作为输出,即末尾有 4 个空值。
当我必须在此列上使用 to_number 时出现主要问题,它返回“ORA-1722 无效数字”,因为它包含 null。
有没有办法在 NULL 值出现之前获取子字符串?
我什至拿了dump(nse_credit_rating)的输出。
SELECT dump(nse_credit_rating),nse_symbol
FROM nse_security_master
where nse_series='EQ'
and nse_symbol like 'ARVIND'
and nse_series='EQ'
输出:
Typ=1 Len=17: 51,54,55,46,48,48,45,52,52,56,46,53,48,0,0,0,0
这里 0 是 NULL 的 ascii。
SELECT (nse_credit_rating),nse_symbol
FROM nse_security_master
where nse_series='EQ'
and nse_symbol like 'ARVIND'
and nse_series='EQ'
输出:
367.00-448.50
我尝试使用ascii(substr(nse_credit_rating,-1,1)),但这仅在我知道最后只有一个字符为 Null 时才有效。但可能有任意数量的字符为 NULL。
【问题讨论】: