# Database Discussions > IBM DB2 >  can we use if then else when declare a cursor?

## mimizulk

DECLARE COMP_PROS_CSR CURSOR WITH HOLD FOR
IF ll_c_BCBIDTYPE = 'BDW130010'  THEN 
begin    
    SELECT p.PRIMARYKEY, p.CONTACTKEY, p.BCBConstitution
    FROM ACCOUNT p
    WHERE P.STATUS <> 'BCBCCustom'
    AND (P.BCBCONSTITUTION > 'BDW100101' AND P.BCBCONSTITUTION <= 'BDW100999')
    AND P.BCBBIZREGNO__ = ll_c_BCBBIZREGNO     
    ORDER BY lastupdd;
end  
ELSE 	
    SELECT p.PRIMARYKEY, p.CONTACTKEY, p.BCBConstitution
    FROM ACCOUNT p
    WHERE P.STATUS <> 'BCBCCustom'
    AND (P.BCBCONSTITUTION > 'BDW100101' AND P.BCBCONSTITUTION <= 'BDW100999')
    AND (P.BCBBIZREGNO__ = ll_c_BCBBIZREGNO
         OR P.BCBASSOCLUBSOC__ = ll_c_BCBASSOCLUBSOC
         OR P.BCBOTHERID__ = ll_c_BCBOTHERID)
    AND BCBNameMatch = ll_c_NAME
    ORDER BY lastupdd;
END IF;

----------

