1、最近的kettle的數據交換配置,啟動kettle引起的錯誤,如下所示:
1 |ERROR|ERROR: missing data for column "createtime" (seg3 slice1 192.168.66.23:40001 pid=33370)
引發這個錯誤,並不是這個字段引起的錯誤,一般是這個字段臨近的字段存在空格或者換行符引發的錯誤。
2、引發這個錯誤,並不是這個字段引起的錯誤,一般是這個字段臨近的字段存在空格或者換行符引發的錯誤。為了問題重現,我新建一個數據庫和數據表:
3、准備插入的正常數據,可以執行多條插入數據:
1 insert into user(name,age,birthday,sex) VALUES("張三",22,"2018-08-20","男"); 2 insert into user(name,age,birthday,sex) VALUES("李四",21,"2018-8-20","男"); 3 insert into user(name,age,birthday,sex) VALUES("王五",18,"2018-8-20","男"); 4 insert into user(name,age,birthday,sex) VALUES("趙六",19,"2018-8-20","男"); 5 insert into user(name,age,birthday,sex) VALUES("李白",20,"2018-8-20","男"); 6 insert into user(name,age,birthday,sex) VALUES("安琪拉",43,"2018-8-20","女"); 7 insert into user(name,age,birthday,sex) VALUES("亞瑟",32,"2018-8-20","男"); 8 insert into user(name,age,birthday,sex) VALUES("魯班",14,"2018-8-20","男");
然后執行查詢結果是沒有查詢結果的:
CONCAT(str1,str2,…) 返回結果為連接參數產生的字符串。

4、然后插入一條換行的數據:
換行的數據可以如下所示造幾條,這里造一條。

然后執行
insert into user(name,age,birthday,sex) VALUES("后
裔",14,"2018-8-20","男");
5、然后可以看到已經查詢出來了這條換行的數據。

6、mysql函數。replace(string_expression , string_pattern , string_replacement),第一個參數:要查找的字段。第二個參數:要查找的字符。第三個參數:要替換成的字符。char(10)換行鍵。char(13)回車鍵。你會發現字段名稱like 的concat里面是char(10)和char(13)都可以進行查詢出結果的。

7、我要的結果就是將帶有換行和回車的字符處理掉,然后執行交換。其他使用情況以后用到再貼。
8、最后說一下,這里是name的字段,本不該出現回車和換行符的,如果是其他長文本字段,可以使用如下命令:
1 -- 將char(10)換行鍵,char(13)回車鍵換成@#r;和@#n; 2 select REPLACE(REPLACE(name, char(10), '@#r;'), char(13), '@#n;') as name from user where name like CONCAT("%",char(13),"%") 3 4 -- 將@#r;和@#換成nchar(10)換行鍵,char(13)回車鍵; 5 select REPLACE(REPLACE(name, '@#r;', char(10)), '@#n;', char(13)) as name from user where name like CONCAT("%",char(13),"%")
待續......
