Process one set of primary and secondary records at a time

Need to read and analyze all service lines for every claim
I wrote these Statements but they are in a never ending state despite of the fact of setting the claims range to one day.
Thank you for any suggestions.
Harry
set serveroutput on
declare
v_claim1 varchar2(12):='080010000000';
v_claim2 varchar2(12):='080019999999';
fd_claim varchar2(12):=' ';
mismatch number:=0;
v_outfile UTL_FILE.FILE_TYPE;
v_outfile_name constant varchar2(100):= 'prvmm.dat';
v_outfile_dir constant varchar2(100):= 'AVMED_TEMPDATA';
w_line varchar2(44);
v_claim claim.claim_nbr%type;
buffer varchar2(100);
status integer;
cursor get_clm is
select claim_nbr from claim
where claim_nbr between v_claim1 and v_claim2
and rownum < 100
order by claim_nbr;
cursor get_srvline is
select claim_nbr, serv_nbr, aff_nbr from service_x
where claim_nbr = fd_claim;
type serv_t is table of get_srvline%rowtype;
serv serv_t;
begin
V_OUTFILE := UTL_FILE.FOPEN(V_OUTFILE_DIR,V_OUTFILE_NAME,'w');
OPEN get_clm;
--OPEN get_srvline;
LOOP
fetch get_clm into v_claim;
DBMS_OUTPUT.PUT_LINE(v_claim);
DBMS_OUTPUT.GET_LINE(buffer,status );
DBMS_OUTPUT.PUT_LINE('Buffer: '||buffer);
DBMS_OUTPUT.PUT_LINE('Status: '||to_char(status));
--while get_clm%found
--while rownum < 100
LOOP
fd_claim:= v_claim;
OPEN get_srvline;
fetch get_srvline bulk collect into serv;
CLOSE get_srvline;
mismatch:=0;
FOR i in 1..serv.count LOOP
if serv(1).aff_nbr <> serv(i).aff_nbr then mismatch:=1;
end if;
END loop;
if mismatch = 1 then
FOR i in 1..serv.count LOOP
w_line:=serv(i).claim_nbr||serv(i).serv_nbr||serv(i).aff_nbr;
UTL_FILE.PUT_LINE(V_OUTFILE,w_line);
END LOOP;
end if;
END LOOP;
--close get_srvline;
close get_clm;
UTL_FILE.FCLOSE(V_OUTFILE);
DBMS_OUTPUT.PUT_LINE ( serv.count );
END LOOP;
END;

Hi,
Welcome to the forum!
Here's your code with some whitspace added, to make it readable:
set serveroutput on
declare
     v_claim1 varchar2(12):='080010000000';
     v_claim2 varchar2(12):='080019999999';
     fd_claim varchar2(12):=' ';
     mismatch number:=0;
     v_outfile UTL_FILE.FILE_TYPE;
     v_outfile_name constant varchar2(100):= 'prvmm.dat';
     v_outfile_dir constant varchar2(100):= 'AVMED_TEMPDATA';
     w_line varchar2(44);
     v_claim claim.claim_nbr%type;
     buffer varchar2(100);
     status integer;
     cursor get_clm is
            select claim_nbr from claim
            where claim_nbr between v_claim1 and v_claim2
            and rownum < 100
            order by claim_nbr;
     cursor get_srvline is
            select claim_nbr, serv_nbr, aff_nbr from service_x
            where claim_nbr = fd_claim;
     type serv_t is table of get_srvline%rowtype;
     serv serv_t;
