Opening different cursor under same name?

I have a problem that depending on a if statement I want to open two different cursors. The cursors have the same format for their ROWTYPE. Like:
CURSOR a_cur IS SELECT a,b FROM c WHERE d=e;
CURSOR b_cur IS SELECT a,b, FROM c WHERE d<>e;
Then I want to run the same logic in the fetch loop no mater if I opened a_cur or b_cur. At the moment the logic is replicated in the code, but I would like to avoid this. Is it possible to open either one of them as a alias and then run the fetch loop on the alias. Some thing like this:
DECLARE
g_val a_cur%ROWTYPE;
BEGIN
IF f=1 THEN
OPEN a_cur as opened_cursor;
ELSE
OPEN b_cur as opened_cursor;
FOR g_val IN opened_cursor LOOP
<lots of logic>
END LOOP;

Here is an example of using a REF CURSOR:
create table t
(x int)
insert into t
select rownum
  from all_objects
where rownum <=10
declare
   rc sys_refcursor;
   rec t%rowtype;
   condition varchar2(1) := 'E';
begin
   if condition = 'E' -- Even Numbers only
   then
      open rc for select *
                    from t
                   where Mod (x, 2) = 0
   elsif condition = 'O' -- Odd Numbers
   then
      open rc for select *
                    from t
                   where Mod (x, 2) = 1
   end if;
   loop
      fetch rc into rec;
      exit when rc%notfound;
      Dbms_Output.Put_Line (rec.x);
   end loop;
end;

