Varzone Technology

Unix,Oracle,Pl/SQL and more

Thursday, January 10, 2008

Convert Date format in Unix (ddmmyyyy to dd-mon-yyyy )

Could not find an inbuilt function in unix to convert ddmmyyyy to dd-mon-yyyy format.So wrote this script. Check this out.

month_mon='JAN+FEB+MAR+APR+MAY+JUN+JUL+AUG+SEP+OCT+NOV+DEC'
time_stamp='01012007' #&1
dd=`echo $time_stamp (pipe) cut -c5-6`
mm=`echo $time_stamp (pipe) cut -c3-4`
yy=`echo $time_stamp (pipe) cut -c1-2`
file_mon=`echo ${month_mon} (pipe) cut -d"+" -f${mm}`
file_date=$file_dd'-'${file_mon}'-20'${file_yy}
echo $file_date


NOTE: The pipe symbol before cut is getting filtered out in this blog. Please take care to replace (pipe) with the actual one.

Sunday, November 11, 2007

OWB File Operators

Ø File Operators

1) SQL loaders are created in OWB using file operators. Simple mappings work fine with file operators.
But if there is an expression operator also in the mapping, it is seen that the CTL file that gets created has the field names wrong. The code will still work correctly as the file positions will remain the same.

Solution

The only solution seems to be manually changing the CTL file.

2) Another issue with this operator is that the mapping will throw errors if we try to map the same source column from the file to different target columns.

Solution


One work around to this problem is to use an expression operator and map one of the source columns through the expression operator so that we have one mapping directly from the file column to the target column and another one which moves through the expression operator to the target column.

3) Before using a file operator we need to create a file in OWB by sampling the actual input file. The process allows us to specify the file type (delimited, fixed length) column length, data types etc. It is found that while we can easily sample a single delimited file (eg: - 001,Emp_name,13232,…) OWB does not allow us to sample a file which has multi character delimiters (eg:- 001~~EMP_name~~13245).

Solution

As the sampling interface simply won’t accept multi character delimiters, we need to sample the file using a single delimiter.
But when the file operator is imported into the mapping we can use the properties window to edit the delimiter. In the above example, after sampling the file using a single character delimiter, we will have the file operators delimiter field attribute having the value ~.This needs to be replaced with ‘~~’.

It is also noticed that after sampling the file operators may not get the correct precision or data type as in the file. We have to manually make sure that all the attributes have the correct data types and length.

Blog Archive