Cursor with exceptions

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
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

For everyone's joy, let down another case with useless exceptions found these days in a package.
See below:

Select all

BEGIN 
  OPEN  cr_vl_limite_resp_aux(ldt_pesquisa); 
  FETCH cr_vl_limite_resp_aux INTO lvl_lim_pesquisa; 
  CLOSE cr_vl_limite_resp_aux; 
EXCEPTION 
  WHEN NO_DATA_FOUND THEN 
    select vl_limite_resp 
    into lvl_lim_pesquisa 
    from tb_item_transp_nac 
    where cd_pessoa = PCd_Pessoa; 
  WHEN TOO_MANY_ROWS THEN 
    lvl_lim_pesquisa := 0; 
END;
The guy made a cursor and placed those exceptions that will never be fired. That's because to test if a cursor did not return any row, it is tested with nomedocursorr% Found !!!
Another ridiculous thing here is to put TOO_MANY_ROWS in this cursor! Imagine: If the guy chose to do a cursor it's kind of obvious that he expects to return more than one line (in order to treat line per line). Hheheheh :-D
NaPraia
Rank: Analista Júnior
Rank: Analista Júnior
Posts: 88
Joined: Fri, 22 Feb 2008 8:24 am
Location: Floripa - SC

Where do you get these pearls ????
There is something that even God doubts
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

Yeah ... I worked with maintenance projects a while ... hence I had to read several programs and move on them. From time to time some pearls appeared like these .. haohaoah

but I have not think so long ago ...
rodfbar
Rank: DBA Pleno
Rank: DBA Pleno
Posts: 241
Joined: Tue, 09 Oct 2007 11:15 am
Location: Batatais - SP

Look guys .. very careful about this ... what we do today tomorrow may seem bullshit .... but it happens .... huahauhauhauahua
: oops:

but it is Legal to see these things ....


A hug
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests