2013. 4. 22. 14:51

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

Oracle/DB22010. 9. 10. 11:28


/*--------------------------------------------------------------------------------------------------*/
Transaction          SQLSP

SQLSP = create Transaction
SQLSP.DBMS = "ODBC"
SQLSP.AutoCommit = False

SQLSP.DBParm =  "ConnectString='DSN=" + gs_system + ";UID="+ gs_emp_no +";PWD="+ gs_password + "'"

CONNECT using SQLSP;

//SQLSP Connection Check!
if SQLSP.sqlcode <> 0 then
 Messagebox ( 'SERVER CONNECT ERROR', 'Connect Fail' + " Connection Error" )
 Return
end if

//Stored Procedure 실행
DECLARE SP_USER_ENABL PROCEDURE FOR SP_USER_ENABL(:ls_nno, :ls_rst, :ls_msg) using SQLSP;
EXECUTE SP_USER_ENABL;

DISCONNECT using SQLSP;

Posted by Julyus
Oracle2009. 9. 21. 11:42
PROCEDURE Sample oracle 

2009/09/02 00:04

복사http://blog.naver.com/delcom/80087374247

DROP   PROCEDURE Proc_master;
CREATE PROCEDURE Proc_master
  (sSIPNUM in  varchar2)
IS
begin
    begin
      insert into imms.mc_comsip_m
        (SIPNUM) values (sSIPNUM);
    exception
       when DUP_VAL_ON_INDEX then -- key 중복 error 일 경우 update 수행
            rollback; 
            raise_application_error(-20502, 'insert other error...DUP');
       when OTHERS then
            rollback;
            raise_application_error(-20502, 'insert other error...');         
    end;  
--    begin
    
--    end; 
        
END Proc_master;

 

==========================================================================================

DROP   PROCEDURE Proc_test;
CREATE PROCEDURE Proc_test
  (sPJTCOD     in  varchar2,
   sSTART_YM   in  varchar2,
   sPRLCOA     in  varchar2,
   sPRICOD     in  varchar2,
   sP_EMPNO    in  varchar2,
   sMsg       out varchar2)
IS
  sOPTTYP varchar2(10);


CURSOR  M1 IS
  select OPTTYP from imms.MC_POSUM_D
   where PJTCOD   = sPJTCOD  
     and START_YM = sSTART_YM
     and PRLOCA   = sPRLCOA  
     and PRICOD   = sPRICOD  
     and P_EMPNO  = sP_EMPNO;
begin    

  begin
    Insert into imms.MC_POSUM
      (select * from imms.MC_POSUM
        where PJTCOD   = sPJTCOD  
          and START_YM = sSTART_YM
          and PRLOCA   = sPRLCOA  
          and PRICOD   = sPRICOD  
          and P_EMPNO  = sP_EMPNO);
          
  end;


  open M1;
  Loop
    FETCH M1
      into sOPTTYP;

      begin    
        Insert into imms.MC_POSUM_D
          (select * from imms.MC_POSUM_D     
            where PJTCOD   = sPJTCOD       
              and START_YM = sSTART_YM     
              and PRLOCA   = sPRLCOA       
              and PRICOD   = sPRICOD       
              and P_EMPNO  = sP_EMPNO
              and OPTTYP   = sOPTTYP);    
     exception
       when DUP_VAL_ON_INDEX then -- key 중복 error 일 경우 update 수행
            rollback; 
            raise_application_error(-20502, 'insert other error...DUP');
            sMsg := '-20502, insert other error...';
       when OTHERS then
            rollback;
            raise_application_error(-20502, 'insert other error...');         
            sMsg := '-20502, insert other error...';
     end;
      
  End Loop;      
  Commit;
  
close M1;

        
END Proc_test;

==========================================================================================

      

PROCEDURE SAMPLE_TEST IS
  aa varchar2(10) := 'test';
  bb varchar2(10) := 'test1';
  cc varchar2(10) := 'test2';
BEGIN
  begin
     insert into test_tab(a, b, c)
     values (aa, bb, cc);
  exception
       when DUP_VAL_ON_INDEX then -- key 중복 error 일 경우 update 수행
            begin
               update test_tab
                  set b = bb,
                      c = cc
                where a = aa;
            exception
                 when OTHERS then -- 기타 error 일 경우
                      raise_application_error(-20501, 'update error...');         
            end;
       when OTHERS then
            rollback;
            raise_application_error(-20502, 'insert other error...');         
  end;
END;

Posted by Julyus
Oracle2009. 9. 17. 11:02
별거 아닌데, 이거 만든다고 하룻밤을 꼬박 샜다;;;
ㅎㅎㅎ ;;;
나중에 보면 기분이 새로울거 같아 올려놓는다;

Posted by Julyus