Link to home
Start Free TrialLog in
Avatar of alexalar
alexalar

asked on

How to implement Ref cursor on DB2

Hi all

I need to translate an Oracle functions and Stores procedures that uses Ref Cursor datatypes variables, for example:

CREATE OR REPLACE FUNCTION    "EXISTE" (Selecc in Varchar2, Proced in Varchar2, Condic in Varchar2)
RETURN BOOLEAN
IS

Type Registro is Ref Cursor;
retorno   Registro;
p_valor1  int;
f_strsql  varchar2(4000);
p_existe  boolean;

Begin

p_valor1 := 0;
f_strsql := 'Select ' || Selecc || ' From ' || Proced || ' Where ' || Condic;
Open retorno for f_strsql;
Loop
  Fetch retorno into p_valor1;
  Exit when retorno%notfound;
End Loop;

If p_valor1 = 1 Then
  p_existe := True;
Else
  p_existe := False;
End If;

Return p_existe;

End EXISTE;
/

How i can do this on DB2?

Thanks a lot,
regards
ASKER CERTIFIED SOLUTION
Avatar of ocgstyles
ocgstyles

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial