Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: Table Insert/Update only when field is NULL

Started 3 weeks, 6 days ago by dibe0015
Hi, I'm trying to create a transformation to update a table. But every single field should only be update when the current value is NULL so I don't loose existing data. Here is an example: Table: has the format id last_name first_name email Some data in the table: 1,Miller,Brat,NULL 2,NULL,Daemon,matt@daemon.com If I get the following input data: 1,...
Site: Pentaho Community Forums  Pentaho Community Forums - site profile
Forum: Data Integration / ETL  Data Integration / ETL - forum profile
Total authors: 3 authors
Total thread posts: 6 posts
Thread activity: no new posts during last week
Domain info for: pentaho.org

Other posts in this thread:

DEinspanjer replied 3 weeks, 6 days ago
I'd suggest looking at the following steps: 1. Get sorted data from table 2. Get sorted new data 3. Join #1 and #2 with a Merge Diff Step 4. Filter the Joined data for only changed records 5. Calculator step using NVL to get the non-null value for every field (if it exists) 6. Update step inserting your NVLed fields

dibe0015 replied 3 weeks, 3 days ago
Hi, thanks for your answer. I'll give that a try this week. Benjamin

dibe0015 replied 3 weeks, 3 days ago
Hi, thanks for your answer. I'll give that a try this week. Benjamin

dibe0015 replied 3 weeks, 1 day ago
Hi, I tried it out and i think I got it to work. I first tried the Merge Diff step but the way you described it you'll only have the new/changed row without knowing what the original value was. Using the "Merge Join" step solved the problem. I now have old and new data together and can use the calculator step. It gives me the desired result. I added a screenshot in case someone else will run...

vlr replied 3 weeks, 1 day ago
you can also do a Execute SQL Script: update tableA set last_name = decode(last_name, null, '?', last_name), first_name = decode(first_name, null, '?', first_name) , email = decode(email,null,'?',email) where id = ? Enable "Execute for each row" & "Variable substitution"

 

Top contributing authors

Name
Posts
dibe0015
4
user's latest post:
Table Insert/Update only when...
Published (2009-11-11 16:11:00)
Hi, I tried it out and i think I got it to work. I first tried the Merge Diff step but the way you described it you'll only have the new/changed row without knowing what the original value was. Using the "Merge Join" step solved the problem. I now have old and new data together and can use the calculator step. It gives me the desired result. I added a screenshot in case someone else will run into the same issue. Thanks...
DEinspanjer
1
user's latest post:
Table Insert/Update only when...
Published (2009-11-07 02:46:00)
I'd suggest looking at the following steps: 1. Get sorted data from table 2. Get sorted new data 3. Join #1 and #2 with a Merge Diff Step 4. Filter the Joined data for only changed records 5. Calculator step using NVL to get the non-null value for every field (if it exists) 6. Update step inserting your NVLed fields
vlr
1
user's latest post:
Table Insert/Update only when...
Published (2009-11-11 18:45:00)
you can also do a Execute SQL Script: update tableA set last_name = decode(last_name, null, '?', last_name), first_name = decode(first_name, null, '?', first_name) , email = decode(email,null,'?',email) where id = ? Enable "Execute for each row" & "Variable substitution"

Related threads on "Pentaho Community Forums":

Related threads on other sites:

Thread profile page for "Table Insert/Update only when field is NULL" on http://www.pentaho.org. This report page is a snippet summary view from a single thread "Table Insert/Update only when field is NULL", located on the Message Board at http://www.pentaho.org. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity