All Forums Database
suresh_1644 1 post Joined 06/10
21 Jun 2010
Regarding upsert

Please help me regarding the upsert command in Teradata.
i found some points regarding the upsert in Teradata.
Please confirm me if the below comments correct or not.if correct please
privide the syntax for upsert command
-- Insert statement should not containt SELECT Statement
-- Update Statement should not contain subquery
-- Update statement may not reference another table for updates

Thanks & Regards,
Suresh Babu Ch.

Ch Suresh Babu
Adeel Chaudhry 773 posts Joined 04/08
22 Jun 2010

Hi,

Logically putting UPSERT in one line: If the row exists (same PK), it'll update, if not it'll insert.

Example is as follows:

MERGE INTO
Table1 AS tt
USING
Table1_tmp AS st
ON
tt.PK_Col=st.PK_Col
WHEN MATCHED THEN UPDATE
SET
Col1=st.Col1,
Col2=st.Col2
WHEN NOT MATCHED THEN
INSERT
(
st.PK_Col,
st.Col1,
st.Col2
)
;

For further documentation over it, please refer to documentation.

Regards,

MAC

-- If you are stuck at something .... consider it an opportunity to think anew.

You must sign in to leave a comment.