Cai on Exception?

Este forum é dedicado a códigos errados que se encontram por aí, ou seja, coisas que não se deve fazer de jeito nenhum! Não coloque neste forum dúvidas! (apenas situações bizarras do nosso dia a dia :-)
Post Reply
gokden
Rank: DBA Pleno
Rank: DBA Pleno
Posts: 264
Joined: Sun, 19 Aug 2007 8:18 pm
Location: Ribeirão Preto - SP
Lucas de Souza

OCA Developer
Analista de sistemas

Good .... I was giving maintenance in a program here and found this:

Select all

   begin 
      vn_flag := 17; 
      :bl_empr_usu.v_perm_fat_nf_venc  := fg_param_adm( 'PERM_NF_TIT_VENC_MEN' 
                                                      , 'FAT' 
                                                      , :global.emprusu 
                                                      , 0  -- deve obrigatóriamente existir na cg_ref_code 
                                                      ); 
   exception 
   when vê_insere_r then 
      pl_variaveis.vv_insere_r := 'S'; 
      if vn_flag = 17 then 
         pl_variaveis.vv_nome := 'PERM_NF_TIT_VENC_MEN'; 
      end if; 
      pl_insere_r; 
   end;
AI has several begins similar to this most changes the Function parameters and the name of the item. .... and changes the VN_FLAG in number sequences until 22.
and all these begins are inside a bigger begin.
And in this bigger begin has another exception:

Select all

EXCEPTION 
   when vê_insere_r then 
      pl_variaveis.vv_insere_r := 'S'; 
      if vn_flag = 1 then 
         pl_variaveis.vv_nome := 'PED_VENDA_LIB_REP'; 
      elsif vn_flag = 2 then 
         pl_variaveis.vv_nome := 'PED_REMESS_LIB_REP'; 
      elsif vn_flag = 3 then 
         pl_variaveis.vv_nome := 'CTR_VENCTO_PEDIDO'; 
      elsif vn_flag = 4 then 
      	 pl_variaveis.vv_nome := 'VER_VALID_CNPJ_CLI'; 
      elsif vn_flag = 5 then 
      	 pl_variaveis.vv_nome := 'PERM_DT_RETROAT_NF'; 
...
This procedure is done only anyway, there is nothing different from the other Begins ... .

Here comes the question ...
How can he fall on the exception vê_insere_r if he does not have raise anywhere ??
and of course chi case fall in the last exception the VN_FLAG will be equal to 22!
and do not have the when others também .... = D
User avatar
vetis
Rank: Programador Pleno
Rank: Programador Pleno
Posts: 36
Joined: Fri, 25 Apr 2008 10:29 am
Location: cariacica - es
Thiago Vetis
Creedence Clearwater Revival - :-o

Very crazy!

: -O
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

It seems that they used the method "copy-paste" from some other procedure, hehehhe
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests