Page 1 of 1

Db2 Import command as before SQL

Posted: Tue Oct 05, 2004 8:36 am
by Xanadu
Hello,
I am trying to truncate a table using the DB2 import command (importing an emprty file into the table)
The command works fine at the Command Center and Db2 prompt.
But when I try to run it as a "before SQL" statement I get this error :

[IBM][CLI Driver][DB2/AIX64] SQL0104N An unexpected token "from" was found following "import ". Expected tokens may include: "JOIN <joined_table>". SQLSTATE=42601

Executing SQL statement 'import from empty of del replace into <tablename>'

Anyone else encountered this problem ?
Actually my table has more than 40 million rows - so I dont want to do a delete from on it but use this command instead.

Any inputs are appreciated.
Thanks
-Xan

Posted: Tue Oct 05, 2004 9:07 am
by chulett
Why not do it 'before job' via a script?

Posted: Wed Oct 06, 2004 12:27 am
by s_r_chandru
Hi,
We also tried to use but could not accomplish in the before Sql.
So we used Before routine to do the truncation
paste following code in job before routine and substitute according to yours
Eg:
db2 "connect to <databasename>";db2 "export to '<filepath>' of ixf select * from <tablename> where 1=2" ;db2 "import from '<filepath>' of ixf replace into <tablename>"

-Chandru

Posted: Thu Oct 07, 2004 8:17 am
by Xanadu
Thanks for your response Chandru.
But I get this error when I try doing that :
db2 "connect to <databasename>";
"String Constant unexpected, Was expecting: Assignment Operator"

I am positive that I am doing some trivial error and missing something - but not able to figure out what.

Anyways thanks for letting me know
-Xan

Posted: Thu Oct 07, 2004 8:39 am
by JDionne
s_r_chandru wrote:Hi,
We also tried to use but could not accomplish in the before Sql.
So we used Before routine to do the truncation
paste following code in job before routine and substitute according to yours
Eg:
db2 "connect to <databasename>";db2 "export to '<filepath>' of ixf select * from <tablename> where 1=2" ;db2 "import from '<filepath>' of ixf replace into <tablename>"

-Chandru
The before job routine...is that a basic routine or do you past the above code right into the code line?
Jim