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)
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)