Oracle 存储过程 删除表记录时删除不存在的记录也是显示删除成功 create or replace procedure delDept(p_deptno in dept.deptno%type) is begin delete from dept where deptno=p_deptno; dbms_output.put_line('部门删除成功...'); exception when others then dbms_output.put_line('部门删除失败...'); en…
sql%rowcount用于记录修改的条数,就如你在sqlplus下执行delete from之后提示已删除xx行一样,这个参数必须要在一个修改语句和commit之间放置,否则你就得不到正确的修改行数. 例如: declare n number; begin insert into test_a select level lv from dual connect by level<500; n:=sql%rowcount; commit; dbms_output.put_line(n); end…
sql server中,返回影响行数是:If @@RowCount<1 Oracle中,返回影响行数是:If sql%rowcount<1 例: sqlserver: create procedure Proc_test , )='', AS BEGIN Update T_Mt Set Stat=@Stat,OStat=@Stat,RptTime=Getdate() Where MsgId=@MsgId --没有更新成功就插入到t_Statbuf insert into t_statbuf(M…
oracle中.返回影响行数是:If sql%rowcount 举例: update ut_calenderStatus t set t.calenderstatus=pi_flg, t.m=pi_M, t.n=pi_N, t.prolong=pi_prolong where t.fundcode=pi_fundcode; if sql%rowcount=0 then insert into ut_calenderStatus values (pi_fundcode,pi_flg,pi_M,pi…
@@Rowcount主要是返回上次sql语句所影响的数据行数 SELECT * FROM dbo.Region AS R SELECT @@rowcount SELECT @@rowcount --我们可以使用@@rowcount来作递归或循环 begin select * from Region where id=@n end…
get diagnostics cnt := row_count; 现在有两个表tab1和tab2,两个表的格式相同,tab1中有1000条数据,tab2中0条数据 创建测试功能函数 create or replace function test_fun() return integer as $body$ declare rowcnt integer; begin insert into tab2 select * from tab1; get diagnostics rowcnt := ro…
PL/SQL 基础 ( 下 ) 1. PL/SQL中的 SQL语句 - END语句与COMMIT等内容,没有任何关系. - PL/SQL does not directly support data definition language( DDL ) statements, such as CREATE TA BLE, ALTER TABLE, or DROP TABLE. - PL/SQL does not support data control language( DCL ) sta…
DDL commands --> create user / table / view / sequence alter DML --> data manipulation language (insert, select, update, delete) eg : SELECT ename FROM emp WHERE sal = (SELECT MAX(sal) FROM EMP); %type(single col), %rowtype(single row/record) cursor…