update_dim: ERROR during execution of DB2-CLI requests: SQL_ERROR; SQLSTATE = 42601; NativeErrorCode = -104; Message = [IBM][CLI Driver][DB2/LINUX] SQL0104N An unexpected token "END-OF-STATEMENT" was found following "_dim NONRECOVERABLE"". Expected tokens may include: "JOIN <joined_table>". SQLSTATE=42601.
Failed to prepare statement: load from /dev/null of del replace into ownername.tablename NONRECOVERABLE
It would be great if anyone could point me in the right direction on how to truncate a table in DB2
Well, your load replace syntax seems to be correct but db2 is reading something more than that. Thats why its giving you SQL0104N which just means its a syntax error. Even the SQL0104N help is not very helpful as it just says, hey, your syntax is messed up, fix it. Close that window, open a new one and try the command again. Even try going in from command line and try it there. Also make sure you are running this command for UDB and not DB2. If its DB2, all the tables in that table space will be wiped out. But for UDB it will only truncate the table that you specify.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
DSguru2B wrote:Well, your load replace syntax seems to be correct but db2 is reading something more than that. Thats why its giving you SQL0104N which just means its a syntax error. Even the SQL0104N help is not very helpful as it just says, hey, your syntax is messed up, fix it. Close that window, open a new one and try the command again. Even try going in from command line and try it there. Also make sure you are running this command for UDB and not DB2. If its DB2, all the tables in that table space will be wiped out. But for UDB it will only truncate the table that you specify.
Yeah DSGuru it is syntax error, I wanted to know if there is any special syntax to issue command line commands.It works well when I try it in command line.
ghila wrote:
You can also use the following SQL in order to do a truncate in DB2 :
ALTER TABLE <tablename> ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE
ghila, Thanks for the response when I tried to execute the above query I got sql code =SQL1596N
SQL1596N WITH EMPTY TABLE cannot be specified for <table-name>SQLSTATE=42928
I did a search on sql code =SQL1596N I got some link saying its not allowed for REFRESH IMMEDIATE table. I donot know what that means.
I know it might sound silly, but what if you explicitly add a semicolon to your statement?
ArndW- Thanks for the suggestion, I have already tried that, it doesnt matter I still get the same error.I even tried removing quotes and all other various combination. Is there anything like PL/SQL equivalent syntax for DB2 .
ECHO CONNECT TO database USER user using pwd >file.SQL
ECHO import from nul: of del replace into schema.table; >>file.SQL
ECHO DISCONNECT CURRENT; >>file.SQL
ECHO TERMINATE; >>file.SQL