Total Pageviews

July 16, 2016

7/16/2016 08:20:00 PM
Using of Decode in Sql Loader


How to use decode function in SQL*Loader to reference fields

Problem:
Based on the first field We need to load the second field data in Sql*loader.
Here is small script to acheive this


The Control file is  test.ctl


Load data
infile *
into table xxtestref
fields terminated by ',' optionally enclosed by '"'
(test1,
 test2 "decode(:test1, 'hello', 'welcome', :test1)")
begindata
hello,""
welcome,""
this is a test,""
hello,""

Here the decode function specifies if the data for test1 spells "hello" then
loads "welcome" into test2, otherwise load data from test1.

0 comments:

Post a Comment