how to insert record into table when input file is empty

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
shalini11
Participant
Posts: 74
Joined: Thu Jan 22, 2009 3:00 am

how to insert record into table when input file is empty

Post by shalini11 »

Hi All,

I have to load data from a file into database.

When there are no records in the file(empty file), then i want to enter 1 hardcoded record into table.

How can i implement this?Could you pls help.


Thanks
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post by nagarjuna »

As of now i think of having a execute command activity stage ( using wc -l filename ) and if output of that execute activity stage is 0 then insert hardcoded value else normal action.
Nag
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or perhaps check if the file is empty before the job starts and conditionally append this 'hardcoded record' to it.
-craig

"You can never have too many knives" -- Logan Nine Fingers
dsedi
Participant
Posts: 220
Joined: Wed Jun 02, 2004 12:38 am

Post by dsedi »

nagarjuna wrote:As of now i think of having a execute command activity stage ( using wc -l filename ) and if output of that execute activity stage is 0 then insert hardcoded value else normal action.
I doubt it. The exec command activity will just trigger the output link or it will not(based on the conditional expression).Now how(where) do you write "insert hard coded value else normal action"
dsedi
Participant
Posts: 220
Joined: Wed Jun 02, 2004 12:38 am

Re: how to insert record into table when input file is empty

Post by dsedi »

shalini11 wrote:Hi All,

I have to load data from a file into database.

When there are no records in the file(empty file), then i want to enter 1 hardcoded record into table.

How can i implement this?Could you pls help.


Thanks
Have you implemented anything? pls post it here so all can benefit.
Btw..What is empty file? You mean a file with ZERO size or No data (with header)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Job Sequence

Code: Select all

                           +-->  Job to insert hard coded row
                           |
GetFileSize  --->  Test  --+
                           |
                           +--> Job to process file contents
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
datastage_learner
Participant
Posts: 15
Joined: Thu May 07, 2009 9:50 pm

Post by datastage_learner »

I have to load data from a file into database.

When there are no records in the file(empty file), then i want to enter 1 hardcoded record into table.
mate...since you have not described the scenario properly, how your job is going to run properly. if at source level file if there is no data, won't it stop or abort for that matter? :(
Thanks,
DS_Learner
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post by nagarjuna »

DataStage job wont abort if you dont have records in the input sequential file .It will run successfully .

datastage_learner wrote:
I have to load data from a file into database.

When there are no records in the file(empty file), then i want to enter 1 hardcoded record into table.
mate...since you have not described the scenario properly, how your job is going to run properly. if at source level file if there is no data, won't it stop or abort for that matter? :(
Nag
Post Reply