What is a good way to check if the selection ADB sql cursor returns nothing

Hi all

I am trying to find a good way to identify that a select SQL basic cursor return nothing.
I know that or we use exception when no data found or count (*) to check how many rows are returned.


I have a cursor based on a long statement select.
As
CREATE OR REPLACE PROCEDURE aaa (v_input IN NUMBER, v_output OUT VARCHAR2)
     CURSOR long_cursor IS
          --long select statement(with input variable) ;

BEGIN
     Select count(*) 
     Into v_count
  From
  -- a long select statment with input again ;
  IF v_count > 0 then
    For record in long_cursor loop
     --Get information from cursor
        --other processing for output
    End loop;
  END IF;

END;
Is there a way other than the above?
I would like to reduce the amount of typing. I know that repetition in code is not good.

Thanks in advance,
Ann

Published by: Ann586341 on February 28, 2013 14:29

Hello Ann,.

Apart from the possibility has already been mentioned that other users can change the data during execution of your process, you can check if something needs to be done without the COUNTY. Set a flag in the cursor for loop. When there is no data, then the flag will not change one you can perform the necessary procedure.

CREATE OR REPLACE PROCEDURE aaa (v_input IN NUMBER, v_output OUT VARCHAR2)

    v_data_found    BOOLEAN := FALSE;
    CURSOR long_cursor IS
        --long select statement(with input variable) ;

BEGIN
    For record in long_cursor loop
        v_data_found := TRUE;
        --Get information from cursor
        --other processing for output
    End loop;
    IF NOT v_data_found THEN
        -- set processed flag
    END IF;
END;

Concerning
Marcus

Tags: Database

Similar Questions

Maybe you are looking for

  • Firefox losing all my tabs if I close when a youtube video is blocked. What is accettable?

    I saved several groups almost 50 pellets.Yesterday, I was looking for some videos on Youtube. When some videos seen regularly, I select a video that seems to expect too much to appear.I close firefox.After the reopening, he opened with a default page

  • NB100 Bios password reset

    I have a Netbook NB100 and you want to reset the supervisor password. I know two possible solutions for Toshiba systems in general; reorganize one using a floppy disk and the other using a parallel device, however as the NB100 has none of these they

  • Can someone tell me what 3D engine used ultiboard

    I want to know what 3D engine used ultiboard?

  • Close the form

    Lenovo ThinkPad T500 95% of the time I use the laptop connected to a flat screen of plugin, a keyboard and a mouse. Question 1 Is it possible to close the laptop screen / lid put the laptop to sleep, either keep the laptop that works with the screen

  • AMD WIN7 DRIVER FOR HPPAVILLION E038TX

    I haverecently bought computer hp laptop Pavilion 15 e038tx. It comes with 4 gb/500/3 rd gen amd of i3/1 GB graphics card. I was shocked to see that there is no driver for win7. If I use win8. I tried all the drivers of win8 on win7 64. they work per