linux shell使用loop和cursor批量修改sql
来源:互联网 发布:linux下的网络编程 编辑:程序博客网 时间:2024/06/15 16:06
USER="zhangsan"PWD="123456"DBNAME="JTP"sqlplus ${USER}/${PWD}@${DBNAME}<<EOFdeclare #定义游标并赋值cursor 与is一起使用 cursor stu_cur is select * from tbstudents; #定义类型rowtype,stu_row用户获取表字段值 stu_row tbstudent%rowtype #开始执行 begin #打开游标 open stu_cur #开始循环 loop #退出循环结束条件 exit when stu_cur%notfound #将游标的值赋值到rowtype fetch stu_cur into stu_row #更新表字段,将没有身份证的学生状态置位0(不正常) update set status='0' where name=stu_row.name and id_code=' '; #或者使用下面sql,,更高效; if stu_row.id_code = ' ' then update student set status='0' where name=stu_row.name; elsif stu_row.id_kind = ' ' then update student set status='0' where name=stu_row.name; elsif stu_row.name = ' ' or stu_row.sex = ' ' then update student set status='0' where name=stu_row.name; end if; #结束循环 end loop; #关闭游标 close stu_cur; end;EOF
- 1.sqlplus
- 2.delcare
- 3.cursor
- 4.begin
- 5.open cursor
- 6.loop
- 7.exit
- 8.fetch
- 9.sql
阅读全文
0 0
- linux shell使用loop和cursor批量修改sql
- [PL/SQL] 用For Loop 替代Cursor
- [PL/SQL] 用For Loop 替代Cursor
- pl/sql 中for和while循环([PL/SQL] 用For Loop 替代Cursor)
- Cursor Loop
- Cursor Loop
- linux shell----for Loop
- linux shell ----while Loop
- linux批量修改文件后缀名shell脚本
- linux批量修改文件后缀名shell脚本
- linux批量修改文件字符集shell 脚本
- linux下shell批量修改文件后缀名
- MySql CURSOR+LOOP循环-使用小实例
- 使用shell管理linux下账号批量添加和批量删除
- linux下使用shell批量修改文件名几种方法总结
- 【Linux】使用sed、awk来完成批量修改配置文件的shell设计
- shell批量修改文件名
- shell批量修改文件名
- [ARM-Linux]Linux-MATLAB安装
- matlab的findobj函数
- 沧田TS618K打印机驱动官方版下载
- 【hdu 1863】 畅通工程
- C/C++使用NotePad++DIY一个IDE
- linux shell使用loop和cursor批量修改sql
- 静态代码块的执行顺序
- POJ 2406 Power Strings(后缀数组或KMP或扩展KMP)
- 在Matlab下利用VS调试C/C++代码
- Linux系统Java环境安装配置
- 方格取数(1) HDU
- 传入一个字符串,输出某个字符或者字符串在传入字符串中的所有位置
- 11.2
- CVPR 2017 全部及部分论文解读集锦