oracle数据库应用总结

1------->>>>>>>>>>>>>>>>>>>>>>>>>>>>>merge into 函数的使用

MERGE INTO tb_yygl_xxplbbgl_log a  
        USING (  
              SELECT COUNT(*) COUNT
              FROM tb_yygl_xxplbbgl_log x
              WHERE  x.fund_code=#{pd.p8,jdbcType=VARCHAR} and x.bb_qj=#{pd.p9,jdbcType=VARCHAR}
          ) b  
        ON (b.count>0)  
        WHEN MATCHED THEN  
              UPDATE SET  a.beforstatus = '0',
                          a.afterstatus='1'
              WHERE a.fund_code=#{pd.p8,jdbcType=VARCHAR} and a.bb_qj=#{pd.p9,jdbcType=VARCHAR}
        WHEN NOT MATCHED THEN  
              insert (
                    ID,
                    REC_NAME,
                    CONTACT_WAY,
                    SEND_TYPE,
                    STATUS,
                    flag,
                    insert_time,
                    fund_code,
                    bb_qj,
                    bb_type,
                    <if test="pd.p11=='flagbefore'">
                      beforstatus,
                    </if>
                    <if test="pd.p11=='flagafter'">
                      afterstatus,
                    </if>
                    username
                    )
                    
             values(to_char(systimestamp,'yyyyMMddhh24missff'),
                        #{pd.p2,jdbcType=VARCHAR},
                        #{pd.p3,jdbcType=VARCHAR},
                        '1',
                        '0',
                        'inner',
                         sysdate,
                        #{pd.p8,jdbcType=VARCHAR},
                        #{pd.p9,jdbcType=VARCHAR},
                        #{pd.p10,jdbcType=VARCHAR},
                        <if test="pd.p11=='flagbefore'">
                         '0',
                        </if>
                        <if test="pd.p11=='flagafter'">
                          '1',    
                        </if>
                        #{pd.userName}            
                     )      
MERGE INTO T_EXPORT_RATE p 
                       USING (select #{pd.p2} exportrate,#{pd.p1} fund_code,#{pd.operatorRole} operatorRole,#{pd.userName}  userName from dual) np
                      ON (np.fund_code = p.fund_code)
            WHEN MATCHED THEN
                      UPDATE SET p.whetherexport='01',
                                          p.exportrate=np.exportrate,
                                            p.showdate='',
                                            p.update_date=sysdate,
                                            p.username=np.userName,
                                            p.operatorrole=np.operatorRole,
                                            p.if_holidays=''
            WHEN NOT MATCHED THEN
                     insert values (np.fund_code,'01',np.exportrate,'',sysdate,sysdate,np.userName,np.operatorRole,'') 
            

 

 

decode 函数的使用

 decode(tyxl.beforstatus,'0','发送成功',' ') beforedxstatus,

case when then else end 函数的应用

case
when (h.telephone is not null and h.email is not null) then
'0'
else
'1'
end isxpstatus

 

--复制表的操作

  create table t_fund_infobak  as select * from t_fund_info;

 

posted @ 2019-07-19 09:13  阿福聊编程  阅读(191)  评论(0编辑  收藏  举报