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
Advertisement

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

  • What is the best way to check if the trigger was held

    What is the fastest way to check if the trigger was held. Right now, the only way I can think is to query the number of samples acquired on the AI channel (which is triggered). Is there a faster way? Is there a property node (that I can't find) that returns TRUE/FALSE?

    Thank you

    Can you elaborate a bit more? What type of trip (I guess a start trigger)? What equipment? What do you mean by 'faster '?

    There is no property to "has a start trigger has occurred." If you want to find if a start trigger has occurred, you can he deduct the number of samples. There are several approaches you can take:

    * DAQmx Read will hang until a timeout is hit or up to the number of samples you request is read. You could do a DAQmx Read with a timeout-infinity (1), playback of a single sample.

    * Well, you could ask about properties DAQmx Read TotalSampPerChanAcquired or AvailSampPerChan; Once they no longer means 0, while this NEITHER-DAQmx started buffering data internally, which means that the material received the trigger.

    * If you use a digital border start trigger and according to your material, then you may be able to use the detection of changes in a separate task, but I don't know if it would be significantly faster then the other two approaches.

  • How to check if the selection is any text tho:

    Ok.. Another question:

    How to check if the selection is any text tho:

        if (app.documents.length != 0 && app.selection.length != 0 &&

         (app.selection[0].constructor.name=="Text"||app.selection[0].constructor.name=="Paragraph"))

    but sometimes the selection is 'textStyleRange', sometimes 'character' etc. is there a shortcut to check both?

    I usually do something like this:

    if ( app.documents.length && app.selection.length && app.selection [ 0 ].hasOwnProperty ( 'baseline' ) )
         alert ( "It's a text!" );
    

    Hope that helps.

    --

    Marijan (tomaxxi)

    http://tomaxxi.com

  • What is a good way to use the queues for the model of consumers/producers?

    Hi all

    I am following the model of consumers/producers to use the queue to synchronize the following process: the producer is a loop to produce a number N, I will put each number generated in a table and after each 5 numbers generated, I put the table in the queue and pass it on to the consumer. I have to wait the use by consumers of the data and it will then remove the item from queue so that producers will have the chance to produce another 5 numbers. As I put the maximum size of the queue one, I expect that the producer and the consumer turns to produce / consume all five numbers and the opportunity to another. Here is my code

    When the checkbox is false, the code will be

    For the first 5 numbers, product will generate every thing right and put it in the table, and it's going to pass the array to the quere so that the consumer will have the chance to loop through the table. I except the procude loop will continue only when the queue is available (i.e. all items are deleted), but it seems that once the consumer starts the loop loop of the product will continue (if the indicator x + 1 and x 2 will be changed to numbers). But this isn't what I want, I know there must be something wrong, but I can't say it is.

    dragondriver wrote:

    As you say in 1, sequency structure to enforce the order of execution, that's why I put it here, in this example, the simple question, I replace the complete code with increase in the number, in the real case, the first markers + 1 and + 2 must be performed in this order.

    Mikeporter says:
    1. get rid of all the structures of the sequence. None of them are nothing but apply a work order which would have been the same without them.

    So even if you delete the sequence structure, there will be a fixed & defined order and it is because LabVIEW follows the MODEL of FLOW OF DATA.

    Data flow model (more precisely in the context of LabVIEW): a block diagram node runs when it receives the required inputs. When a node is running, it produces output data and transmits data to the next node in the path of the data stream. The flow of data on the nodes determines the order of execution of the VIs and functions on the block diagram (click here for reference).

    Now in your code, just remove the sequence structure will not make you order will be going to stay the same, but you need to do some very minor changes (as thread of the error in loop, before that he go to the node "Élément Dequeue").

    Come to the main point: it's a good way to use the queue for the consumer/pmodel that?
    The model you are using (and qualifying as consumer/pmodel) is much too deviated from the original consumer/pmodel which model.

    dragondriver wrote:

    For the second, Yes, it's my fault for delete, though. I'm actually the example of model of producer/consumer design pattern, but I do not pay attention to the while loop in the part of the consumer.

    While loops (two producers & consumers) are the essential part of this architecture and cannot be deleted. You can start your code using standard model.

  • What is the quick way to check if the battery current sequency contains nothing or not?

    Hi all

    I have switch from C++ to the labview in a short time before. I got a code written in labview 7 someone else and I am trying to change a code in my labview 2012. In the code, there are a lot of nested structures (like sequency battery, case, etc.). Some code contains 30 batteries but not all subsequences contains controls or code. Someone when I pass in a sequence, it seems empty, but some controls or code could be hiding somewhere beyond the current view. Thus, instead of zoom current sequency block, is that any quick way to identify if the block contains another type or not? Thank you.

    It is spelled "sequence".

    Make sure that autogrow is enabled for the sequence stacked so that you don't have the problem of the code hidden beyond the edges.

    Right-click on the stacked sequence and choose replace with flat sequence.  It will extend things, but how you can see all the pictures.

    Block diagram cleanup allows to get rid of more space and clean up the code.

    If you see empty images, you can right-click on the border between frames and select merge the images.  You should also do this if you have separate frames that should not be because there is already a data dependence that determines the sequence of operation.

  • is there a way to check if the page request was made by specific URL?

    I need locking a page so it responds only to when a form is sent to our payment gateway

    Is there a way to check WHO sent the page request

    That is to say. If the page request to was provider of payment process form

    I'm already check if the form fields are valid by xreffing with our own details

    I check if the request was for the HTTPS version of our page

    I would now like to check whether the application was the URL of our payment gateway

    I use cgi.remote_addr and check the IP address, the only other thing you can use is the sponsor, but that can be easily spoofed.

  • How to use SQL or another way to check if the assets have been post GL?

    Hi all:
    I wan to ask, how to use SQL statements or any other way to check iif assets have been post GL?


    my environment is oracle 11.5.9






    Concerning
    Terry

    to create entries and transfer to GL
    assets: -.
    (1) (log N entries)-> standard
    (2) complete the setting and submit.

    to check if the assets have been post GL
    Journal:--
    (1) magazines-> Enter
    (2) in the form of research journals Source LOV, select 'Assets', then enter
    (3) you will find all transferred assets (Addition or depreciation) magazines, and the status of the batch is (Unposted), then review and Post

    Published by:! ALotfy September 2, 2010 08:54

  • Good way to respond to the events to commit

    Community,.

    . . . . What is the right way to add a trigger for a table with version as this event only fires on MergeWorkspace?

    Kind regards
    Noel



    . . . . What I've tried: (plan A) to exclude the possibility of a trigger on the table of LT shooting as part of a workspace, I implemented a trigger aulieude on the view. Then I tried to use SetTriggerEvents to ensure the trigger pulled only on MergeWorkspace. This does not, as bspeckha pointed out, account OWM does not support triggers aulieude. (plan B) As advised, I added the relaxation to the LTS table in the context of a DDL session and was able to run successfully SetTriggerEvents. I've listed the triggers associated with the table in question (using the OEM) and does not see the trigger in question. A systematic update against the erroneous out table and I suspect the newly added trigger was guilty:
    ERROR at line 1:
    ORA-00600: internal error code, arguments: [kxtounpi2], [image-to-object
    conversion failed in trigger bind], [7], [], [], [], [], []
    ORA-04088: error during execution of trigger '<SCHEMA>.OVM_UPDATE_25'
    . . . . (plan C) As advised, I could create a copy empty table, add triggers, activate the version and reload all the files and revisions. I have not tried yet as it is a tedious job and wondered if there was another way.

    Hello

    When you call dbms_wm. EnableVersioning on a table that has a user-defined trigger, OWM will convert the relaxation in a PL/SQL procedure. That's why she will not appear in the dba_triggers view. You don't want to use all_wm_tab_triggers view instead.

    If you want a trigger only during the MergeWorkspace, you do the following:
    SQL > exec dbms_wm. SetTriggerEvents ('', dbms_wm.) WORKSPACE_MERGE_WO_REMOVE | «, » || dbms_wm. WORKSPACE_MERGE_W_REMOVE);

    If you get an ORA-600 error when you do, I'd file a SR. It is an internal database error.

    Kind regards
    Ben

  • What is a good way to determine the validity of the GPS with BPS?

    Hello

    I use bps for a native application on the Playbook. There are a lot of functions to call to get information about the events of geolocation, which is great. But I'm looking to distill information into something that could tell me if yes or no position (lon, lat at least) is designed to use in my application... it is to tell whether or not I am a "GPS coordinates". You can check the validity of all to a large number of parameters (altitude, heading, speed, etc.) ... but nothing that tells you if lon and lat are valid.

    Does anyone have advice as to how I can a true/false 'gpsIsValid' extracts the available data?

    REF;

    http://developer.BlackBerry.com/native/reference/PlayBook/com.QNX.doc.bps.lib_ref/com.QNX.doc.bps.Li...

    If you get a reading at all, it should be "valid" in the sense that it came from calculated data based on the satellites used.

    What you need to do is to decide 'how' it is valid, that's up to you: https://developer.blackberry.com/native/reference/playbook/com.qnx.doc.bps.lib_ref/com.qnx.doc.bps.l...

  • What is a good way to clean a macbook air screen?

    Just want to clean my screen is their way I should do?

    Use the cleaning cloth provided with the computer when it was new. You can use the cleaning rags used to clean eyeglasses.

  • Pavilion G-6 2209au: Pavilion G - 6 2209au what is a good way to know what updates I can do?

    can I upgrade my Proccesor, graphics card or motherboard? I don't know where to look for this info. All tips yould be appreciated...

    Thanks for your help Arant47

    Hello

    Purchase of a Blu - Ray player of stand alone for your TV is now much cheaper and LIVE longer. I have two readers of comics, one on my laptop and a Pioneer burner external BD (also actor) and they are not worth better than single player. Now, you can buy a stand-alone player for less than $100.

    Kind regards.

  • Good way to check that an application built with SDK v10.3.1 works for 10.2.1

    Hello

    My application uses the SDK v10.3.1. A user asked me if it can be compiled to support v10.2.1 as well.

    Is there a formal procedure to verify this?

    Thank you

    You need to test yourself with a device running 10.2.1 or a simulator. Change your file bar - descriptor.xml to assign the minimum OS 10.2.1 there is also a blue text on the same screen of bar - descriptor.xml file saying API level or something, be sure to set for 10.2.1. If your project is a headless application, left-click on your project without head, choose Properties or preferences or configure (don't remember), there will be somewhere to change the level of the API for headless to 10.2.1. Clean and rebuild your project (s).

    All your QML file must import bb.cascades 1.2 instead of 1.3, otherwise it displays a black screen at startup where nothing happens.

  • What is a good way to say WHAT HA is healthy?

    Go to the essential, how will I know if HA is happy and healthy for all hosts in a cluster?

    We are very new to ESXi/ESX/vCenter. We have the license for HA, etc. Most of the things are fine, but we had a problem with vCenter box recently and it hung (vCenter box runs on a server ESXi unrelated to our production cluster. The problem was caused by... you guessed it, NTP problems... we had NTP works fine on ESXi hosts in our production cluster, but the vCenter box is completely separated physically and virtually our production of HA cluster and we have neglected it). After restarting the host to vCenter, he came and began to cough up all sorts of errors of heart rate for all hosts and some mistakes HA of a single host. Could not find anything wrong b/c, everything seems to work very well. So I restarted the VM vCenter, and when it came 10 minutes ago he seems happy. No more alarms/errors not yet at this time.

    So I expect errors to start popping up at all now, but if there is nothing, how do I know if HA is happy?

    You can see the newspaper on each ESX:

    tail-f /var/log/vmware/aam/vmware_*.log

    HA is happy when all heartbeats works... do not forget to have redundancy of the network, if you have only 2 node ESX make sure default gw is to ping queries (or add additional tests of 'ping'), understand admission control (if using it),...

    André

  • OsCustomizationSpec and OSCustomizationNicMapping they are a good way to set up the new virtual machine for the model

    I build a script to generate auto magicly VM when I have import information from a csv file. I have the latest PowerCli, I am trying to build servers r2 Sever 2012 model.  I tried several OsCustomizationSpec (OCS) of in the hope of getting something to work, but I had no luck so far.  In VCenter, it shows that it applies the OCS, but is not apear to have an impact on the server.  I have disabled UAC since the last time that I tried it so maybe that will make a difference.  I am under ESXi 5.1 update 2, just to try to give all the necessary information.  Ideally, I'd like Sysprep, the value of intellectual property, change the computer name and join the server to the domain.  That's all! lol I have the book "VMware vSphere PowerCLI Reffernece, automating vSphere Administration, I walked through step by step.  The new version of PowerCli seems not have the x 86 limitation as earlier versions of PowerCli.  I tried so many different things, I'm not sure what to put in place as a starting point.

    # Save the object credentials with permission to join the domain.
    $DomainCredentials = get-Credential "domain\testername."
    # Clone our Spec by adding the domain information.
    $Spec = get-OSCustomizationSpec "Windows Server 2012 R2"
    $Spec += get-OSCustomizationNicMapping - Spec $Spec
    #$Spec | Select *.

    # Get our VM
    # Change network settings
    Get - VM BigServername | Get-NetworkAdapter | Together-NetworkAdapter - NetworkName nic - 172.16.25 - VLAN225 - connected: $true '
    -Confirm: $false | out-null
    # Close the comments to make change.
    Stop-VMGuest - VM $VM - confirm: $false | out-null
    # Wait while feedback stops
    While ($vm. ExtensionData.Runtime.PowerState - not "poweredOff")
    {
    Start-Sleep - seconds 1
    $vm. ExtensionData.UpdateViewData ('Runtime.PowerState')
    }
    # Apply Spec customization to apply the new network settings
    Get - VM "BigServername" |
    Set-VM - OSCustomizationSpec "R2 Windows Server 2012" - confirm: $false |
    Start-VM

    I can rebuild the model, or something else, we must do this work.

    OR - is simply not the best way to configure the VM?  If not, what Sysprep?

    Good news, but first, I would really like to know where the log files are on which server to the OsCustomization process.

    I decided to reverse engineer and create a CSOS within vCeneter and once I got to work, I kept creating new CSO via PowerCli until I could get that to work, create a new virtual machine.  Once I got this to work, I have tryied to apply on a cloned vm, with no parameters. I got it works too.  I tried to go back to my original image, but I couldn't get this to work.  Something's wrong with this picture.  He wrath that the problem was related to the permissions on the local client.

    New OSCustomizationSpec - OrgName company OSType - Windows - ChangeSid-Server "vcenter.dom.com" - name PowerCliOnly4 - persistent administrator-Type FullName - AdminPassword! password123 - zone "Eastern (USA and Canada)" AutoLogonCount - 3 - domain dom dadmin - DomainUsername - DomainPassword! password123 NamingScheme - vm-Description "PowerCli Use only" - confirm: $false

    Get-OSCustomizationNicMapping - OSCustomizationSpec PowerCliOnly4 | Game-OSCustomizationNicMapping - Position 1 - IpMode UseStaticIP - IpAddress 10.10.10.98 - 255.255.255.0 - DefaultGateway 10.10.10.1 Dns subnet - mask "10.10.10.10","10.10.10.11" "-confirm: $false

    This seems to be very picky.  Because the area is one of the parameters, you cannot put it in the DomainUsername, no dom\dadmin. The part that I really want to know how to get more, is what happens if your vm has a different local administrator as the administrator account.  It turns out that FullName - is not the account that it to connect locally with tires. When I created the vCenter Medtronic Chondroitin, I put 'me' in the name and information of the Organization and that's what was settled in the FullName property:

    Name: PowerCliOnlyM
    Type: persistent
    ServerId: /VIServer = dom\[email protected]: 443.
    Server: vcenter.dom.com
    LastUpdate: 24/09/2014 13:33:19
    DomainAdminUsername: dadmin NO dom/dadmin here!
    DomainUsername: dadmin
    Description: PowerCli use only, done manually in vCenter.
    AutoLogonCount: 3
    ChangeSid: true
    DeleteAccounts: false
    DnsServer:
    DnsSuffix:
    Domain: vsi
    Full name: me
    GuiRunOnce:
    NamingPrefix:
    NamingScheme: Vm
    OrgName: CompanyTU
    OSType: Windows
    ProductKey:
    Time zone: (USA and Canada)
    Working Group:
    LicenseMode: NotSpecified
    LicenseMaxConnections:
    EncryptionKey: {-126, 3, 48, 108...}
    ExtensionData: VMware.Vim.CustomizationSpecItem
    ID: PowerCliOnlyM
    UID: /VIServer = vsi\[email protected]com: 443/OSCustomizationSpec = PowerCliOnlyM /.
    Client: VMware.VimAutomation.ViCore.Impl.V1.VimClient
    AdminPassword: w
    DomainAdminPassword: N
    DomainPassword: N

    DNS: {10.10.10.10, 10.10.10.11}
    Wins                  :
    SpecId: PowerCliOnlyM
    Spec: PowerCliOnlyM
    SpecType: persistent
    NetworkAdapterMac:
    Position: 1
    IPMode: UseStaticIP
    IP address: 10.10.10.98
    Subnet mask: 255.255.255.0
    DefaultGateway: 10.10.10.1
    AlternateGateway:
    VCApplicationArgument:
    ID: /VIServer = dom\[email protected]: 443/OSCustomizationNicMapping = OSCustomizationNicMappingImpl-PowerCliOnlyM-persistent-1.
    UID: /VIServer = dom\[email protected]: 443/OSCustomizationNicMapping = OSCustomizationNicMappingImpl-PowerCliOnlyM-persistent-1.
    ExtensionData: VMware.Vim.CustomizationAdapterMapping
    Client: VMware.VimAutomation.ViCore.Impl.V1.VimClient
    Version: 1

    I think that it is good to know that the virtual machine reboot 4 or 5 times as it goes through this process.  It breaks is you try and do something for the virtual machine that interrupt the process.  I don't know that I'll think more questions in a second.

    In addition, it cost he had some problems with the put between quotation marks, single or double around the password, but I did not check this again, I just know that once I took them, he began to work.  I ran on other issues while testing as I was using a single IP address, so if I do not disable the test VM, the following would not work because of the conflct network, maybe I shouldn't admit that... lol

  • Best way to check if the VI is dynamic distribution?

    I do a bit of scripting to VI, to create a class of children of a given parent and substituting the dynamic distribution selected screws to create a profile of a class library, I'm iterating over all the screws and check the connector pane to see if there are dynamic terminals. I don't know that there is a smarter method...

    If you have a reference to the class library, you might be able to use the "DynamicMemberVIs" property (there also a "StaticMemberVIs" property).  I have not tried to use it myself, so I can't guarantee that it will do what it takes.

    Chris M.

Maybe you are looking for