Joining 2 related records using PL SQL in Apex - Problems when there are more than 2 related records?

Hi
I am combining 2 related records of legacy data together that make up a marriage record.  I am doing this in APEX using a before header process using the following code below which works well when there are only 2 related records which joins the bride and groom record together on screen in apex.  I have appended a field called principle which is set to 'Y' for the groom and 'N' for the bride to this legacy data
However there are lots of records where in some instances there are 3, 4 , 5, 6 or even 1 record which causes the PL/SQL in APEX to not return the correct data.  The difference in these related columns is that the name of the bride or groom could be different but it is the same person, its just that from the old system if a person had another name or was formally known as they would create another duplicate record for the marriage with the different name, but the book and entry number is the same as this is unique for each couple who get married.
How can I adapt the script below so that if there are more than 2 records that match the entry and book values then it will display a message or is there a better possible work around?  Cleaning the data would be not an option as there are thousands of rows of where these occurrences occur
declare 
     cursor c_mar_principle(b_entry in number, b_book in varchar2) 
     is 
          select DISTINCT  id, forename, surname, marriagedate, entry, book,  formername, principle
          from   MARRIAGES mar 
          where  mar.entry   = b_entry
          and    mar.book = b_book
          order by principle desc, id asc; 
     rec c_mar_principle%rowtype;
begin 
open c_mar_principle(:p16_entry,:p16_book)  ;
fetch c_mar_principle into rec;
:P16_SURNAME_GROOM   := rec.surname; 
:P16_FORNAME_GROOM   := rec.forename;
               :P16_ENTRY := rec.entry; 
               :P16_BOOK :=rec.book;
:P16_FORMERNAME :=rec.formername;
:P16_MARRIAGEDATE :=rec.marriagedate;
:P16_GROOMID  := rec.id;
fetch c_mar_principle into rec;
:P16_SURNAME_BRIDE   := rec.surname; 
:P16_FORNAME_BRIDE   := rec.forename;
               :P16_ENTRY := rec.entry; 
               :P16_BOOK :=rec.book;
:P16_FORMERNAME :=rec.formername;
:P16_MARRIAGEDATE :=rec.marriagedate;
:P16_BRIDEID  := rec.id;
close c_mar_principle;
end;

rambo81 wrote:
True but that answer is not really helping this situation either?
It's indisputably true, which is more than can be said for the results of querying this data.
The data is from an old legacy flat file database that has been exported into a relational database.
It should have been normalized at the time it was imported.
Without having to redesign the data model what options do I have in changing the PL/SQL to cater for multiple occurances
In my professional opinion, none. The actual problem is the data model, so that's what should be changed.

