0

I have this loader control file.

LOAD DATA
REPLACE
INTO TABLE TEST
WHEN TEST_CD != 'A' AND TEST_CD = 'B' AND TEST_TYPE_CD = 15

Currently its loading data when TEST_CD = 'B' AND TEST_TYPE_CD = 15 but now I want to modify it so that when TEST_CD = 'B' as well as test_type_cd = 15 too.. I dont want to load all Test_type_cd when its 15.. i want to load only when it satisfies both condition.. Just keeping the braces around it is going to work.. Plz some one let me know how can I modify this..

I am thinking everyone is confused with what I need.. I want first condition to satisfy as well as 2nd and 3rd condition as 1 condition not to act seperately.. For example if test_cd is not equal A than load the data but 2nd and 3rd condition should act as one piece..when test_cd = B and test_type_cd is 15 than load the data.. i dont want test_type_cd to apply for any other test_cd other than B.. I have 5 of those test_cd A B C D E.. i want only B to apply test_type_cd = 15..

Jack
  • 785
  • 4
  • 12
  • 19
  • You mean you want to load data either TEST_CD = 'B' or TEST_TYPE_CD =5 or both? – niktrs Jul 11 '11 at 17:51
  • 1
    Your code already makes makes sure both conditions are satisfied. – Keith Jul 11 '11 at 17:52
  • i want to load data when test_cd = 'B' and for that row if test_type_cdis 15 too.. when it satisfy both conditions.. right now it doesnt care when test_cd is b test type cd is 15 or not.. if it satisfies one its loading – Jack Jul 11 '11 at 17:53
  • Also, having `TEST_CD != 'A'` is unnecessary because of `TEST_CD = 'B'`. – Keith Jul 11 '11 at 17:56
  • Can you double check that something else isn't broken? Because your syntax is correct. You're already using an `AND` operator not an `OR` operator so it's impossible for it to behave the way you have described. – Keith Jul 11 '11 at 17:58
  • wants to apply test_type_cd = 15 only to test_cd B.. i dont want to apply it to other test_cd C D E that i have – Jack Jul 11 '11 at 18:16
  • OR is not an option in SQL loader – niktrs Jul 11 '11 at 18:18
  • Jack, thanks for the clarification. +1 for niktrs solution below. – Keith Jul 11 '11 at 18:19

2 Answers2

2

Try

LOAD DATA
REPLACE
INTO TABLE TEST
WHEN TEST_CD = 'B' AND TEST_TYPE_CD = 15 -- load everything that is b and 15
INTO TABLE TEST
WHEN TEST_CD != 'A' AND TEST_CD != B -- load everything that is not a and not b (because it is loaded above)
niktrs
  • 9,858
  • 1
  • 30
  • 30
0

So, you want it to load in when EITHER condition is true, not necessarily BOTH conditions?

WHEN TEST_CD != 'A' AND (TEST_CD = 'B' OR TEST_TYPE_CD = 15)

may satisfy the fractured English of your initial question.

Andy Finkenstadt
  • 3,547
  • 1
  • 21
  • 25