Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

Updating data in a table for multiple records from a file using Import - response (3) by thisisKumar

$
0
0

 

Thanks, Dieter.

MERGE INTO function is reqally useful for me in this case when I have only couple records.

But, can we use this MERGE INTO along with INSERT INTO?

I wanted to update else insert a table from a file.

 

CREATE TABLE KUMAR_TEST

(cust_ky INTEGER, fname VARCHAR(30), lname VARCHAR(50))

PRIMARY INDEX(cust_ky);

 

INSERT INTO KUMAR_TEST VALUES(1,'abc','def');

 

MERGE INTO KUMAR_TEST USING

VALUES(1,'pqr','xyz')

AS kk(a,b,c)

ON cust_ky=kk.a

WHEN MATCHED THEN 

UPDATE

SET fname=kk.b

,lname=kk.c

WHEN NOT MATCHED THEN

INSERT VALUES(kk.a,kk.b,kk.c)

--------

 

MERGE INTO KUMAR_TEST USING

VALUES(?,?,?) --how to take values from a file

AS kk(a,b,c)

ON cust_ky=kk.a

WHEN MATCHED THEN 

UPDATE

SET fname=kk.b

,lname=kk.c

WHEN NOT MATCHED THEN

INSERT VALUES(kk.a,kk.b,kk.c)

 


Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>