Similar Messages

  • How to use coditions where there are more than two options

    I have a slide that gathers information from the user and
    then makes decisions based on the values entered. On one slide i am
    using the combo widget and listing 'Basic', 'Intermediate' &
    'Advanced'. What I was hoping to do was use the Coditional
    Structure as follows:
    1. If Basic was selected goto slide BasicQuickQuiz
    2. If Intermediate was selected goto slide
    IntermediateQuickQuiz
    3. If Advanced was selected goto slide AdvancedQuick Quiz
    I can make this work for Basic or Intermediate, but I cannot
    see how (or even if) I can have a multi level IF statement.
    My work around was :
    1. On a button added the logic:
    If Basic, then got BasicQuickQuiz otherwise goto
    IntermediateQuickQuiz
    2. On Slide Enter event on IntermediateQuickQuiz:
    If Intermediate then continue, otherwise goto slide
    AdvancedQuick Quiz
    This works, but seems clumsy - is there any other way this
    could be achieved?
    Tim

    What I was hoping to see was the ability to create multiple
    Else If statements within the one condition. I have changed this
    now to add two Conditional Statements one after the other, but
    still find this functionality to be lacking.
    I will log a feature request to add a Select Case / Switch
    style of fuction to this group.
    However, given that this is new I am can live with the
    workflow (for this version of Cp anyhow!!)
    Tim

  • There are more than 1000 users using query based on sales group and sales ?

    Hi all,
    for a project activities sales group need to have authorization object? but if they make the object authorized and moved to production, all the other 1000 users gets effected to this changes since they dont have access to it.
    Can anyone let me know how to handle this?
    let me explain in detail,
    there are different markets like india, china, hongkong , south east asia,
    for a particular project, only south east asia people needs to have authorization on sales group . but there are 500 users in south east asia, so once changes is moved it will affect the existing users too?
    So can anyone advise me how to handle this?
    Thanks

    HI Pooja,
    Create roles as per authorization you have to give to users.
    Create user groups - for different users depending on the countries where they belong - as you mentioned users belong to India,
    China,
    Hongknog,
    South east asia
    Eg, Create 1 role and give auth object for south east asia users. If you want to give particular authorization to 1 user only from among 500 users. create 2 roles with different authorizations and assign accordingly.
    Regards,
    Chitra

  • Problem with XML Publisher report when there are no detail records.

    I am working on an Oracle XML Publisher procurement report (Oracle E-Business Suite R12) that starts with a budget amount that is imported from our financial system, then lists all requisitions and orders that are in process (not approved). The amounts of all those unapproved requisitions/orders are totaled using a Sum form field, to be followed by a field where the unapproved requisition/order total is subtracted from the budget amount (amount available). I am running into a problem when there are no unapproved requisitions. When I run the report for such instances, it completes with a warning -- here is what it states in the OPP log:
    oracle.xdo.parser.v2.XPathException: Extension function error: Method not found 'sum'
    I have altered my sum field on the RTF template to include an if statement in case of a null value...
    <?sum (EXTENDED_COST)?> <?xdofx:if sum (EXTENDED_COST) = " then 0 end if?>
    ...but this does not work.

    Hi,
    You are on right track. Simply put summary field in header group and remember to set reset at property to Header Group Not Child and now you can use this field in format trigger.
    Format trigger must be written on header frame.
    Cheers !
    Adinath Kamode

  • There is an unclosed comment block in the SQL statement. Ensure that there are balanced "/*" and "*/" comment markers in the SQL statement.

    I get this error - when I try a Multi-line comment entry - by using the /* and */
    "There is an unclosed comment block in the SQL statement. Ensure that there are balanced "/*" and "*/" comment
    markers in the SQL statement."
    Even though I am entering both the /* and the */.
    I tried it many way - in the same line, in different lines etc..
    like 
    /* Select xxx from xxx */
    or
    Select xxx from xxx
    or 
    /* Select xx from xx
    Please help anyone..! ;=(

    But When I do a Help/About I see that it is 
    the SSMSE's Help About screen says "SQL Server 2005"
    However I downloaded and installed SQL Server 2014 last night and was entering queries..
    Most Select Queries work fine..
    the -- comment line works fine..then I stumbled on the /*  - */ does not work.
    Thanks.
    Well, you have two different version of SQL Server installed on your machine. Please connect again from SSMS to the SQL Server 2014.
    T-SQL Articles
    T-SQL e-book by TechNet Wiki Community
    T-SQL blog

  • When using iPhoto can I remove some of the default options such as faces or  flagged etc. There are more bits than I need for my basic use.

    When using iPhoto can I remove some of the default options such as faces or  flagged etc. from the left bar. There are more bits than I need for my basic use.

    Hello Susan,
    Not sure if I have fully understood your question but have you tried ...
    iPhoto > iPhoto help > browse help > view and organise.  Perhaps this touches on some of your needs.
    Usually, best results for questions come from posting to the forum directly related to the question, in this case iPhoto.  That tends to find the gurus
    Would you like me to ask the hosts to relocate your question?  

  • Connection Pool becomes unusable infrequently when there are SQL exceptions

    Hi,
    Can someone help?
    When there are many SQL exceptions thrown, the entire Pool connections on Weblogic
    6.1 sp2 become unusable, and I need to re-start Weblogic. And it gives me these
    errors:
    java.lang.ClassCastException: weblogic.rjvm.ClassTableEntry
    at weblogic.rjvm.MsgAbbrevInputStream.getMethodDescriptor(MsgAbbrevInputStream.java:262)
    at weblogic.rmi.internal.BasicServerRef.dispatch(BasicServerRef.java:148)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:195)
    at weblogic.rjvm.RJVMImpl.dispatchRequest(RJVMImpl.java:642)
    at weblogic.rjvm.RJVMImpl.dispatch(RJVMImpl.java:589)
    at weblogic.rjvm.ConnectionManagerServer.handleRJVM(ConnectionManagerServer.java:164)
    at weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:637)
    at weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java:454)
    at weblogic.socket.PosixSocketMuxer.deliverGoodNews(PosixSocketMuxer.java:456)
    at weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:385)
    at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:24)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    Can someone tell me what's going on?
    Thanks

    Ed wrote:
    Hi,
    Can someone help?
    When there are many SQL exceptions thrown, the entire Pool connections on Weblogic
    6.1 sp2 become unusable, and I need to re-start Weblogic. And it gives me these
    errors:If you can show us some of the SQLExceptions, it would help. The problem below is
    not jdbc-related.
    Joe
    >
    >
    java.lang.ClassCastException: weblogic.rjvm.ClassTableEntry
    at weblogic.rjvm.MsgAbbrevInputStream.getMethodDescriptor(MsgAbbrevInputStream.java:262)
    at weblogic.rmi.internal.BasicServerRef.dispatch(BasicServerRef.java:148)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:195)
    at weblogic.rjvm.RJVMImpl.dispatchRequest(RJVMImpl.java:642)
    at weblogic.rjvm.RJVMImpl.dispatch(RJVMImpl.java:589)
    at weblogic.rjvm.ConnectionManagerServer.handleRJVM(ConnectionManagerServer.java:164)
    at weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:637)
    at weblogic.rjvm.t3.T3JVMConnection.dispatch(T3JVMConnection.java:454)
    at weblogic.socket.PosixSocketMuxer.deliverGoodNews(PosixSocketMuxer.java:456)
    at weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:385)
    at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:24)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    Can someone tell me what's going on?
    Thanks

  • We are a creative design studio, we need to use apple mac pro server , so we can make more than a different user to use at the same time doing different activities, on different screens, is it possible?what is the max. no. of users that can work efficient

    we are a creative design studio, we need to use apple mac pro server , so we can make more than a different user to use at the same time doing different activities, on different screens, is it possible?what is the max. no. of users that can work efficient.
    Appreciate your support and if possible , how to do this?

    If you want to work with Mac OS X, you need one computer per simultaneous user.
    What you are describing, " Multiple simultaneous logins to a single computer" is not avialable on a regular Mac of any description, unless you decide to use Unix tools instead of Mac OS X.
    Server will happily store files for many, many users and provide them to multiple (up to hundreds) of computers at "near hard Drive" speeds over Gigabit Ethernet. It can make the File Sharing part easy.

  • After several years of use very satisfied with Firefox, recently loaded version (4.0.1) severely slows my browsing, and even my system, especially when there are pictures or videos. I said that this was not the case before and my system is Windows XP SP3.

    After several years of use very satisfied with Firefox, recently loaded version (4.0.1) severely slows my browsing, and even my system, especially when there are pictures or videos. I said that this was not the case before and my system is Windows XP SP3.

    I have had a similar problem with my system. I just recently (within a week of this post) built a brand new desktop. I installed Windows 7 64-bit Home and had a clean install, no problems. Using IE downloaded an anti-virus program, and then, because it was the latest version, downloaded and installed Firefox 4.0. As I began to search the internet for other programs to install after about maybe 10-15 minutes my computer crashes. Blank screen (yet monitor was still receiving a signal from computer) and completely frozen (couldn't even change the caps and num lock on keyboard). I thought I perhaps forgot to reboot after an update so I did a manual reboot and it started up fine.
    When ever I got on the internet (still using firefox) it would crash after anywhere between 5-15 minutes. Since I've had good experience with FF in the past I thought it must be either the drivers or a hardware problem. So in-between crashes I updated all the drivers. Still had the same problem. Took the computer to a friend who knows more about computers than I do, made sure all the drivers were updated, same problem. We thought that it might be a hardware problem (bad video card, chipset, overheating issues, etc.), but after my friend played around with my computer for a day he found that when he didn't start FF at all it worked fine, even after watching a movie, or going through a playlist on Youtube.
    At the time of this posting I'm going to try to uninstall FF 4.0 and download and install FF 3.6.16 which is currently on my laptop and works like a dream. Hopefully that will do the trick, because I love using FF and would hate to have to switch to another browser. Hopefully Mozilla will work out the kinks with FF 4 so I can continue to use it.
    I apologize for the lengthy post. Any feedback would be appreciated, but is not necessary. I will try and post back after I try FF 3.16.6.

  • Hi, I've checked how to use kannada keyboard in Yosemite. But, there are some 'vattu forms' and other grammar in Kannada language that I don't know how to use it. For eg, Preetiya taatanige nimma muddu mommagalu maduva namaskara? How to write this?

    Hi, I've checked how to use Kannada keyboard in Yosemite. But, there are some 'vattu forms' and other grammar in Kannada language that I don't know how to use it. I know how to change between the keyboards and can also view keyboard. However, For eg, 'Preetiya taatanige nimma muddu mommagalu maduva namaskara' How to write this? If anybody can answer this, very much appreciated.
    Thanks in advance for your reply.

    In general, you need to use the "f" (kannada qwerty keyboard) or "d" key (kannada) between letters to make special forms.  Also you may need to adjust the typography settings of the font, which is done by doing Format > Font > Show Fonts > Gear Wheel > Typography as shown below.  If you can provide screenshots or more detailed info on things you cannot make, I can perhaps help.
    It is important to note that MS Word for Mac does not support Indic scripts -- any other app should work OK.

  • Using the App Store, it shows that there are two upgrades.  When itap upgrades, nothing comes up.

    Using the App Store, it shows that there are two upgrades.  When itap upgrades, nothing comes up.

    I'm sorry that you ran into trouble with syncing fonts to your Creative Cloud application.  Please try these troubleshooting steps:
    http://help.typekit.com/customer/portal/articles/1649149
    If that doesn't help, send the log files mentioned in that page to [email protected] and we will look into it further.  Thank you,
    -- liz

  • I have just owned a macbook pro and trying to learn things since i have all along used windows laptop. My first question is : when there are two files i am working together, one above the other on screen, how you switch over between the two with key ?

    I have just owned a macbook pro and trying to learn things since i have all along used windows laptop. My first question is : when there are two files i am working together, one above the other on screen, how you switch over between the two with key ?

    Hi...
    Mac OS X keyboard shortcuts
    Control-F4
    Move focus to the active (or next) window
    Shift-Control-F4
    Move focus to the previously active window
    By the way...  since you are new to Mac, click a clear space on your Desktop. You should see "Finder" top left corner of the screen in the menu bar.
    Click Help then click Help Center
    As an example type in    keyboard shortcuts
    You can use the Help menu for almost any application on your Mac.
    Apple - Find Out How - Mac Basics
    For held switching from PC to Mac >  Apple - Support - Switch 101

  • Can you use Live Office to post a Spread Sheet to more than your own inbox?

    Can you use Live Office to post a Spread Sheet to more than your own inbox?
    I have a spread sheet that I want to send to 5 different inboxes, Can I do this with LiveOffice
    Thanks
    Jeff

    Hi Jeff,
    Live Office's purpose is to allow Crystal and Web I content to be imported into Excel. Basically it allows BO data be displayeed and refreshable inside eXcel.
    If you are using CR to develop the report you can set eXcel as the output format and send it to peoples inboxes. You might be able to do the same with csv for Web I
    Regards
    Alan

  • VO fetches 25 records, when there are 150 in the iterator.

    Hi All,
    I'm using View Objects as part of my AD form. In the bean associatd with the form, in one fo my methods, I loop through the Iterator associated with this VO.
    I notice that only 25 records are being fetched, even though the number of rows is clearly more than that. I've looped through usinga for loop and printed each and every record within the VO and it only prints 25.
    How can I tune this VO to bring back all my records at once?Will it always only bring back 25 at a time?
    JDev-11g used.
    The code I use to bring back the rows is :
    int numRows = vo.getRowCount();
    System.out.println("*Number of rows*" + numRows); // This returns 150
    for (int i = 0; i < numRows; i++) {
    System.out.println("Role data" + roledata);
    I'm trying to print out each line's role data : I notice only 25 printed lines in the logs.
    //some code
    What am I doing incorrect here?
    Thanks
    Preethi.
    Edited by: 859810 on 08-Aug-2011 02:38

    On the page go to bindings - executables - select the iterator and set its range size to -1.
    setting -1 will fetch all the records
    Edited by: in the line of fire on Aug 8, 2011 1:41 PM

  • Splitting to multiple files in file adaptor when it's more than 100 records

    Hi,
    I have a scenario where I'm generating a xml file to the receiver using file adaptor I need to write 100 records per file, if it's more than 100 then I need to write into a different file, to say I need to have 100 records per file.
    ABAP Proxy > PI- >File
    Any help is really appreciated.
    Thanks,
    Joe.P

    Hi Joe,
    What is your source structure and what is your destination structure?
    You can go the ABAP proxy route but then your control is not in the integration layer but in the business system.  But if you prefer it, here's some code outlined:
    data:
    index type i,
    lcl_proxy type ref to ZCL_Proxy.
    i = 0.
    try.
    loop at lt_recordset into ls_record.
    append ls_record to lt_output.
    index = index+1.
    if index = 100.
    create object lcl_proxy.
    lcl_proxy->execute_asynchronous(output = lt_output).
    index = 0.
    clear lt_output.
    endif.
    end loop.
    if index>0.
    create object lcl_proxy.
    lcl_proxy->execute_asynchronous(output = lt_output).
    endif.
    catch CX_ROOT.
    endtry.
    commit-work.

Maybe you are looking for

  • How to download applications from the Creative Cloud?

    i have paid to join creative cloud. Where is the download area to download the suite Title of this message was edited by a moderator.

  • My Mac Mini running yosemite 10.10.3 constantly freezes

    my mac mini runs slow & freezes after updating to 10.10.3

  • Integrated Planning Project Plan

    Hi everybody, Can anyone share with me an Integrated Planning sample project plan? I just want a have some idea about the global tasks and detail activities. A sample could be good. thanks a lot! Mike Mora

  • Frames randomly changing?

    Hi, I'm using Adobe Premiere Elements 11 in order to make a parody series and I've been experiencing a weird and very annoying problem recently. See, what I have to do in a lot of the editing is use lip flaps of the animated characters to match up to

  • IPhone stuck on gestures (Pinch) screen - can't power off

    Hi hi - My home button died a few days ago so I've been using the Accessibility version, the onscreen white spot. While adding new gestures via the "spot", the Gestures menu froze with only the Pinch option showing in the top-left (but not functionin