Skip to content

Instantly share code, notes, and snippets.

@Benjit87
Created July 30, 2013 08:36
Show Gist options
  • Save Benjit87/6111288 to your computer and use it in GitHub Desktop.
Save Benjit87/6111288 to your computer and use it in GitHub Desktop.
Simple Datastage Custom C++
APT_TimeStamp dateofbirth(in0.Dob,"%yyyy%mm%dd%hh%nn%ss%SSSSSS",true); // APT_Timestamp to convert char to timestamp (see the reference card for more info)
if ( !dateofbirth.isValid() ) { recOk = false; } else { out0.Dob = dateofbirth;} // check if the current record contains a valid timestamp
out0.Name = in0.Name; // assign the column from the 1st input port to the 1st output port which is the results port
out0.Country = in0.Country;
if ( lowercase == "yes" ) { out0.Country.toLower(); } // if the string property (as defined in the property tab) of lowercase is yes , output should be lowercase
out0.Region = in0.Region;
out0.Region.trimWhitespaceLeadingTrailing(); //this is actually a datastage macro, you can use setPadChar and trimPadding to trim (see reference card). To see how to conversion (using some C precompilers) is being applied you can take a look at the generated C++ code after generation
if ( in0.Mobile.length() == 0 )
{ } //do nothing it will be set as null automatically or u can use macro e.g out0.Mobile_setnull();
else { out0.Mobile = in0.Mobile; }
if ( recOk ) // if valid
{writeRecord(0);} // Write to Port 0 which is input_test
else
{transfer(1);writeRecord(1);} // Propagate the columns from input_test to err_test (Port 1) and Write to Port 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment