Subrecord to Varchar

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

sud
Premium Member
Premium Member
Posts: 366
Joined: Fri Dec 02, 2005 5:00 am
Location: Here I Am

Subrecord to Varchar

Post by sud »

Hi,

My original objective was to pass a subrecord to a C routine, but since C routine definition in Datastage is not allowing me to pass a pointer, this cannot be done. Please let me know in case this is possible.

So my workaround is to pass each subrecord as varchar with comma delimited values. The subrecord I am getting after using a "combine rocords" stage and then a "split subrecord" stage. But how do I put these subrecords into a varchar in a comma delimited format?

Alternatively I can use a stage variable and keep concatinating things and finally pass it out -- instead of using "combine records". But this will be my last option if nothing works.

Thanks in advance !!
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.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Who said you cannot pass arguments to C routines that are pointer types? If you look at the Argument's tab while creating a px routine, you will find Input types as char * and int * etc.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
sud
Premium Member
Premium Member
Posts: 366
Joined: Fri Dec 02, 2005 5:00 am
Location: Here I Am

Post by sud »

DSguru2B wrote:Who said you cannot pass arguments to C routines that are pointer types? If you look at the Argument's tab while creating a px routine, you will find Input types as char * and int * etc.
Ummm :roll:

The only native types in the drop down are :

char
char*
double
float
int
long
short
unsigned char
unsigned int
unsigned long
unsigned short

Datastage version is 7.5.2

Are those datatypes available for you?
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.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Yes. The ones which are suffixed with an astrix (*) means you can send in a string. You can specify your input variable as char* and send it any length of record you like.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
sud
Premium Member
Premium Member
Posts: 366
Joined: Fri Dec 02, 2005 5:00 am
Location: Here I Am

Post by sud »

DSguru2B wrote:Yes. The ones which are suffixed with an astrix (*) means you can send in a string. You can specify your input variable as char* and send it any length of record you like.
Yes, so it won't eat a pointer. Now the question is I have a subrecord, how do I convert into a comma delimited Varchar?
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.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

I am not able to get what do you mean by "eat a pointer". Will you be passing the string or the memory address of the string? You cannot do the latter, how will you get the memory address of the string inside datastage?

Pass the values in as arguments. For example if I want to concatenate 3 fields, my C routine will look something like

Code: Select all


char* ConcatenateAll(char* Arg1, char* Arg2, char* Arg3)
{
      const int size = 1000;
      char* result = (char *)malloc (3*size); 
      sprintf(result, "%s,%s,%s", Arg1, Arg2, Arg3);
      return result

} 
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
sud
Premium Member
Premium Member
Posts: 366
Joined: Fri Dec 02, 2005 5:00 am
Location: Here I Am

Post by sud »

Well, let me explain. It does not eat pointers means it does not take arrays as arguments. Char* is nothing but a string, u cant pass an array of strings though.

Now I don't need a C routine that concatenates strings, I need to convert a subrecord to a varchar with delimited data and pass this varchar as a string to the routine.
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.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Ok now your more clear when you said pass arrays as argument. As a stand alone function you can pass arrays as arguments. Like

Code: Select all

void printArray(char myArr[], int size)
I am not sure if you can do this inside datastage. Have you tried specifying char as your input and suffixing your argument with [] ?

Also give me an example of your input record and how it should look after all the transformations. I mean from the time you start and the final formatted data.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
sud
Premium Member
Premium Member
Posts: 366
Joined: Fri Dec 02, 2005 5:00 am
Location: Here I Am

Post by sud »

sud wrote:The only native types in the drop down are :

char
char*
double
float
int
long
short
unsigned char
unsigned int
unsigned long
unsigned short

Datastage version is 7.5.2
This was what I said in the first post that you cannot pass arrays/pointers since datastage doesn't allow it.

Now the workaround is to convert the subrecord field into a Varchar with delimited values. Does anybody know how to do it? Is it possible?
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.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You said pass a pointer not pass an array. There is a difference. Arrays are defined as 'char' which is present in your list. Anywho, try what I suggested and see if that works.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
sud
Premium Member
Premium Member
Posts: 366
Joined: Fri Dec 02, 2005 5:00 am
Location: Here I Am

Post by sud »

DSguru2B wrote:You said pass a pointer not pass an array. There is a difference. Arrays are defined as 'char' which is present in your list. Anywho, try what I suggested and see if that works.
Well, let's not talk at all about pointers and arrays since you cannot use them. My question is very simple. A subrecord field has to be converted to a Varchar containig delimited values. How do you do it?
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.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Give an example of your data, as I've previously requested, and show me how you want it to look like.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Promote Subrecord stage?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sud
Premium Member
Premium Member
Posts: 366
Joined: Fri Dec 02, 2005 5:00 am
Location: Here I Am

Post by sud »

Please hold on ... I am writing the whole description with data that will give u better idea. Gimme some time.
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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No! No!
It's urgent!!!
:lol:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply