Home > Mobile >  Procedure which returns several rows conditionally
Procedure which returns several rows conditionally

Time:04-04

I have a procedure which will return a number as out parameter(let's call it out_parameter_result). According to this number I need to add rows conditionally.

Pseudocode example(don't mind about conditions):

if(bitand(out_parameter_result, 1) = 1)
   result.add(select 1 from dual)
if(bitand(out_parameter_result, 2) = 2)
   result.add(select 2 from dual)
if(bitand(out_parameter_result, 4) = 4)
   result.add(select 4 from dual)
return cursor(or resultset) which will contain 1,2,4.

CodePudding user response:

Different from original, but works fine in my case.

SELECT * FROM TABLE WHERE id IN (
       DECODE(bitand(v_info, 1), 1, 0, 1), 
       DECODE(bitand(v_info, 2), 2, 0, 2), 
       DECODE(bitand(v_info, 4), 4, 0, 3)
  • Related