begin
     V_OUTFILE := UTL_FILE.FOPEN(V_OUTFILE_DIR,V_OUTFILE_NAME,'w');
     OPEN get_clm;
     --OPEN get_srvline;
     LOOP
          fetch get_clm into v_claim;
          DBMS_OUTPUT.PUT_LINE(v_claim);
          DBMS_OUTPUT.GET_LINE(buffer,status );
          DBMS_OUTPUT.PUT_LINE('Buffer: '||buffer);
          DBMS_OUTPUT.PUT_LINE('Status: '||to_char(status));
          --while get_clm%found
          --while rownum < 100
          LOOP
               fd_claim:= v_claim;
               OPEN get_srvline;
               fetch get_srvline bulk collect into serv;
               CLOSE get_srvline;
               mismatch:=0;
               FOR i in 1..serv.count LOOP
                       if serv(1).aff_nbr <> serv(i).aff_nbr then mismatch:=1;
                    end if;
               END loop;
               if mismatch = 1 then
                       FOR i in 1..serv.count LOOP
                            w_line:=serv(i).claim_nbr||serv(i).serv_nbr||serv(i).aff_nbr;
                         UTL_FILE.PUT_LINE(V_OUTFILE,w_line);
                    END LOOP;
               end if;
          END LOOP;
          --close get_srvline;
          close get_clm;
          UTL_FILE.FCLOSE(V_OUTFILE);
          DBMS_OUTPUT.PUT_LINE ( serv.count );
     END LOOP;
END;The reason why it won't stop is that neither of the two outer LOOPs has any way of stopping.
If you want to fetch one row from a cursor in a loop, and contine the loop as long as you keep getting rows, then use a cursor FOR loop, like this
FOR  v_claim  IN get_clm
LOOP
        DBMS_OUTPUT.PUT_LINE(v_claim);
END LOOP;You do not need OPEN, FETCH or CLOSE statements when using a cursor FOR loop.
If you do want to use OPEN, FETCH and CLOSE, then the loop that FETCHes the data should test for %NOTFOUND, and EXIT when it is true, like this:
OPEN  get_clm
LOOP
        FETCH  get_clm  INTO  c_claim
        EXIT WHEN get_clm%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(v_claim);
END LOOP;
CLOSE  get_clm;Always format your code to show the range of LOOPs and IF statements.
When posting on this site, type these 6 characters:
&#123;code&#125;
(small letters only, inside curly brackets) before and after formatted text, to preserve spacing.

