Generate multiple output files for a single output stage

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
tech_savvy
Participant
Posts: 48
Joined: Mon Oct 08, 2007 7:12 pm
Location: Sydney

Generate multiple output files for a single output stage

Post by tech_savvy »

Hi All,

Issue: There is a single column(name) table with ten records, requirement is to provide seperate output file for each record.. with column value as the file name.

name: (1, 2, 3, 4, 5) as values the output must be 1.txt, 2.txt, 3.txt, 4.txt 5.txt

How to achieve this...in a single run :? [/list]
Regards
Naveen Kandukuri
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Job sequence.
User variables activity to convert the list to delimited list.
Start Loop activity using user variable to control list.
It's been explained before. Search.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

A parallel (C++) routine which creates files dynamically will be the best way to do this 'in a single run'.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

pxCreateFile: Parallel routine (C++) which creates files dynamically.

Code: Select all

//Creates and writes on a text file for each record
//Pass the FileName with path as first parameter Ex: <Path>: LinkName.InputColumn : '.txt'
//Pass the Content of the file as second parameter Ex: LinkName.InputColumn
//Px routine call --> pxCreateFile(<Path>: LinkName.InputColumn : '.txt', LinkName.InputColumn)
//If file creation is success 0 is returned, else 1. Use this status for report/tracking/print to file/print to peek
//If file already exists, overwrite happens
//Pass '' (empty) as second Parameter if you don't want anything to be printed in the file)


#include <iostream>
#include <fstream>
using namespace std;

int pxCreateFile(char *FileName, char *Msg)
 {
  int StatusFlag=0;
  ofstream myfile (FileName);
  if (myfile.is_open())
  {
    myfile << Msg;
    myfile << "\n"; //Comment this line if a new line char is not required at the end of the file by default
    myfile.close();
  }
  else 
   {
    StatusFlag = 1;
   }

   return StatusFlag;
}
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
Post Reply