Transformer Stage Functions

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

DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Did you make this particular column with that humongous derivation a nullable column? Another point, nulls arent really populated in a flat file. You will just see an empty value.
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 »

Nulls are populated in a flat file with whatever you specify as the Null Field Value property.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

vick wrote:Thanks a ton Ray!

I plugged in your code and concatenated with "V-" and it works great except for 5 & 6. (Values after ----------------> are the results)

Code: Select all

1. "3.5 L V6 24-Valve DOHC"  --------------------->  V-6   
2. "3.8 L V-6 24-Valve DOHC" --------------------->  V-6
3. "4.6 L V8 w/4 valve per CYL" ------------------->  V-8
4. "5.5 L 32-Valve Aluminum V-12"---------------->  V-12
5. "5.9 L V-12 32-Valve Aluminum"---------------->  V-
6. "3.9 L V6 32-Valve Aluminum"------------------>   V-
7. "AMG 5,439-cc 24-Valve Supercharged"------->  Null

How do you account for when the data is similar to 5 & 6 (When V6 or V-12 comes in before the word "Valve")

Any suugestions?

TIA
Try replacing the constant in the pattern ("V") with " V".

Code: Select all

If InLink.Product Matches "0X' V'1N0N0X" Then MatchField(InLink.Product, "0X' V'0N0X", 3) Else If InLink.Product Matches "0X' V-'1N0N0X" Then MatchField(InLink.Product, "0X' V-'0N0X", 3) Else @NULL
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vick
Participant
Posts: 88
Joined: Sun Oct 30, 2005 2:06 am

Post by vick »

Hey folks

My team lead has decided not to go with BASIC Tfr as he needs this to be a pristine DS-EE environment.

Looks like I need to develop a C-routine for this purpose.

Any suggestions, samples, pointers on developing a C-routine.

TIA
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Use strstr() C funtion to locate your string and then do substrings or you can use sscanf() to get the literal you require.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Give it your best shot, post your code here and then we can go from there. Its not that hard.
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 »

vick wrote:My team lead has decided not to go with BASIC Tfr as he needs this to be a pristine DS-EE environment.
Thinking of a word that rhymes with "anchor" but isn't "banker".

The DS-EE environment includes the BASIC Transformer stage. Therefore including such a stage does not in any way detract from your environment being pristine.

What we have with the BASIC Transformer stage is a tool that can do the job and which is part of the toolset. Now there's a requirement to develop in a language with which no-one on the team is familiar. What's wrong with this picture?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vick
Participant
Posts: 88
Joined: Sun Oct 30, 2005 2:06 am

Post by vick »

Hello folks

I was wondering if there is C-routine sample that somebody could pass across. I searched for it but could'nt find what I need.

It would be of great help to me as I will learn to code in a new language.

TIA

vick
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Well, its kind of hard to teach you a new language just through description. You have to go through language syntax, create your first program "Hello World", go through some functions etc etc etc.
Ill give you a piece of code, you can go through it, google up the functions, see what they do.

Code: Select all

//header files
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//Main Function
char* GetEngineInfo(char* inp)
{ //Declare Variables
  const int SIZE = 100;
  char* out = (char *)malloc (SIZE);
  char* x = (char *)malloc (SIZE);
  char* p = (char *)malloc (SIZE);
  int i = 0;

  //Check if input is empty
  if (strlen(inp) < 1)
    return NULL;

  //Strip out the literal "Valve"
  x = strstr(inp, "Valve");
  if(x)
    strncpy(x, "     ",5);

  //Look for character "V". If not found then search for "V-"
  p = strstr(inp, "V");
  if(!p)
    p = strstr(inp, "V-");

  //If either "V" or "V-" are found get everything untill you hit space
  if(p)
  {
    while(strncmp(p, " ", 1) != 0 )
    {
     out[i++]=*p++;
    }
      out[i] = '\0'; //terminate string
  }
  //Return NULL if not found
  else
  {
    strcpy(out,NULL);
  }

 return out;
}
The description for each and every function used in the code above can be googled up. C has been around for ages and hence a lot of information present on the web.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
vick
Participant
Posts: 88
Joined: Sun Oct 30, 2005 2:06 am

Post by vick »

Thanks a bunch DSguru2B. Appreciate all your help. I will try and let know.

Thanks once again

V
swades
Premium Member
Premium Member
Posts: 323
Joined: Mon Dec 04, 2006 11:52 pm

Post by swades »

Hi,
Is there any documents available for C-Guide( by IBM) like Basic Guide is available under "Ascential\DataStage751\Client\Docs"

Thanks
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Not that I know off. One of the primary reason being that C is widely used and has been around for many years and hence a lot of reference material can be found online.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply