Db2 Import command as before SQL

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Xanadu
Participant
Posts: 61
Joined: Thu Jul 22, 2004 9:29 am

Db2 Import command as before SQL

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Why not do it 'before job' via a script?
-craig

"You can never have too many knives" -- Logan Nine Fingers
s_r_chandru
Charter Member
Charter Member
Posts: 13
Joined: Tue Apr 08, 2003 9:51 pm
Location: Australia

Post 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
Xanadu
Participant
Posts: 61
Joined: Thu Jul 22, 2004 9:29 am

Post 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
JDionne
Participant
Posts: 342
Joined: Wed Aug 27, 2003 1:06 pm

Post 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
Sure I need help....But who dosent?
Post Reply