Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi please any body have solution i want to execute oracle SP if first refcur has record than and than second refcur1 execute otherwise not please help me if anybody knows
this is my SP code

SQL
    (   
			v_COM_Service_No IN VARCHAR2,
			v_COM_CompDate IN TIMESTAMP,			
			v_COM_Type IN CHAR,
			v_COM_DefCD1 IN NUMBER,					
			v_COM_Modified_By IN VARCHAR2,
			v_COM_IP_Addr IN VARCHAR2,					
			v_COM_Remarks in varchar2 default null
			,v_refcur out sys_refcursor
			,v_refcur1 out sys_refcursor
		 	) as

    v_OutComplaintNo varchar2(50);
   v_maxSequenceNo number;   
   v_App_No  VARCHAR2(25);   
   v_mtrchngcnt number;
   v_mtrserialno VARCHAR2(25);   
   v_todflag varchar2(10);

BEGIN

open v_refcur for
select nvl(MTRM_CHANGE_COUNT,0)+1 ,MTRM_Serial_No,TOD_Name into v_mtrchngcnt , v_mtrserialno,  v_todflag
from  M_Meter,M_ServiceMaster,M_TOD where  
 TOD_Id = MTRM_TOD_Flag  
 and MTRM_Service_No = v_COM_Service_No 
 and SRM_Discon_tag_Id = 2 
 and SRM_Service_no = MTRM_Service_No and  (MTRM_CHANGE_INDICATION=0 or MTRM_CHANGE_INDICATION is null)  ;
if(v_mtrchngcnt > 1)then
open v_refcur1 for 
select  sws_com_compno.nextval into v_maxSequenceNo from dual;
end if;
END;
Posted
Updated 30-Sep-11 1:59am
v2

1 solution

you have first to check for the data like

SQL
SELECT COUNT(*) INTO XYZ FROM M_Meter,M_ServiceMaster,M_TOD where   
TOD_Id = MTRM_TOD_Flag   
and MTRM_Service_No = v_COM_Service_No 
and SRM_Discon_tag_Id = 2 
and SRM_Service_no = MTRM_Service_No and   (MTRM_CHANGE_INDICATION=0 or MTRM_CHANGE_INDICATION is null);

IF XYZ > 0 THEN

return first cursor

ELSE

return second cursor

ENDIF;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900