Clear a big table then insert rows

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

selina_king
Participant
Posts: 21
Joined: Fri Jul 29, 2011 8:02 am

Clear a big table then insert rows

Post by selina_king »

HELLO, everyone.

I want to clear the table then insert rows. When I choose the option it will be delete the data then it will fill up transactions logs in the database.

So I want to clear the data in the before SQL tab. I try to use "Import from /dev/null of del replace into tablename". It is does not work. The logs are

"DB2_UDB_API_9,0: Warning: test_db2_notin_test.DB2_UDB_API_9: SQLExecDirect: Error executing statement 'import from /dev/null of del replace into test3'. See following DB2 message for details."

"DB2_UDB_API_9,0: Warning: test_db2_notin_test.DB2_UDB_API_9: SQLExecDirect: DB2 warning/info message '[IBM][CLI Driver][DB2/NT] SQL0007N The character "" following "import from " is not valid. SQLSTATE=42601"

I do not know what is the matter. Is anyone have ever saw the trouble please give me idea.

By the way . The target database version is V9.1, so I can not use "truncate table tablename immediate".

Thank you very much. It is urgency.




Sorry. I forget it. I use two DB2 APT stage. One is source table another is target table. I want to extract data from source table and clear the target table then insert the data. I want to truncate table but the target database version is V9.1. "truncate" does not work on it.
Last edited by selina_king on Wed Dec 21, 2011 2:22 am, edited 1 time in total.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Don't hurry up!!
Clearing means , do you want to truncate the table and insert?
What stage are you using?

Thanks
pandeeswaran
selina_king
Participant
Posts: 21
Joined: Fri Jul 29, 2011 8:02 am

Post by selina_king »

Sorry. I forget it. I use two DB2 APT stage. One is source table another is target table. I want to extract data from source table and clear the target table then insert the data. I want to truncate table but the target database version is V9.1. "truncate" does not work on it.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Yes.I understand that.
What you are giving exactly in Before sql.

Thanks
pandeeswaran
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

What about this method?

Code: Select all

ALTER TABLE YourTable ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE
pandeeswaran
selina_king
Participant
Posts: 21
Joined: Fri Jul 29, 2011 8:02 am

Post by selina_king »

I want to use "Import from /dev/null of del replace into tablename", it is does not work.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

The code what i have posted is also doing the same.
Make sure whethere that's case sensitive.

Try like:

Code: Select all

IMPORT FROM /dev/null/ OF DEL REPLACE INTO tablename
Dont give any quotes in side the command.
pandeeswaran
selina_king
Participant
Posts: 21
Joined: Fri Jul 29, 2011 8:02 am

Post by selina_king »

Thank you very much. I already try it. But it is still not work.

warning:

DB2_UDB_API_9,0: Warning: test_db2_notin_test.DB2_UDB_API_9: SQLExecDirect: Error executing statement 'IMPORT FROM /dev/null/ OF DEL REPLACE INTO TEST3'. See following DB2 message for details.



DB2_UDB_API_9,0: Warning: test_db2_notin_test.DB2_UDB_API_9: SQLExecDirect: DB2 warning/info message '[IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token "IMPORT" was found following "BEGIN-OF-STATEMENT". Expected tokens may include: "<values>". SQLSTATE=42601
'.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

So,does the below work?

Code: Select all

ALTER TABLE YourTable ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE
And one more suggestion is , a unix script which contains the import from script and call that script in Before job subroutine.

That may work.
pandeeswaran
manoj_23sakthi
Participant
Posts: 47
Joined: Tue Feb 23, 2010 12:16 am
Location: CHENNAI

Post by manoj_23sakthi »

Hi,
Could you please try this in script and call this script in sequencer job
Script must contain this inputs :
Use looping concept
-----------------------
select count(*) from Table >D1
D1 >1
then
(
Delete from (select * from table fetch first 100000 rows only )

commit;

)
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

manoj_23sakthi wrote:Hi,

select count(*) from Table >D1
D1 >1
then
(
Delete from (select * from table fetch first 100000 rows only )

commit;

)
Hi ,

However , delete processes row by row right.
Then how it makes better..
Can you please justify?
pandeeswaran
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

manoj_23sakthi wrote:Could you please try this in script and call this script in sequencer job
By the by, that's Job sequence not sequencer job.
if you call like that, Ray and Craig will become angry.

:)
pandeeswaran
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Just Ray. :wink:

I've seen how the documentation calls it Job Sequence or Sequencer Job interchangeably so it doesn't really bother me as long as you include 'job' in there... there is a Sequence stage after all.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

chulett wrote:there is a Sequence stage after all
Oh no there isn't!

There's a Sequencer which is an activity in a sequence job.
Sequence jobs don't have stages. They have activities.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Just an EMT Ray, an Early Morning Typo. :wink:

And I just have to add - you are getting way too anal in your old age. Yes, they are stages. And yes, those stages represent activities. The documentation likes to flip-flop around on how it refers to them:
Designing a job sequence is similar to designing a job. You create the job sequence in the Designer, add activities (as opposed to stages) from the tool palette, and join these together with triggers (as opposed to links) to define control flow.
You create a job sequence by:
. Placing the stages representing the activities in your sequence on the canvas.
. Linking the stages together.
. Specifying properties details for each activity, defining what it does.
. Specifying trigger information for each activity specifying what action is taken on success or failure of the activity.
It's not worth calling out and whacking people over. IMHO. However, talking about a hash file is still a capital offense. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply