L
L
Light7772014-10-03 11:58:15
Oracle
Light777, 2014-10-03 11:58:15

Why is the if block ignored and immediately jumped to the case block when I run the function?

Why is the if block ignored and immediately jumped to the case block when I run the function?

create or replace function aaa_aaa(
cel_cred in varchar2,
prog_cred in varchar2,
dog_num_ in varchar2 default NULL
)
  return varchar2 is
  res varchar2(10);
begin

  if cel_cred = '051' and dog_num_ is null then 
    if prog_cred = '16102' then
      res := '006';
    elsif prog_cred = '16155' then
      res := '007';
    end if;
  end if;

  case
    when prog_cred = '16153' and cel_cred ='051'   then
      select case
               when AAA in (206, 207, 208, 209, 210, 211, 212, 220, 221, 17)  then
                '029' 
               when AAA not in (206, 207, 208, 209, 210, 211, 212, 220, 221, 17) then
                '007'
             end 
        into res
        from tab_name t
        where t.BBB=dog_num_;
         dbms_output.put_line(res);

    when prog_cred = '16103' and cel_cred ='051' then
      select case
               when AAA not in (206, 207, 208, 209, 210, 211, 212, 220, 221, 17) then
                '007'
               when AAA in (206, 207, 208, 209, 210, 211, 212, 220, 221, 17) then
                '029'
             end
        into res
        from  tab_name t
        where t.BBB=dog_num_;
        else res:=cel_cred;
  end case;

  return res;
end aaa_aaa;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Максим Чорнопольский, 2014-10-03
@Voiddancer

А вы уверены что условия для if подходят? Дебаггером его, дебаггером!

D
DmitrySytkov, 2014-11-13
@DmitrySytkov

Вы бы для начала указали с какими значениями параметров вы эту функцию вызываете.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question