Home Page for the TeradataForum

Archives of the TeradataForum

Message Posted: Fri, 12 May 2005 @ 23:12:04 GMT

  <Prev Next>   <<First <Prev Next> Last>>  

Subj:   Re: Using MLoad to update several columns
From:   McCall, Glenn David

You might try using a case statement

     update employee
     set first_name = :first_name,
        last_name = case when last_name = 'abcd' then :last_name else last_name
     where emp_id = :emp_id;

I would also encourage you to look at conditional apply statements (although it won't work for your example) - refer to .import in the mload manual.

With these you can do something like this

     .import blah blah blah
         APPLY update_both_names where :last_name = 'abcd'
         APPLY update_firt_name_only where :last_name <> 'abcd';

This might be overkill for this example, but you can do things like load data into different tables.

This conditional apply is tested against the incoming data from your data source not data already in the database. It doesn't check content that is already in the database. So if the last_name was 'abcd' in the data source, you could use conditional apply's to control what tables were updated according to whatever rules you needed.

Hope this helps.

Glenn Mc

  <Prev Next>   <<First <Prev Next> Last>>  
  Top Home Privacy Feedback  
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023