SybaseIQ导入数据库Load失败的解决办法
使用isql导入脚本的方式Load数据到IQ中时,出现下面错误:
(0 rows affected)
Msg 21, Level 14, State 0:
SQL Anywhere Error -1013027: Number of bytes (2) for a column from an input file
has exceeded the maximum allowed (512).
-- (db_RecScanner.cxx 725)
原因说明:
行结束的分隔符如果使用的是 '\n' 或者 '\X0a'或者 '\Xob' ,则在操作系统中的编码机不一样,导致寻找换行符的时候,寻找失败,出现上面的错误。
下面是我的解决办法:
如果是使用bcp导出的文件,那么在bcp语句的最后面,加上 -r@@@
然后在Load脚本的最后一个字段后面填写行分隔符的时候,改成'@@@'
这样再导入即可!
参考的是下面这篇不知道是什么文的内容:
Problème:
L'éxecution du load table génére ce message d'erreur:
Could not execute statement.
Number of bytes (3) for a column from an input file has exceeded the
maximum allowed (512).
-- (db_RecScanner.cxx 725)
SQLCODE=-1013027, ODBC 3 State="HY000"
Référence trouvée dans la doc (Sybase):
Error 1013027
Number of bytes (%2) for a column from an input file has exceeded the maximum allowed (%3). %1
Item Description
SQLCode
-1013027L
Constant
EMSG_DB_RECSCANNER_E_EXCEEDMAX
SQLState
QCA27
ODBC 2 State
ERROR
ODBC 3 State
ERROR
Sybase Error Code
20597
Severity Code
Parameter 1
location of the exception
Parameter 2
# of bytes.
Parameter 3
maximum number of bytes allowed.
Probable cause
The number of bytes you are trying to load into a column from an input file has exceeded the maximum number of bytes allowed.
Extrait de la commande Load:
LOAD TABLE XXXXXXXXXXXXXXXXXXXXXX
( XXXXXXX '|',
XXXXXXXX '|',
XXXXXXXXXXX '|',.....
xxxxxxxxxx '|',
xxxxxxxxxxx '|',
xxxxxxxxxxx '@@@')
FROM '/PATH/Fichier_NAME'
QUOTES OFF
ESCAPES OFF
MESSAGE LOG '/PATH/Fichier_Name.log'
row log '/PATH/Fichier_Name.log';
commit;
Résolution
Le problème est dans les fichier source
Aprés analyse du fichier, la génération du fichier s'est faite avec un select sans effacer le nombre de ligne retourné à la fin du fichier.
XXXX|NXXXXX| |XXXX|XXXX|XXXX| | | |XXXX|XXXX|XXXX|XXXXXXXX|XXXX|XXXX| | |XXXX| | | |XXXX| | | | |XXXX | | | |XXXX| |XXXX| |XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX|XXXX| |XXXXXXXX| | |XXXX| |XXXX|XXXX| | | | | |XXXX| |XXXX| | | | | | |XXXX| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |XXXX|XXXX|XXXX| |XXXX| | | |XXXX| |XXXX|XXXX|XXXX| | | | | | | | | | | | |XXXX|XXXX |X @@@
XXXX|000002207
La suppression de la ligne résout le problème.