Recipe 4.10. Updating with Values from Another Table

Problem

select *
  from new_sal


DEPTNO        SAL
------ ----------
    10       4000

Column DEPTNO is the primary key of table NEW_SAL. You want to update the salaries and commission of certain employees in table EMP using values table NEW_SAL if there is a match between EMP.DEPTNO and NEW_SAL.DEPTNO, update EMP.SAL to NEW_SAL.SAL, and update EMP.COMM to 50% of NEW_SAL.SAL. The rows in EMP are as follows:

	
	select deptno,ename,sal,comm
	  from emp
	 order by 1

	DEPTNO ENAME             SAL       COMM
	------ ---------- ---------- ----------
	    10 CLARK           2450            
	    10 KING            5000
	    10 MILLER          1300
	    20 SMITH            800
	    20 ADAMS           1100
	    20 FORD            3000
	    20 SCOTT           3000
	    20 JONES           2975
	    30 ALLEN           1600         300
	    30 BLAKE           2850
	    30 MARTIN          1250        1400
	    30 JAMES            950
	    30 TURNER          1500           0
	    30 WARD            1250         500


 

Solution
	1 update emp e set (e.sal,e.comm) = (select ns.sal, ns.sal/2
	2                                      from new_sal ns
	3                                     where ns.deptno=e.deptno)
	4  where exists ( select null
	5                   from new_sal ns
	6                  where ns.deptno = e.deptno )
------------------
	1 update (
	2  select e.sal as emp_sal, e.comm as emp_comm,
	3         ns.sal as ns_sal, ns.sal/2 as ns_comm
	4    from emp e, new_sal ns
	5   where e.deptno = ns.deptno
	6 ) set emp_sal = ns_sal, emp_comm = ns_comm



 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23895263/viewspace-681076/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/23895263/viewspace-681076/

给定的参考引用中未提及项目构建时出现'Recipe terminated with error'错误的解决方案。一般而言,此错误通常表示在构建过程中某个步骤失败,以下是一些常见的解决思路和办法: ### 检查编译日志 查看详细的编译日志,定位具体出错的命令和文件。例如,查看${T}/log.do_compile文件,从中找到错误的具体信息,像缺少头文件、语法错误等情况。 ```bash DEBUG: Executing shell function do_compile gcc -o example main.c main.c: fatal error: stdio.h: No such file or directory compilation terminated. ``` 若日志显示缺少头文件,就需要安装相应的开发包。 ### 清理缓存并重新构建 有时候,旧的缓存文件可能会引发构建问题。可以清理项目的缓存文件,然后重新构建项目。以openvslam为例: ```bash rm -rf build/ mkdir build && cd build cmake -DUSE_PANGOLIN_VIEWER=ON -DINSTALL_PANGOLIN_VIEWER=ON -DUSE_SOCKET_PUBLISHER=OFF -DUSE_STACK_TRACE_LOGGER=ON -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON .. make -j6 sudo make install ``` ### 检查依赖项 确保项目所需的所有依赖项都已正确安装。若使用了一些库,要保证这些库的版本兼容。例如,安装PCL时,若编译时间较长,可采用无图界面编译: ```bash sudo systemctl set-default graphical.target sudo systemctl set-default multi-user.target sudo reboot ``` ### 检查CMake配置 若项目使用CMake进行构建,要确保CMakeLists.txt文件配置正确。若CLion新建c++项目报错,可能是CMake无法正确生成项目: ```plaintext CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:2 (project) ``` 此时需要检查CMakeLists.txt文件的语法和配置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值