Merge Query

1. Oracle:

"MERGE into MHGROUP.proj_access m using dual on " +
    "(PRJ_ID = '" + WS_PrjID + "' AND USER_GP_ID = '" + smrIDs[i] + "')" +
        "when not matched then " +
            "insert (PRJ_ID,OBJECT_TYPE,USER_GP_ID,ACCESS_RIGHT) " +
                    "values ('" + WS_PrjID + "','U','" + smrIDs[i] + "','" + accessLevel + "')" +
        "when matched then " + 
                "update set ACCESS_RIGHT = '" + accessLevel + "'";

 

2. MSSQL:

insert into customer_info(company_name,customerid,status)

    Select 'abc','CD',1 

Where not exists(select * from customer_info where cid=2)

 

posted @ 2016-07-26 13:41  木子执手  阅读(324)  评论(0编辑  收藏  举报