最近在做Sql到Oracle的移植工作,由于Oracle中没有像Sql 里那样的Identity列,所以遇到很多麻烦,最近遇到了一个要根据自增列的值删除数据的存储过程,弄了半天找到了一种方法。
- /*在Oracle中的操作过程*/
-
- --创建表,由于Oracle中没有identity,所以去掉aid列,在后面使用rownum
- create table TempTable (
- SearchID number(10,0)
- )
-
- --删除Rownum为5的值
-
- declare cursor tmp_cursor is select rownum aid,searchid from TempTable for update;
- tmp_record tmp_cursor%rowtype;
- begin
- open tmp_cursor;
- loop
- fetch tmp_cursor into tmp_record;
- exit when tmp_cursor%notfound;
-
- if(tmp_record.aid=5)--如果rownum为5
- then
- begin
- delete TempTable where current of tmp_cursor;
- end;
- end if;
- end loop;
- close tmp_cursor;
- commit;
- end;
Oracle教程:ORA-02292和ORA-02297Oracle 层次查询-学习笔记相关资讯 Oracle教程
- Oracle中纯数字的varchar2类型和 (07/29/2015 07:20:43)
- Oracle教程:Oracle中查看DBLink密 (07/29/2015 07:16:55)
- [Oracle] SQL*Loader 详细使用教程 (08/11/2013 21:30:36)
| - Oracle教程:Oracle中kill死锁进程 (07/29/2015 07:18:28)
- Oracle教程:ORA-25153 临时表空间 (07/29/2015 07:13:37)
- Oracle教程之管理安全和资源 (04/08/2013 11:39:32)
|
本文评论 查看全部评论 (0)