Similar Messages

  • Set Primary and Secondary Interfaces

    How can I set up primary and secondary network interfaces, so that it will automatically fallback to the second interface when I don't have the primary connected? I tether my phone to T-Mobile's network, but when I don't have it connected it want it to fall back to my wired connection.

    Sorry, I only bump my own posts when I've added additional information to my last post and I see that no one has added anything to it in the past few days. I guess I would be better to create a new post instead of editing the old one.
    I did give it a try and I have no real results to share. I created the two profiles in the /etc/netctl directory and named them as above (including Priority=1 for the tmobile connection and Priority=2 for the wired connection, as stated in the wiki entry even though man netfcfg.profile says it's only for wireless connections), then I enabled the service. There is the word "interface" after systemctl enable netctl-ifplugd@ which makes me think I should specify an interface but I have no idea which one to specify, so I just enabled it without it and it didn't complain. There's no way to start it. Both connections are enabled but it seems to default to the wired connection for some reason, when I want it to default to the tmobile connection and then fall back to the wired connection. Both are enabled and have IP addresses but nothing changes when I connect or disconnect my mobile data connection since it's using the wired connection.
    edit: I just tried to enable the service using the interface name of my mobile data connection and it didn't change anything ex. sudo systemctl enable netctl-ifplugd@enp0s26f7u3
    Last edited by brando56894 (2013-07-31 21:44:57)

  • Need help with sorting records in primary and secondary databases

    Hi,
    I would like to store data into primary and secondary db in different order. For the main primary, I want it to be ordered by login_ts instead of uuid which is the key.
    For the user secondary database, I want it to be ordered by sip_user. For the timestampe secondary db, I want it to be ordered by login_ts.
    This is what I have right now,
    this is for main
    uuid=029ae227-a188-4ba8-aea4-7cbc26783d6 sip_user=200003 login_ts=1264327630 logout_ts=
    uuid=22966f76-8c8a-4ab4-b832-b36e8f8e14d sip_user=200003 login_ts=1264327688 logout_ts=
    uuid=e1846e4a-e1f5-406d-b903-55905a2533a sip_user=200003 login_ts=1264327618 logout_ts=
    uuid=e2f9a3cb-02d1-47ff-8af8-a3a371e20b5 sip_user=200003 login_ts=1264327613 logout_ts=
    this is for user search
    uuid=029ae227-a188-4ba8-aea4-7cbc26783d6 sip_user=200003 login_ts=1264327630 logout_ts=
    uuid=22966f76-8c8a-4ab4-b832-b36e8f8e14d sip_user=200003 login_ts=1264327688 logout_ts=
    uuid=e1846e4a-e1f5-406d-b903-55905a2533a sip_user=200003 login_ts=1264327618 logout_ts=
    uuid=e2f9a3cb-02d1-47ff-8af8-a3a371e20b5 sip_user=200003 login_ts=1264327613 logout_ts=
    this is for timestamp
    uuid=029ae227-a188-4ba8-aea4-7cbc26783d6 sip_user=200003 login_ts=1264327630 logout_ts=
    uuid=22966f76-8c8a-4ab4-b832-b36e8f8e14d sip_user=200003 login_ts=1264327688 logout_ts=
    uuid=e1846e4a-e1f5-406d-b903-55905a2533a sip_user=200003 login_ts=1264327618 logout_ts=
    uuid=e2f9a3cb-02d1-47ff-8af8-a3a371e20b5 sip_user=200003 login_ts=1264327613 logout_ts=
    but what I want is :
    this is for main
    uuid=e2f9a3cb-02d1-47ff-8af8-a3a371e20b5 sip_user=200003 login_ts=1264327613 logout_ts=
    uuid=e1846e4a-e1f5-406d-b903-55905a2533a sip_user=200004 login_ts=1264327618 logout_ts=
    uuid=029ae227-a188-4ba8-aea4-7cbc26783d6 sip_user=200003 login_ts=1264327630 logout_ts=
    uuid=22966f76-8c8a-4ab4-b832-b36e8f8e14d sip_user=200005 login_ts=1264327688 logout_ts=
    this is for user search
    uuid=e2f9a3cb-02d1-47ff-8af8-a3a371e20b5 sip_user=200003 login_ts=1264327613 logout_ts=
    uuid=029ae227-a188-4ba8-aea4-7cbc26783d6 sip_user=200003 login_ts=1264327630 logout_ts=
    uuid=e1846e4a-e1f5-406d-b903-55905a2533a sip_user=200004 login_ts=1264327618 logout_ts=
    uuid=22966f76-8c8a-4ab4-b832-b36e8f8e14d sip_user=200004 login_ts=1264327688 logout_ts=
    this is for timestamp
    uuid=e2f9a3cb-02d1-47ff-8af8-a3a371e20b5 sip_user=200003 login_ts=1264327613 logout_ts=
    uuid=e1846e4a-e1f5-406d-b903-55905a2533a sip_user=200003 login_ts=1264327618 logout_ts=
    uuid=029ae227-a188-4ba8-aea4-7cbc26783d6 sip_user=200004 login_ts=1264327630 logout_ts=
    uuid=22966f76-8c8a-4ab4-b832-b36e8f8e14d sip_user=200004 login_ts=1264327688 logout_ts=
    Right now, I have:
    int compare_login_ts(dbp, a, b)
         DB *dbp;
         const DBT a, b;
         int time_a = 0;
         int time_b = 0;
         time_a = atoi ( (char *)a->data);
         time_b = atoi ( (char *)b->data);
         return time_a - time_b ;
    for the timestamp secondary, I set that compare function:
              if ((ret = (*sdb)->set_bt_compare(*sdb , compare_login_ts )) != 0){
    Does anyone know how can I make it sorted according?

    Hi,
    The DB->set_bt_compare() is used to compare keys in Btree database. In the callback function, both the DBTs are key, but not data. Please refer to http://www.oracle.com/technology/documentation/berkeley-db/db/api_reference/C/dbset_bt_compare.html.
    If you want any field in the data to be sorted, you might create a secondary index on it and define the compare function as you wish.
    Regards,
    Emily Fu, Oracle Berkeley DB

  • HT2477 I just purchased the IMac and was in the process of setting it up and got locked out.  A password is being requested and I did not establish one.  Is there a default password for the imac?

    I just purchased the iMac and was in the process of setting it up and it locked up, requiring me to put in a password.  I never established a password, does the iMac have a default password?

    If you have been using the mac.com Apple ID to make iTunes purchases recently, then there should be no issues continuing to use it with the new iPhone. I would abandon the new ID as you will never get Apple to merge the two IDs. I have had a mac.com ID for years and continue to use it with my iPhone 4S.
    Tell us the issues that you encounter trying to set up the iPhone with the mac.com account.

  • Setting up a primary and secondary Database in Oracle 10G

    Hi Experts
    can you please tel me the steps involved in creation of primary and secondary database? This is the first time i am going to configure this setup. Please provide your helping hands.
    Thanks alot in advance,
    Ram

    Absolutely glad to help.
    Step 1: Clarify what it is you are trying to build. Are you talking about a Standby Database? Perhaps Physical or Logical Data Guard? If so what protection mode? Stand-alone or RAC? Or are you just trying to dup an existing database on another server in which case you can just use RMAN.
    Step 2: Go to http://tahiti.oracle.com and read the relevant docs
    Step 3: Go to http://metalink.oracle.com and look at the Knowledge Base docs
    If you have any question thereafter contact us and be sure to include your version number, not a marketing label. 10g is a marketing label that refers to everything from the 10.1 Beta through 10.2.0.4.

  • Is it possible to set primary and secondary display with 2 graphics cards?

    I have an Early 2008 Mac Pro with two graphics cards and four monitors installed. Does anyone know how the computer (or more specifically Keynote) determines which is the primary display and which is the secondary?
    Also is there any way to change the scheme?
    What I am trying to do is switch the primary and secondary from the two monitors in my office to the monitor at the podium (would like it to become primary) and a vga projector (would like it to become secondary)
    I bought the second graphics card so I wouldn't have to switch the cables back and forth three times a week. All the monitors work fine, it's just a matter of determining or changing primary/secondary
    Thanks in advance

    Thanks Malcolm
    I got that far – The keynote manual says that the display with the menu bar is the primary display – that works out fine. The problem is that the manual says that the display without the menu bar is the secondary (or alternate). But there are three displays without the menu bar.
    What I would like to find out is: is there a way to choose the display without the menu bar to be the alternate?
    When I try various combinations, there seems to be no rhyme or reason as to which display is the alternate.
    Thanks again for your response!

  • Magic Mouse Primary and Secondary Clicks Switched

    Recently I picked up a Magic Mouse and have since found some very strange things that I don't know how to fix:
    The primary and secondary clicks are switched. As in, under mouse settings when I select the secondary click to be on the right, only the primary click works on the right side and everything else is a secondary click. It is also very annoying because every time I have more than one finger touching the surface it counts as a secondary click. If anyone knows how to fix this I would really appreciate feedback.
    I looked around in settings and couldn't find anything regarding this matter. I fiddled with some stuff but never got it working properly.
    Feedback much appreciated!
    --Justin

    Looking at another thread in this forum, I see some people who had older apple mice installed before the magic mouse are having this problem with the magic mouse.
    I had an older wireless mouse that would take right-clicks before I set up the magic mouse. Unfortunately when I connect the older wireless mouse I can no longer access it's preferences. It only gives me the preferences a generic one button mouse. Somewhere there must be some set of files I can delete and it will forget this old mouse.
    I am pretty disheartened after a week of this. One of the benefits to a mac is that I shouldn't have to dig around removing drivers and such

  • How can I modify one column of current and next record depending of some criteria?

    Having DDL
    CREATE TABLE #ServiceChange(
    [ID] [int] identity(1,1),
    [SHCOMP] [char](2) NOT NULL,
    [SHCRTD] [numeric](8, 0) NOT NULL,
    [SHCUST] [numeric](7, 0) NOT NULL,
    [SHDESC] [char](35) NOT NULL,
    [SHTYPE] [char](1) NOT NULL,
    [SHAMT] [numeric](9, 2) NOT NULL,
    [CBLNAM] [char](30) NOT NULL,
    [GROUPID] [char](2) NULL
    And original and desire data in below link
    https://www.dropbox.com/sh/bpapxquaae9aa13/AADnan31ZASublDjN7sa2Vvza
    I would like to know how can I modify one column of current and next record depending of some criteria using SQL2012?
    The criteria is:
    Type should always flow F->T
    if current abs(amount)> next abs(amount) then groupid = 'PD'
    if current abs(amount)< next abs(amount) then groupid = 'PI'
    there is no case when those amounts will be equals
    where current(custid) = next(custid) and current(service) = next(service) and groupid is null
    Any help will be really apreciated.
    Thank you

    I tried that and got this error
    'LAG' is not a recognized built-in function name.
    You said you were using SQL 2012, but apparently you are not. The LAG function was added in SQL 2012. This solution works on SQL 2005 and SQL 2008:
    ; WITH numbering AS (
       SELECT groupid,
              rowno = row_number()  OVER (PARTITION BY custid, service ORDER BY date, id)
       FROM   #ServiceChange
    ), CTE AS (
       SELECT a.groupid,
              CASE WHEN abs(a.amount) < abs(b.amount) THEN 'PD'
                   WHEN abs(a.amount) > abs(b.amount) THEN 'PI'
              END AS newgroupid
       FROM  numbering a
       JOIN  numbering b ON b.custid  = a.custid
                        AND b.service = a.service
                        AND b.rowno   = a.rowno - 1
    UPDATE CTE
    SET   groupid = newgroupid
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to bind the Zero line between a primary and secondary Y axis?

    All -
    We are using combination charts with:
    - primary and secondary Y axis (Sales versus Volume).
    - Scale: Auto (Y) Axis
    - Linear
    - Fixed Label Size
    In instances where one axis has a negative value and the value ranges are diverse the Zero line will be different for both. This causes some confusion when trying to read. Other that putting in manual (Y) axis with min and max, is there a way to force the chart to keep the same Zero line?
    Thanks!

    KOENIG Yvan wrote:
    It's quite a basic requirement for a spreadsheet program
    It's your point of view. It seems that it's not the designers's one
    Obviously, true
    The number of different features described once as "a basic requirement" is really amazing but a feature asked once is perhaps not one which must be added to a program like Numbers.
    Other tools are available for professional numbers crunchers .
    I know there are other threads asking about secondary axes, but your point is taken. I'm definitely not a number cruncher, but I am/was a pretty advanced Excel user.
    _Go to "Provide Numbers Feedback" in the "Numbers" menu_, describe what you wish.
    Then, cross your fingers, and wait _at least_ for iWork'09
    Thanks for that, I didn't quite know where to go for the feedback - provided and fingers crossed.
    Cheers!

  • Can't find my DNS Primary and Secondary

    Dear God, I need my DNS primary and secondary. I'm trying to set my xbox 360 up with it's own ip ect. I've gone to my airport to get this information but my DNS is the same as the IPv4 router. My xbox requires a DNS primary and secondary. The only thing I can find for my DNS is a Domain Name and Server address: 10.0.1.1 Do I put this number in my xbox for the DNS with no secondary?

    I think your router is not configured properly for your internet connection. Router is not giving out a valid DNS to the computers because it cannot obtain it (dns) from the modem. Is your connection Cable or DSL?

  • Windows 8.1 screen bounces between primary and secondary monitors

    I have a Lenovo T530 laptop with a docking station and a IBM monitor L200P attached to it.
    Up until yesterday, this configuration was running Windows 8 Pro with no issues.
    However today, after I installed the Windows 8.1 upgrade, I started having problems with the screen bouncing between the primary and secondary monitors without my intervention. The problem happens very regularly, regardless of whether I have selected the laptop as primary monitor or the IBM monitor attached to the docking station.
    I verified that the problem does not happen with Windows 7 and Windows 8 installation and only starts appearing after the Windows 8.1 upgrade is applied.
    Does anybody have similar problems
    Thank you in advance.

    O''philipp [[#answer-697652|said]]''
    <blockquote>
    another thing you could try is this: enter '''about:config''' into the firefox address bar (confirm the info message in case it shows up) & search for the preference named '''layout.css.devPixelsPerPx'''.
    double-click it and change its value to '''1.2''' (or any other zoom factor that fits your purpose: 1.0 relates to 100%, 1.2 equals 120% and so on; -1.0 is the default value and will adhere to the system settings).
    </blockquote>
    Okay, I tried it, set it to 1.2 and even more stuff got blurry and fuzzy. Besides everything in the FF menu bar everything in the header on youtube and a few other pages did it too. It did make the pages fill the actual page better, but the blur is worse than this prob so I set it back to -1.0.
    Any other ideas?

  • ITunes U course published but I can't see my school in the Primary and Secondary Schools list

    I don't know how to contact the responsable of the iTunes U administration to send an email and change the name of my school.
    I want to change  Villaviciosa De Odón - Colegio Pax-Casvi into "Eurocolegio Casvi".  Anyway, even my organization has been approved for courses publishing, I can't find the name of my school at the list of iTunes U "Primary and Secondary" schools.
    If I go to https://itunesu.itunes.apple.com/audit/633264363, the course is in the iTunes U.

    you might want to check on this possibility:
    No music shows up in iTunes after upgrading

  • Primary and secondary Email accounts

    Hello,
    Is there a way to specify primary and secondary email account ? In case if the primary server is down, the secondary server would be used for sending the notification.
    Thanks.

    I am implementing something similar to what you have suggested. I was wondering if there is a way to achieve this by just changing configuration. Looks like it is not possible to configure it and coding it is the only way out.
    Thanks for your inputs :)

  • My computer was rebuilt this week and I am in the process of setting up iTunes and have a weird setup issue. The music in my playlists plays but the same song doesn't play from the library. Initially, I opened ITunes while holding down Shift of control.

    My computer was rebuilt this week and I am in the process of setting up iTunes and have a weird setup issue. The music in my playlists plays but the same song doesn't play from the library. Initially, I opened ITunes while holding down Shift of control key.

    Scratch the post above - the musics that plays in the playlist also plays in the library and that is because i forgot that i imported from the cd yesterday. Basically, I see the rest of my music, but it doesnt' play and tells me it can't locate the file though the location in 'perferences' points to the correct location. Getting iTunes to play after a new computer or rebuild is a headache.

  • P965 Neo-f - primary and secondary ide channel stops working after changing gpu

    I just changed my graphic card from 4850 to 4870x2 and then my idd devices stopped working, and when I look in device manager the primary and secondary ide channel has a yellow exclamationmark over them. And the error msg is as follow: This device cannot find enough free resources that it can use. (Code 12)
    And when I look on the tab resources the two I\O range tabs have a red cross like over them probably meaning there is something wrong. And in the column Conflicting devies list: Input/Output Range 01F0 - 01F7 not available.
    Input/Output Range 03F6 - 03F6 not available.
    What I have tried so far:
    Updating the bios, looking for I\o range crashes and irq crashes, uinstalling and reintalling severals times. And when I change back to my old 4850 card the problems disappears straight away.
    Any ideas?

    Quote from: Crispin on 28-April-09, 20:15:49
    Well reality says something different  :D
    And a reinstall fixed the problem. I find this post very amusing.
    Ill bet your graphics doesnt even use its full potential on that board.
    Me thinks it severly limited by the board and the cpu and imo a waste of a good graphicscard/money.
    Its better to use only 2 slots of mem because of the strain you put on your memorycontroller when using 4 slots.
    When running " double dualchannel"  the memorycontroller can be overflooded when running too high mem.speeds, with errors and BSOD and crashes as a result.

Maybe you are looking for

  • IMessage not working new sim

    I am running a an iPhone 5s on Verizon and I am currently abroad and bought a sim card in Europe frpm Vodafone and my iMessage will I not register my new number when my sim Is in, my friend got one at th same time and theres automatically connected a

  • Loudness Radar not an option in Audio Effects

    I'm running the current version of Premiere Pro 6 and need to start monitoring loudness. I was under the impression from what I've been researching that Loudness Radar is standard with Premiere Pro. But I don't see it as an option in my audio effects

  • HT4623 I cannot find "software update" in "general"

    Trying to update iPad to iOS5 to stream Netflix movies???

  • Verity Collection Bloat

    I recently had a problem where the 'parts' directory in my search collection began to bloat with tons of files resulting in a HUGE and unexpected bill from my hosting company (a shared host). I had the following set to run every hour <cfindex collect

  • Why do I have two profiles stored in my profile folder?

    I recently started having some issues with my laptop - I can't run a restore operation and I can't run a complete scan with my "SuperAntiSpyware" program. The spyware program always hangs up on a Firefox file. When I started troubleshooting the Firef