Similar Messages

  • Can I run 2 different domains with same name but on 2 different machines?

    I am trying to setup 2 domains with same name (sharedcds1) on 2 different machines (Machine1 and Machine2).
              When I start the weblogic managed server 1 (sharedcds1managedserver1) on Machine2, it throws an error saying it has some conflicts with the managed server 1 running on Machine1. How did the managed server of one machine know about the other server. Can I run 2 different domains with same name but on 2 different machines?
              Here is the error in the log -
              <Jun 14, 2005 10:53:29 AM EDT> <Error> <Cluster> <BEA-000123> <Conflict start: You tried to bind an
              object under the name weblogic.transaction.coordinators.sharedcds1managedserver1 in the JNDI tree.
              The object from 4596206652609838848S:130.170.61.153:[9505,9505,-1,-1,9505,-1,-1,0,0]:sharedcds1:s
              haredcds1managedserver1 is non-clusterable, and you have tried to bind more than once from two or m
              ore servers. Such objects can only be deployed from one server.>
              <Jun 14, 2005 10:53:29 AM EDT> <Error> <Cluster> <BEA-000123> <Conflict start: You tried to bind an
              object under the name weblogic.transaction.coordinators.sharedcds1managedserver1 in the JNDI tree.
              The object from 8842351474821025197S:130.170.61.154:[9505,9505,-1,-1,9505,-1,-1,0,0]:sharedcds1:s
              haredcds1managedserver1 is non-clusterable, and you have tried to bind more than once from two or m
              ore servers. Such objects can only be deployed from one server.>
              Thanks
              Satish

    Yes you can. Make sure that domains configured to use different multicast address. WLS uses multicast for communications between nodes in domain.
              although your configuration will work, you could have troubles if you going to execute inter-domain calls between domains/servers with the same names.

  • Is it possible to differentiate one payroll area with different currency under same company code

    Hi experts ,
    MY client wants to pay in yemen currency for the employees who working in yemen, but it was comes under same company code created for india.we have differentiated yemen under different payroll area wise . so is it possible to  differentiate one payroll area with different currency under same company code.
    thnx,
    vamshi keshavapatnam

    Hi Vamshi,
    I don't think so what you have done is correct. It seems like Global Employment functionality. As I understood you have some EEs which are Indian but working in company branch of Yeman.
    If this is the case you should define a new company code for Yeman branch and use Global Employment functionality. By this you can make decision to pay in home currency or traget country currency.
    Regards,
    Omid

  • Problem in importing two different classes with same name...

    I have to import two different classes in my program with the same name....
    import org.apache.lucene.document.Document;
    import org.w3c.dom.Document;
    //    I AM USING THE DOCUMENT FROM W3C PACKAGE HERE....
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                     DocumentBuilder builder = factory.newDocumentBuilder();
                     InputSource is = new InputSource( new StringReader( tempString ) );
                     d = builder.parse( is );
                     NodeList images = d.getElementsByTagName("img");
                     int length = images.getLength();
                     for(int i = 0;i<length;i++)
                         Node image = images.item(i);
                         String tempAltText = image.getAttributes().getNamedItem("alt").getNodeValue();
                         altText = altText.concat(" ").concat(tempAltText);
                     }and the error i am getting is
    [javac] C:\Documents and Settings\sumit-i\WolframWorkspaces\Base\WolframNutch\src\java\com\wolfram\nutch\indexer\InfoCenterFilter.java:20: org.apache.lucene.document.Document is already defined in a single-type import
        [javac] import org.w3c.dom.Document;
        [javac] ^
        [javac] C:\Documents and Settings\sumit-i\WolframWorkspaces\Base\WolframNutch\src\java\com\wolfram\nutch\indexer\InfoCenterFilter.java:132: incompatible types
        [javac] found   : org.w3c.dom.Document
        [javac] required: org.apache.lucene.document.Document
        [javac] d = builder.parse( is );
        [javac] ^
        [javac] C:\Documents and Settings\sumit-i\WolframWorkspaces\Base\WolframNutch\src\java\com\wolfram\nutch\indexer\InfoCenterFilter.java:133: cannot find symbol
        [javac] symbol  : method getElementsByTagName(java.lang.String)
        [javac] location: class org.apache.lucene.document.Document
        [javac] NodeList images = d.getElementsByTagName("img");
        [javac] ^
        [javac] Note: Some input files use unchecked or unsafe operations.
        [javac] Note: Recompile with -Xlint:unchecked for details.
        [javac] 3 errorsany idea ..how to resolve it
    Edited by: ping.sumit on Jul 16, 2008 3:39 PM
    Edited by: ping.sumit on Jul 16, 2008 3:40 PM

    now i changed the code to
    import org.apache.lucene.document.Document;
    import org.w3c.dom.Document;
    org.w3c.dom.Document d = null;
    try{
         System.out.println("in author");
                   URL url = new java.net.URL(urlString);
                   java.net.URLConnection conn = url.openConnection();
                   BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                   while ((in.readLine()) != null)
                        //tempString = tempString.concat(in.readLine());
                        String temp = in.readLine();
                        tempString = tempString + " " + temp;
                   System.out.println("the string in author" + tempString);
                    in.close();
                    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                     DocumentBuilder builder = factory.newDocumentBuilder();
                     InputSource is = new InputSource( new StringReader( tempString ) );
                     d = builder.parse( is );
                     NodeList images = d.getElementsByTagName("img");and their is only one error i am getting ...and that is
    [javac] C:\Documents and Settings\sumit-i\WolframWorkspaces\Base\WolframNutch\src\java\com\wolfram\nutch\indexer\InfoCenterFilter.java:20: org.apache.lucene.document.Document is already defined in a single-type import
        [javac] import org.w3c.dom.Document;
        [javac] ^
        [javac] Note: Some input files use unchecked or unsafe operations.
        [javac] Note: Recompile with -Xlint:unchecked for details.
        [javac] 1 error

  • TS1398 I am unable to connect to two different wifi at different locations having same name but different passwords

    I am unable to connect to two different wi if at different locations having same user name but different password one is at home other at work

    I was able to do a full reset on the router (pushing the tiny button near the power input). Then ran through the setup process and it started working on my device.

  • Itunes places imported tracks in different albums with same name

    When I import a CD, itunes can't seem to keep these files in the same album if they happen to be by different artists.  I've tried manually editing the track information using the "get info" screen, but just can't get it.  The initial download places the tracks together, but after I use the "get track titles" option and download the track titles from Gracenote, I'm left with multiple albums, even though the albums show as having the same name.

    Generally all you need to do is fill in an appropriate Album Artist. For more details see my article on Grouping Tracks Into Albums, in particular the topic One album, too many covers.
    tt2

  • Two different WLAN in different Location but Same Name

    Iphone4 with IoS5....i have wlan in my office and my home both are in same wlan name....When ever i try use home wlan....i need to do forget wlan which already ussed in my office and again search for wlan and connect the same....via in my office...i need to do forget the network and do rescan and found the office wlan.... is there any way to use both the wlan without doing forget network....Please help to resolve

    You can't re-name your HOME network?  Why? It's yours... presumably, you should be able to re-name it. If you can't, there is no fix. You can only store 1 security key for any given network. If 2 networks have the same name, they are considered the same network...

  • Is there a limit on the number of Apple IDs one can have under same name and billing info (with different email addresses)?

    I want to set up MANY for my employees but control the billing as a perk.  Is this even possible?

    Thunderbird has no limit.
    See http://kb.mozillazine.org/Thunderbird_:_FAQs_:_Create_Mailing_List

  • Error while opening two cursors in same procedure...

    Hi :
    I have written following Procedure:
    Declare
    procedure pro_canefortnight_master Is
    kr_caneperiodid integer;
    last_caneperiod_id number(10,0);
    kr_forthnightid integer;
    last_forthnight_id number(10,0);
    ref_caneperiodid integer;
    ref_seasonyrid integer;
    ctr integer:= 1;
    CURSOR comp_cur IS select * from CMS_SEASON_YEAR_MASTER ;
    comp_rec comp_cur%ROWTYPE;
    BEGIN
    OPEN comp_cur;
    FETCH comp_cur INTO comp_rec;
    WHILE comp_cur%FOUND
    LOOP
    kr_caneperiodid:= comp_rec.SEASON_YR_ID;
    select max(crayom_db.cr_cane_calender.cr_cane_calender_ID) into last_caneperiod_id from crayom_db.cr_cane_calender;
    if last_caneperiod_id <> 0 then
    last_caneperiod_id:= last_caneperiod_id + 1;
    else
    last_caneperiod_id:= 1000000;
    end if;
    insert into crayom_db.CR_CANE_CALENDER(cr_cane_calender_ID,ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby,CR_CANE_CALENDER_NAME,DESCRIPTION) values(last_caneperiod_id,11,11,comp_rec.current_season,sysdate,100,sysdate,11,comp_rec.DESC_MA,comp_rec.DESC_EN);
    COMMIT;
    /*insert into crayom_db.CR_IdBackup(kr_cultivationtypeid,cr_cultivationtypeid) values(kr_cultivationtypeid, last_cultivationtype_id);*/
    insert into crayom_db.temp(kr_bpartnerid,cr_bpartnerid) values(comp_rec.season_yr_id,last_caneperiod_id);
    commit;
    FETCH comp_cur INTO comp_rec;
    End LOOP;
    close comp_cur;
    CURSOR comp_cur1 IS select * from CMS_FORTH_NIGHT_MASTER ;
    comp_rec1 comp_cur1%ROWTYPE;
    OPEN comp_cur1;
    FETCH comp_cur1 INTO comp_rec1;
    WHILE comp_cur1%FOUND
    LOOP
    kr_forthnightid:= comp_rec1.forthnight_id;
    select max(crayom_db.cr_cane_calender_period.cr_cane_calender_period_ID) into last_forthnight_id from crayom_db.cr_cane_calender_period;
    if last_forthnight_id <> 0 then
    last_forthnight_id:= last_forthnight_id + 1;
    else
    last_forthnight_id:= 1000000;
    end if;
    if ref_seasonyrid <> comp_rec1.season_yr_id then
    ref_seasonyrid:= comp_rec1.season_yr_id;
    else
    ctr:= ctr + 1;
    end if;
    SELECT cr_bpartnerid into ref_caneperiodid from crayom_db.temp where kr_bpartnerid = comp_rec1.season_yr_id;
    dbms_output.put_line(ref_caneperiodid);
    insert into crayom_db.CR_CANE_CALENDER_period(cr_cane_calender_period_ID,ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby,Enddate,name, startdate, cr_cane_calender_id) values(last_forthnight_id,11,11,comp_rec1.current_season,sysdate,100,sysdate,11,comp_rec1.end_date,'ForthNight' || ctr, comp_rec1.start_date,ref_caneperiodid);
    commit;
    FETCH comp_cur1 INTO comp_rec1;
    End LOOP;
    close comp_cur1;
    END;
    BEGIN
    pro_canefortnight_master();
    END;
    But I am getting following Error:
    Error report:
    ORA-06550: line 429, column 8:
    PLS-00103: Encountered the symbol "COMP_CUR1" when expecting one of the following:
    := . ( @ % ;
    ORA-06550: line 433, column 1:
    PLS-00103: Encountered the symbol "FETCH" when expecting one of the following:
    begin function package pragma procedure subtype type use
    <an identifier> <a double-quoted delimited-identifier> form
    current cursor
    The symbol "begi
    ORA-06550: line 472, column 1:
    PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following:
    end not pragma final instantiable order overriding static
    member constructor map
    ORA-06550: line 477, column 4:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
    end not pragma final instantiable order overriding static
    member constructor map
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause: Usually a PL/SQL compilation error.
    *Action:
    Can any body help me?
    Thank You.
    Edited by: [email protected] on Oct 22, 2009 4:36 AM

    [email protected] wrote:
    CURSOR comp_cur1 IS select * from CMS_FORTH_NIGHT_MASTER ;
    comp_rec1 comp_cur1%ROWTYPE;This is probably the issue. All variable definitions, including cursors, must be in the DEFINE section of a procedure (between either DECLARE ... BEGIN or AS/IS ... BEGIN).
    In addition I wanted to note the following:
    1. When posting it is helpful to identify your Oracle version (e.g. 10.2.0.4).
    2. Any code that is posted should be placed between \ tags to improve readability.
    3. It looks like the code is doing "slow by slow" processing (a.k.a single record processing). It could probably be made much cleaner, maintainable and better performing by possibly using INSERT .. AS SELECT ... or something along those lines.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Bug report - different episodes with same names won't update correctly in the list of pcast-episodes

    I think there was no similar report yet. Sorry if repeated.
    I use podcasts app only on my iPad - no iTunes syncing or whatsoever - as simple as possibly could be in terms of functionality.
    Background: I am subscribed to a posdcast of a radiostation programme where weekly usually same people give interviews. For example, each Tuesday the guy named A.B. is a guest of the programme. So each Tuesday episode almost always named: Interview - A.B. So 09.10.2012 there was episode named: Interview - A.B. then 15.10.2012 there is also an episode named Interview - A.B.
    Problem: even though in the list of episodes I can see these two each with correct date stamp, when I tap 15.10.12 episode to play, it would play the previous episode (of 09.10.2012). I know it's the podcasts app bug, because good old iPod app would play everything correctly.
    That's shamy.

    Very similar problem for me.  A podcast has several different episodes per day broken down by hour.  It will totally mix up the files and names and descriptions, seemingly grabbing them from random days surrounding what it should be.  Sometimes two simlarly named files will play the same audio.  It's totally messed up.  I can't figure out any pattern for this either.
    Although I'm sure it happens for podcast episodes with titles that are not similar as well.

  • Open different URLs in same window

    I'm developing a program that will be run remotely.
    Next to  each control or indicator, I have a little help button that opens up a URL with some information explaining what the control does or indicator means. The problem is that I don't want each help button to open up in a new window. I'd like to have the help info open in a pop-up window. If the user then clicks on a different help icon, then the info in the pop-up window changes (sort of like Labview Context help) as opposed to having a bunch of windows open.
    Is there anyway to control which window the URL opens in?
    Brian 

    this may help, you should look it up and see if it can be a solution.
    Message Edited by Harold Timmis on 10-11-2009 05:04 AM
    Harold Timmis
    [email protected]
    Orlando,Fl
    *Kudos always welcome
    Attachments:
    append to HTML.jpg ‏38 KB
    html vi's.jpg ‏30 KB

  • Trying to sync different 700p under same user

    Hello.  Hope someone can help.  My 700p died.  Like the calendar/planner so I bought a used one.  Trying to sync my calendar to the different 700p.  my computer and hot sync are not recongnizing the different phone.  Any hints?
    Post relates to: Treo 700p (Verizon)

    Did you Hard Reset the "new" used phone before trying to sync it?  This should be done, then when you try to sync it after erasing it, choose your original HotSync name and all the data should migrate to the phone from your computer.
    To perform a Hard Reset: (Palm Knowledgebase article #887)
    http://kb.palm.com/wps/portal/kb/common/article/887_en.html
    WyreNut
    I am a Volunteer here, not employed by HP.
    You too can become an HP Expert! Details HERE!
    If my post has helped you, click the Kudos Thumbs up!
    If it solved your issue, Click the "Accept as Solution" button so others can benefit from the question you asked!

  • Linking different processes under same workspace

    Hi..
    I have few processes under my workspace which i need to link. Like calling a process from another process ?
    Is there any way to link these process so that the flow can be continuous ???

    I am not really sure of what you are trying to do, but 1 of the options can be to send a Notification from 1 process to the other process, and have a Notification Wait activity in the called process receive it.
    HTH
    Rajat

  • PO for Plants belonging to different Country under same Company Code

    Hi,
    We have created a Company      1000 (Country u2013 India)
    We have created two Plants 1001 (Location - Delhi, India), 1002 (Location - United Kingdom).
    We have created a pricing Procedure      ZDOMES & ZIMPOR for Domestic & Imports Procurement.
    We have created a Tax Code V0, Country IN.
    We have tested the Procurement Cycle for Plant 1001 (Location - Delhi, India) and it is working fine.
    For Plant 1002 (Location - United Kingdom) what extra configuration do I need to do? Can we use the same pricing Procedure, Tax Code?
    Please advice.
    Regards,

    Thanks for the reply.
    Here in our scenario, we have created only one Company Code and one of our Branch is in UK.
    we need to create only One Company Code & Branches (Plants) in Delhi & UK
    Please suggest .
    Regards,

  • Migrate & coexist Exchange 2010 to 2010 in two different site under same domain

    Hi all,
    The initial plan was planning to coexist Exchange 2010 (old data center) & 2013 (new data center) .
    Unfortunately there was a problem of upgrading the existing exchange 2010 sp2 to 2010 sp3 and Microsoft said they don't support this anymore.
    So the only plan I can think of is build another exchange 2010 with SP3 (new data center)  to coexist with existing exchange 2010 SP2 first then followed by exchange 2013.
    I don't see any relevant info on the Internet for the coexistence of exchange 2010 SP2 and SP3. can you please share some detailed steps or info?
    Thank you very much in advanced.

    Hi all,
    The initial plan was planning to coexist Exchange 2010 (old data center) & 2013 (new data center) .
    Unfortunately there was a problem of upgrading the existing exchange 2010 sp2 to 2010 sp3 and Microsoft said they don't support this anymore.
    So the only plan I can think of is build another exchange 2010 with SP3 (new data center)  to coexist with existing exchange 2010 SP2 first then followed by exchange 2013.
    I don't see any relevant info on the Internet for the coexistence of exchange 2010 SP2 and SP3. can you please share some detailed steps or info?
    The last database upgrade exchange 2010 SP3 is unable to mount server with Exchange 2010 SP2 i.e., there is no database schema upgrade from SP1 or SP2 to SP3. Please check this link :
    https://www.youtube.com/watch?v=M4hJfdqTe5s
    You may download exchange Server 2010 Service Pack 3 from here :http://www.microsoft.com/en-us/download/details.aspx?id=36768
    This Exchange Server 2010 SP3 software may be used to perform a new installation or to update an existing Exchange Server 2010 installation to Service Pack 2 (SP2) level.
    Moreover, to migrate the mailbox database from exchange 2010 to 2013, you may consider on this exchange migration tool (http://www.exchangemigrationtool.com/) that can be a good approach for you.

Maybe you are looking for