Hi Below are the steps I followed to implement merge with stream in snowflake 1.created a table create or replace table employees(employee_id number, salary number, manager_id number); 2. Created stream. create or replace stream employees_stream on table employees; 3. created consumer table. create or replace table employees_consumer(employee_id number, salary number,manager_id number); 4. I inserted some records in employees table. insert into employees values(8,40000,4), (12,50000,9), (3,30000,5), (4,10000,5), (25,35000,9); 5.While trying to execute below command I am getting error. MERGE INTO EMPLOYEES_CONSUMER AS A USING (SELECT * FROM EMPLOYEES_STREAM WHERE NOT (METADATA$ACTION= 'DELETE' AND METADATA$ISUPDATE=TRUE)) AS B ON A.EMPLOYEE_ID=B.EMPLOYEE_ID WHEN MATCHED AND b.METADATA$ACTION= 'INSERT' AND b.METADATA$ISUPDATE THEN UPDATE SET A.EMPLOYEE_ID =B.EMPLOYEE_ID, A.SALARY=B.SALARY, A.MANAGER_ID=B.MANAGER_ID WHEN MATCHED AND b.METADATA$ACTION= 'DELETE' THEN DELETE WHEN NOT MATCHED AND b. METADATA$ACTION= 'INSERT' THEN INSERT INTO (EMPLOYEE_ID,SALARY,MANAGER_ID) VALUES (B.EMPLOYEE_ID,B.SALARY,B.MANAGER_ID); Error is: "SQL compilation error: syntax error line 15 at position 8 unexpected 'INTO'." Please help on this.
0
votes