SQL compilation error: Expression type does not match column data type, expecting VARIANT but got VARCHAR(3038) for column ATTRIBUTES. Can someone help to correct the query?
MERGE INTO "W_TESTTABLE" T USING (SELECT * FROM (VALUES ('{"type":"issue__c", "url":"/services/data/v42.0"}','a0E2v00001jiirTEAQ','00590000005myFsAAI','false','test account','2019-12-18T14:15:06.000000+05:30','00590000005myFsAAI','2019-12-18T14:15:06.000000+05:30','00590000005myFsAAI','2019-12-18T14:15:06.000000+05:30',NULL,'2019-12-18T14:15:07.000000+05:30','2019-12-18T14:15:07.000000+05:30',NULL,NULL,NULL,NULL,NULL) AS UNUSED_ALIAS ("ATTRIBUTES","ID","OWNERID","ISDELETED","NAME","CREATEDDATE","CREATEDBYID","LASTMODIFIEDDATE","LASTMODIFIEDBYID","SYSTEMMODSTAMP","LASTACTIVITYDATE","LASTVIEWEDDATE","LASTREFERENCEDDATE","ASSIGNED_BY__C","FIELD11111111111111111111111111111111111__C","RFIELD1111111111111111111111111111111111__C","ISSUE_ID__C","ORDERSTEST__C"))) S ON (T."ID" = S."ID") WHEN MATCHED THEN UPDATE SET T."ATTRIBUTES"=S."ATTRIBUTES",T."OWNERID"=S."OWNERID",T."ISDELETED"=S."ISDELETED",T."NAME"=S."NAME",T."CREATEDDATE"=S."CREATEDDATE",T."CREATEDBYID"=S."CREATEDBYID",T."LASTMODIFIEDDATE"=S."LASTMODIFIEDDATE",T."LASTMODIFIEDBYID"=S."LASTMODIFIEDBYID",T."SYSTEMMODSTAMP"=S."SYSTEMMODSTAMP",T."LASTACTIVITYDATE"=S."LASTACTIVITYDATE",T."LASTVIEWEDDATE"=S."LASTVIEWEDDATE",T."LASTREFERENCEDDATE"=S."LASTREFERENCEDDATE",T."ASSIGNED_BY__C"=S."ASSIGNED_BY__C",T."FIELD11111111111111111111111111111111111__C"=S."FIELD11111111111111111111111111111111111__C",T."RFIELD1111111111111111111111111111111111__C"=S."RFIELD1111111111111111111111111111111111__C",T."ISSUE_ID__C"=S."ISSUE_ID__C",T."ORDERSTEST__C"=S."ORDERSTEST__C" WHEN NOT MATCHED THEN INSERT ("ATTRIBUTES","ID","OWNERID","ISDELETED","NAME","CREATEDDATE","CREATEDBYID","LASTMODIFIEDDATE","LASTMODIFIEDBYID","SYSTEMMODSTAMP","LASTACTIVITYDATE","LASTVIEWEDDATE","LASTREFERENCEDDATE","ASSIGNED_BY__C","FIELD11111111111111111111111111111111111__C","RFIELD1111111111111111111111111111111111__C","ISSUE_ID__C","ORDERSTEST__C") VALUES (S."ATTRIBUTES",S."ID",S."OWNERID",S."ISDELETED",S."NAME",S."CREATEDDATE",S."CREATEDBYID",S."LASTMODIFIEDDATE",S."LASTMODIFIEDBYID",S."SYSTEMMODSTAMP",S."LASTACTIVITYDATE",S."LASTVIEWEDDATE",S."LASTREFERENCEDDATE",S."ASSIGNED_BY__C",S."FIELD11111111111111111111111111111111111__C",S."RFIELD1111111111111111111111111111111111__C",S."ISSUE_ID__C",S."ORDERSTEST__C")
I tried doing PARSE_JSON for VALUES something like this
MERGE INTO "W_TESTTABLE" T USING (SELECT * FROM (VALUES (PARSE_JSON('{"type":"issue__c", "url":"/services/data/v42.0"}')....
but got an error Invalid expression [PARSE_JSON('{"type":"issue__c", "url":"/services/data/v42.0/sobjects/issue__c/a0E2v00001jiirTEAQ"}')] in VALUES clause:
I am able to do insert query succesfully
INSERT INTO DEMO_DB.public.W_TEST(ID, ATTRIBUTES) SELECT 2, PARSE_JSON('{"first_name":"Mickey","last_name":"Mouse"}')
But my requirement is a MERGE query
Table schema Schemapart1