How to execute SQL query in sequence.

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

Post Reply
stiwari
Participant
Posts: 64
Joined: Wed Apr 05, 2006 3:45 am

How to execute SQL query in sequence.

Post by stiwari »

Hi All,

I am loading the data from difference schema using Sequence and in this i am using Startloop,Activity and Endloop to change schema names at run time.....the main thing is that i am droping the index of the target table before loading and creating after load for that i am using open and close command at job level.....but whenever it runs the job for the different schema it drops and recreate the index....i want to drop the index once and it should create index after loading all the data from all the schema.....is there any way to create index after the loop ends finally....



Thanks in advance

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

Post by chulett »

SQL script in the Execute Command stage.
-craig

"You can never have too many knives" -- Logan Nine Fingers
stiwari
Participant
Posts: 64
Joined: Wed Apr 05, 2006 3:45 am

Post by stiwari »

Can I directly put SQL query in Execute command?.The query that i want to run is as follows.

ALTER TABLE SCHEMA_NAME.TABLE_NAME DROP PRIMARY KEY.

Where exactly do i need to put this stage so that it executes only once.

Thanks
in advance
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No, you need to create a script to 'wrapper' it and log into your command line sql tool of choice. Can't get more specific than that as you've haven't mentioned what database you are using. :?

As to the where, put it after the End Loop.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sud
Premium Member
Premium Member
Posts: 366
Joined: Fri Dec 02, 2005 5:00 am
Location: Here I Am

Post by sud »

stiwari wrote:Can I directly put SQL query in Execute command?.The query that i want to run is as follows.

ALTER TABLE SCHEMA_NAME.TABLE_NAME DROP PRIMARY KEY.

Where exactly do i need to put this stage so that it executes only once.

Thanks
in advance
Hey,

If you are trying to do the execution of the sequel just before a job, it is a good idea to put the sequel as an open command in a database stage within the job itself.

:)
It took me fifteen years to discover I had no talent for ETL, but I couldn't give it up because by that time I was too famous.
stiwari
Participant
Posts: 64
Joined: Wed Apr 05, 2006 3:45 am

Post by stiwari »

Hey Sud,


Ya, i can use open command and close command. but the problem is different, Actually while loading the record i am using startLoop and Endloop....and suppose if i give that SQL command(which drops and create the primary keys) in the open and close command of jobs, then what it will do...whenever loop will pick the different schema name it will drop and recreate the primary key, which will reduce the performace... , I want to drop the primary key only once when Sequence will start the job...and after loading all the data from all the schemas it should recreate the primary key....thatwhy i want to use some thing in Sequence itself.........i don't have much knowledage of execute command and UNIX so can you plz give me the solution in detail.....


Thanks in advance

Sumit....
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There are plenty of examples, which you could find in a search.

You use a UNIX editor, such as vi, to create a script that executes the appropriate command (for example sqlplus for Oracle) to issue the SQL statement against the database.

Use a chmod command to add execute permission to the script.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jking123
Premium Member
Premium Member
Posts: 29
Joined: Tue Mar 23, 2004 9:18 pm

Re: How to execute SQL query in sequence.

Post by jking123 »

If you can afford the overead of another job you could use e.g. the Dynamic RDBMS stage to run a sql command/file in a job and call that from the sequence.
Post Reply