Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Return empty ref cursor

SeshuGiriJun 24 2008 — edited Jun 25 2008

How do I return a empty ref cursor in case of no data? see my example below..
If v_count > 0 i am selecting values from db, what should I do if v_count = 0?

   PROCEDURE SPROC_EMP (
                  in_id 	IN 	VARCHAR2,
                  out_values 	OUT 	sys_refcursor)    
    IS
      v_count           NUMBER;    
    BEGIN
    
    SELECT COUNT(*)
        INTO v_count
        FROM EMP E
        WHERE E.id = in_id;
        
    IF v_count > 0 THEN
        BEGIN
	        OPEN out_values FOR
		SELECT * FROM EMP
		WHERE ID = in_id;
	END;
    END IF;
  END;

Thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 23 2008
Added on Jun 24 2008
10 comments
8,091 views