How does a remove string function in a transformer works

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
RAJEEV KATTA
Participant
Posts: 103
Joined: Wed Jul 06, 2005 12:29 am

How does a remove string function in a transformer works

Post by RAJEEV KATTA »

Hi All,
There is no documentation of remove string function,so can anyone tell me how to use it.Mean while I have tried to experiment by running the following function remove("toronto:canada:na",":") ,though this function is being accepted in the transformer but when it is being compiled it throws the following error

Compiling: Source = 'RT_BP27/JOB.48064380.DT.1414559687.TRANS1', Object = 'RT_BP27.O/JOB.48064380.DT.1414559687.TRANS1'
******************************************************************************************************************?*
0048 Pin%%V0S1P2.Column%%1 = (Remove("rajeev", ','))

^
String Constant unexpected, Was expecting: Assignment Operator
0058 END

^
"ELSEEOL" unexpected, Was expecting: END, "REPEAT", "UNTIL", "WHILE"
0065 UPDATE.COUNT -= 1

^
WARNING: Text found after final END statement


2 Errors detected, No Object Code Produced.
(str_Remove.Transformer_1)
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I can't remember the exact syntax of the REMOVE function (there is a REMOVE statement as well, but that does something quite different). I don't have DS on this machine, but if you open up your PDF BASIC Programmer's Guide you can find the definition and description of the function.
RAJEEV KATTA
Participant
Posts: 103
Joined: Wed Jul 06, 2005 12:29 am

Post by RAJEEV KATTA »

Hi Arnd,
The syntax in transformer is Remove(%string%,%delimiter%) whose syntax in basic language is Remove(dynamic.array,variable).It says in basic language that it extracts & returns the dynamic array elements from system delimiters.I have provided the variable as 2 in the above example but still is unable to compile.I have even tried with an example which has end of strinf as delimiter whose variable value is 0 in basic language but still it is unable to compile.Can you please help me out with an example.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

OK, that is what I thought but couldn't remember. This is similar to the REMOVE statement and it works on "dynamic arrays" or strings that have the special DS delimiters and therefore is not the function that you are looking for.

If your goal is to strip out all occurrences of a given single character in a string then you can use a variation of the TRIM() function {I can't recall the exact syntax so I won't post that, but you can read it in the documentation} or the CONVERT(In.String,":",""). If you need to replace all occurrences of a string longer than 1 character you can use the EREPLACE() function.

If you only wish to replace one occurrence of a substring you can still do it in one single command, but it is more complex and inefficient and uses LEN(), INDEX() and substring functions.
RAJEEV KATTA
Participant
Posts: 103
Joined: Wed Jul 06, 2005 12:29 am

Post by RAJEEV KATTA »

Thanks a lot Arnd.I was learning to use different string functions but always getting stucked at dynamic arrays related function.I thought dynamic arrays are arrays with no fixed length but if it is an string with special delimiters.Are the special delimiters in datastage a combination of characters or multi characters.Can you give me any string function example which uses dynamic array like extract or remove etc so that i would know better how a function with dynamic array works.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The separators most commonly used are @FM, @VM, @SM and @TM (Field, Value, Sub-Value and Text marks). The BASIC Programmer's Guide give a good description of these characters in one of the beginning chapters that is worth reading.
Post Reply