Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    153

    Unanswered: Finding value between two cursors

    Hi All,

    There are two cursors. Want to validate that all values of the second cursor is found in the first. If so return S, else F.

    Example.

    First one say contain {1,2,3,4,5}. Second one {2,3}. Result : S.
    First one say contain {1,2,3,4,5}. Second one {2,6}. Result : F.

    It will be nice if any one can help.


    Thanks with Regards,
    JD

  2. #2
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    include first cursor in the second and denote if you have an f or s. Otherwise, handle within your app code via an array of some type.
    Dave

  3. #3
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    SQL, PL/SQL, and Java

    "A cursor is a handle or name for a private SQL area—an area in memory in which a parsed statement and other information for processing the statement are kept."

    >Want to validate that all values of the second cursor is found in the first.
    I do not understand the question/problem.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  4. #4
    Join Date
    Jan 2011
    Posts
    19
    I tossed this together quickly. If I understand the problem the right way.

    There are better ways to do this but I'm limited by the length of my break at work.

    Note: code isn't perfect, it is a sample of an idea quickly tossed together =/

    Code:
    icount PLS_INTEGER := 0;
    jcount PLS_INTEGER := 0;
    
    BEGIN
    
    FOR i IN
    (
    	SELECT *
    	FROM table2
    )
    LOOP
    
    	icount := icount + 1;
    
    	FOR j IN
    	(
    		SELECT *
    		FROM table1
    		WHERE i.number = j.number
    	)
    	LOOP
    	
    		jcount := jcount + 1;
    	
    	END LOOP;
    	
    
    END LOOP;
    
    	IF icount != jcount
    		DBMS_OUTPUT.PUT_LINE('F');
    	ELSE
    		DBMS_OUTPUT.PUT_LINE('S');
    	END IF;
    Last edited by Stium; 02-10-11 at 17:01.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •