Subrecord to Varchar
Moderators: chulett, rschirm, roy
Subrecord to Varchar
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 !!
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.
UmmmDSguru2B 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.
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.
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?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.
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.
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
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.
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.
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.
Ok now your more clear when you said pass arrays as argument. As a stand alone function you can pass arrays as arguments. Like
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.
Code: Select all
void printArray(char myArr[], int size)
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.
This was what I said in the first post that you cannot pass arrays/pointers since datastage doesn't allow it.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
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.
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?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.
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.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: