简体   繁体   中英

db2 replace fails with SQLCODE=-171

We have a select statement with the following:

SELECT REPLACE(REPLACE(EMAIL, x'00', ''), '\n', '') AS EMAIL FROM tabname 

This fails with SQLCODE=-171 because EMAIL is empty. What is the most efficient way to replace EMAIL only if EMAIL has content? EMAIL is defined as a varchar. The actual select is pulling multiple columns and doing a replace on most.

如果你这样做?

SELECT REPLACE(REPLACE(ifnull(EMAIL, ''), x'00', ''), '\n', '') AS EMAIL FROM tabname 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM