`
pouyang
  • 浏览: 313271 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

数据库 sql存储过程

SQL 
阅读更多
create or replace procedure tets(a in varchar2, b  out varchar2) is
 v varchar2(20);
begin
  if a <= 7000 then dbms_output.put_line('ok');
  end if;
  exception 
     when case_not_found then
       dbms_output.put_line('有异常了');
end tets;



CREATE OR REPLACE PROCEDURE xxxx.GETSEQ (in_seqid in varchar,  in_num in  int, out_seq out int)
	as
BEGIN
    DECLARE
    db_sqlcode INTEGER;
    db_seq   INTEGER;
    BEGIN
    	UPDATE xxxx.T_SEQ SET seq = seq+1 WHERE trim(id)=in_seqid;
    	--db_sqlcode := SQLCODE; -- 
      db_sqlcode := sql%rowcount;
      --Dbms_output.put_line(db_sqlcode);
    	IF (db_sqlcode <> 0)
	        THEN
	    	 select seq into db_seq from xxxx.T_SEQ where TRIM(ID)=in_seqid;
		     out_seq:=db_seq;
		ELSE IF (db_sqlcode = 0)

		THEN
		       INSERT INTO xxxx.T_SEQ(id,seq,detail) VALUES(in_seqid,0,' ');
		       out_seq := 0;
		END IF;
	    END IF;
	     UPDATE xxxx.T_SEQ SET seq = seq+in_num WHERE trim(id)=in_seqid;
	END;
END;

 

 

 

 

create or replace procedure "xxx".TEST
	as 
BEGIN 
    DECLARE 
    db_sqlcode INTEGER; 
    db_seq   INTEGER; 
    BEGIN 
      Dbms_output.put_line(db_sqlcode); 
      for tttt in ( select t_order.rpid,t_order.platorderid from xxx.T_ORDER t_order where  t_order.rpid !=  ' '  ) loop
      update  xxx.T_TRANS a  set a.BANKPRIV = tttt.platorderid  where a.rpid = tttt.rpid;
      dbms_output.put_line(tttt.platorderid);
      end loop;
	END; 
END;

 
sql%rowcount=0不是异常处理的语句,是判断sql语句操作的行数(影响的行数)。

if sqlcode<>0 。。。是判断SQL语句是否成功  0 成功 -1等就是出错,或是其

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics