Page 1 of 1

Upper Case Conversion

Posted: Mon Mar 29, 2004 12:45 am
by dhiraj
Hi,

Is it possible to convert the entire input record read from a sequential file in to upper case. i am aware of the UpCase function, but if i use this i'll have to apply this funtion for each and every field. isn't there any generic way in which i can apply this to athe entire incoming record at once.

also i have some 100 odd jobs for which i have to convert all the inputs in to upper case . is there any other easier way of doing this.
mass relace or something.

thanx

dhiraj

Posted: Mon Mar 29, 2004 12:53 am
by roy
Hi,
You can convert the entire row in 2 ways:
1. run a batch script to do it, or a basic routine that reads the entire file and converts it (this might have issues if you use NLS).

2. define the max length of your row and define a seq file stage to have 1 column of varchar(<max length>) and simply use the upper case function on the entire row.

If you choose the 2nd option you need to write it to a seq file and continue from there, or use a filed(...) function to brake down the string to the actual columns in a transformer.

IHTH,

Posted: Mon Mar 29, 2004 1:49 am
by ray.wurlod
DataStage is perfectly at home with the idea of case under NLS. Definition of what is upper case and what is lower case and how to get from one to the other and back again are all part of the CTYPE category of the locale. For example, accented lower case letters lose their accents when converted to upper case in France, but keep their accents in Canada.

So a simple before-stage subroutine might go something like:

Code: Select all

OpenSeq filepath1 To InFileVar
Then
   OpenSeq filepath2 To OutFileVar
   Then
      WeofSeq OutFileVar  ; * overwrite if exists
   End
   Else
      If Status() Then GoTo CloseDown
   End
   Loop
   While ReadSeq Line From InFileVar
      WriteSeq Upcase(Line) To OutFileVar Else NULL
   Repeat
CloseDown:
   CloseSeq OutFileVar
   CloseSeq InFileVar
End
Error and "locked file" processing has been omitted for clarity. Your job would then process filepath2 rather than filepath1.