部件功能模块代码学习

oracle在where子句中加(+) 
Oracle数据库的连接查询包括:等值连接、外连接、自连接等。
where子句中加(+) 是外连接的一种。外连接分:左外连接和右外连接。
select * from emp,dept where emp.deptno=dept.deptno(+); --右外连接
select * from emp,dept where emp.deptno(+)=dept.deptno; --左外连接

带(+)侧的数据即使不存在,另一侧的数据依然可以显示出来。

delete数据时sql语句编写

在拼接字符串时,删除语句使用where(1!=1)防止没有参数传值导致的sql语句出错

  @Override
    public void delete(List<DcDevice> list) throws ApplicationException {
            StringBuffer masterHqlBf = new StringBuffer();
        StringBuffer detailHqlBf = new StringBuffer();
        masterHqlBf.append(" delete from DcDevice where (1 != 1) ");
        detailHqlBf.append(" delete from DcDeviceAttachment where (1 != 1) ");

        for (Iterator<DcDevice> it = list.iterator(); it.hasNext();) {
            DcDevice dcDevice = it.next();
            masterHqlBf.append(" or (deviceId = '");
            masterHqlBf.append(dcDevice.getDeviceId());
            masterHqlBf.append("') ");
            detailHqlBf.append(" or (dcDevice.deviceId = '");
            detailHqlBf.append(dcDevice.getDeviceId());
            detailHqlBf.append("') ");
        }
        try {
                  execHqlUpdate(detailHqlBf.toString());
                  execHqlUpdate(masterHqlBf.toString());
        } catch (OPException ex) {
            throw new ApplicationException("删除设备失败!", ex);
        }
    }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

古柏树下

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值