How to get this challenge of output using joint?

We will create a document XML E2B to query an Oracle Argus Pharmacovigilance DB.  Problem is when trying to generate the tag < drugs >.

-A drug (or product) can have multiple schemas.

-A drug can have several indications.

If a product has several treatment regimens and the indications must be created 1 < drugs > tag to each plan and each indication. However, let us assume that there is only 1 sign and 1 plan, we should produce 1 single tag. If we have 2 regimens and directions 1, we should be producing 2 labels. 1 label must include 1 plan and 1 sign and the other tag should have the indication of information etc...

Like this:

If a drug (product) 1 indication and 1 plan we should output like this:

< drugs >

< scheme > 1 < / plan >

< indication > 1 < / indication >

< / drugs >

If the drug has 2 indications and 2 diagrams then we should output like this:

< drugs >

< scheme > 1 < / plan >

< indication > 1 < / indication >

< / drugs >

< drugs >

< system > 2 < / plan >

< indication > 2 < / indication >

< / drugs >

If a drug has 2 directions and following the 1 pattern, we should output like this:

< drugs >

< scheme > 1 < / plan >

< indication > 1 < / indication >

< / drugs >

< drugs >

< indication > 2 < / indication >

< / drugs >

If a drug has 1 indication and 2 diagrams, then like this:

< drugs >

< scheme > 1 < / plan >

< indication > 1 < / indication >

< / drugs >

< drugs >

< system > 2 < / plan >

< / drugs >

and so on...


I am trying to create a query to get the records to do this, but have problems.  I created 3 examples of tables with test data. It seems that this can be done by using joins. I do not know. Can someone tell me

drop table Case_Prod_Indications_;

drop table Case_Dose_Regimens_;

drop table Case_Product_;

Create Table Case_Product_

(

Number of Case_Id

Number of Seq_Num,

product_id VARCHAR2 (5).

reported_Name Varchar2 (15).

Constraint Case_Product_Pk Primary Key (Case_Id, Seq_Num)

);

Create Table Case_Dose_Regimens_

(

Number of Case_Id

Number of Seq_Num,

Number of Log_No

Regimen_Description Varchar2 (20).

Constraint Case_Dose_Regimens_Pk Primary Key (Case_Id, Seq_Num, Log_No),

Constraint Regimens_2_Product_Fk Foreign Key (Case_Id, Seq_Num) made reference Case_Product_ (Case_Id, Seq_Num)

);

Create Table Case_Prod_Indications_

(

Number of Case_Id

Number of Prod_Seq_Num

Number of Seq_Num,

Indication Varchar2 (25).

Constraint Case_Prod_Ind_Pk Primary Key (Case_Id, Prod_Seq_Num, Seq_Num),

Constraint Foreign Key (Case_Id, Prod_Seq_Num) to indics_2_Product_Fk references Case_Product_ (Case_Id, Seq_Num)

);

Case_Product_ p, Case_Dose_Regimens_ r's Case_Prod_Indications_ I

We always want an output for a particular case_id ONLY.

Scenario1: Product has only been inserted to case_product, with no product_id, but with a reported indication.

INSERT INTO case_product_ VALUES (100, 1, NULL, 'Panadol');

COMMIT;

Output should be: 1 plug as shown below

p.case_id p.seq_num p.product_id, p.reported_name, r.regimen_description, i.indication

100                 1                         null                          Panadol                          null                                       null

Request used:

Select

P.Case_Id, P.Seq_Num, P.Product_Id, P.Reported_Name, R.Regimen_Description, I.Indication

Of

Case_Product_ P

Left outer join Case_Dose_Regimens_ R (P.Case_Id = R.Case_Id And P.Seq_Num = R.Seq_Num)

Outer join Case_Prod_Indications_ left I on (P.Case_Id = I.Case_Id And P.seq_num = I.Prod_Seq_Num)

WHERE

p.case_id = 100;

Output is OK? : YES.

Scenario2: Product diagrams a.

INSERT INTO case_product_ VALUES (200, 10, 3, "Disprin");

INSERT INTO case_dose_regimens_ VALUES (3, 1, 10, 200 mg');

INSERT INTO case_dose_regimens_ VALUES (200, 10, 2, 5 mg');

COMMIT;

Output should be: 2 records as shown below

p.case_id p.seq_num p.product_id, p.reported_name, r.regimen_description, i.indication

200                10                          3                          Disprin                          3mg                                         null

200                10                          3                          Disprin                          5mg                                         null

Request used: same as above, but with case_id = 200.

Select

P.Case_Id, P.Seq_Num, P.Product_Id, P.Reported_Name, R.Regimen_Description, I.Indication

Of

Case_Product_ P

Left outer join Case_Dose_Regimens_ R (P.Case_Id = R.Case_Id And P.Seq_Num = R.Seq_Num)

Outer join Case_Prod_Indications_ left I on (P.Case_Id = I.Case_Id And P.seq_num = I.Prod_Seq_Num)

Where

p.case_id = 200;

Output is OK? : YES.


Scenario3: Product has patterns AND directions. Here, there are more indications that treatment regimens.

INSERT INTO case_product_ VALUES (300, 30, 5, "Aspirin");

INSERT Into Case_Dose_Regimens_ Values (300, 30, 1, 65 MG');

INSERT INTO case_prod_indications_ VALUES (300, 30, 1, 'Bread');

INSERT INTO case_prod_indications_ VALUES (300, 30, 2, 'Vomiting');

COMMIT;

Output should be: 2 records as shown below

p.case_id p.seq_num p.product_id, p.reported_name, r.regimen_description, i.indication

300                30                               5                          Asprin                          65MG                                    Pain

300                30                               5                          Asprin                          null                                         Vomiting

Request used: same as above, but with case_id = 300.

Select

P.Case_Id, P.Seq_Num, P.Product_Id, P.Reported_Name, R.Regimen_Description, I.Indication

Of

Case_Product_ P

Left outer join Case_Dose_Regimens_ R (P.Case_Id = R.Case_Id And P.Seq_Num = R.Seq_Num)

Outer join Case_Prod_Indications_ left I on (P.Case_Id = I.Case_Id And P.seq_num = I.Prod_Seq_Num)

Where

p.case_id = 300;

Output is OK? : No. we get 65MG for the 2nd record as well.

Scenario4: Product has patterns AND directions. Here there are patterns and equal information.

INSERT Into Case_Dose_Regimens_ Values (4, 2, 30, 300 kg');

commit;

Output should be: 2 records as shown below

p.case_id p.seq_num p.product_id, p.reported_name, r.regimen_description, i.indication

300                30                          5                          Asprin                               65MG                                    Pain

300                30                          5                          Asprin                               4kg                                        Vomiting

Request used: same as above.

Output is OK? : no today, we get 4 rows.

Scenario5: Product has patterns AND directions. Here, there are patterns more than indications.

INSERT Into Case_Dose_Regimens_ Values (6, 3, 30, 300 g');

commit;

Output should be: 3 discs as shown below

p.case_id p.seq_num p.product_id, p.reported_name, r.regimen_description, i.indication

300                     30                               5                                    Asprin                          65MG                               Pain

300                     30                               5                                    Asprin                          4kg                               Vomiting

300                     30                               5                                    Asprin                          6g                                         null

Request used: same as above.

Output is OK? : No. now we get 6 entries.

How we do this? Or can not use joins and perhaps another method?

Any help would be greatly appreciated.

Hello

I see it; you need in a few lines of possible exit, until all rows in related tables are included.  You don't care which line of case_dose_regimens gets paired with what line of case_prod_indications, you want just the 1st row of each table (or the 1st line of a table, if there is no matching data in the other) together on the 1st row of output and the 2nd row of each table set on 2nd line , and so on and in what order is used to define the "1st" and "2nd" is not important.  Is this fair?

If so, then use the ROW_NUMBER analytic functions to assign numbers (I called it r_num) to identify the 1st, 2nd,... lines, like this:

WITH schema AS

(

SELECT case_id, seq_num, regimen_description

, ROW_NUMBER () OVER (PARTITION BY case_id, seq_num)

ORDER BY log_no - or what you want

) AS r_num

OF case_dose_regimens_

)

directions,

(

SELECT case_id, prod_seq_num, indication

, ROW_NUMBER () OVER (PARTITION BY case_id, prod_seq_num)

ORDER BY seq_num - or what you want

) AS r_num

OF case_prod_indications_

)

SELECT p.case_id, p.seq_num, p.product_id, p.reported_name

r.regimen_description

i.indication

OF case_product_ p

LEFT OUTER JOIN

(diagram r

FULL OUTER JOIN indication I have ON i.case_id = r.case_id

AND i.prod_seq_num = r.seq_num

AND i.r_num = r.r_num

)

ON p.case_id = COALESCE (r.case_id

i.case_id

)

AND p.seq_num = COALESCE (r.seq_num

i.prod_seq_num

)

WHERE p.case_id (300)

ORDER BY p.case_id, p.seq_num

, COALESCE (r.r_num, i.r_num)

;

Tags: Database

Similar Questions

  • One for the era: how to get this output using REGULAR EXPRESSIONS?

    How to get the bottom of output using REGULAR EXPRESSIONS?
    SQL> ed
    Wrote file afiedt.buf
    
      1* CREATE TABLE cus___addresses    (full_address                   VARCHAR2(200 BYTE))
    SQL> /
    
    Table created.
    
    SQL> PROMPT Address Format is: House #/Housename,  street,  City, Zip Code, COUNTRY
    House #/Housename,  street,  City, Zip Code, COUNTRY
    SQL> INSERT INTO cus___addresses VALUES('1, 3rd street, Lansing, MI 49001, USA');
    
    1 row created.
    
    SQL> INSERT INTO cus___addresses VALUES('3B, fifth street, Clinton, OK 74103, USA');
    
    1 row created.
    
    SQL> INSERT INTO cus___addresses VALUES('Rose Villa, Stanton Grove, Murray, TN 37183, USA');
    
    1 row created.
    
    SQL> SELECT * FROM cus___addresses;
    
    FULL_ADDRESS
    ----------------------------------------------------------------------------------------------------
    1, 3rd street, Lansing, MI 49001, USA
    3B, fifth street, Clinton, OK 74103, USA
    Rose Villa, Stanton Grove, Murray, TN 37183, USA
    
    SQL> The REG EXP query shouLd output the ZIP codes: i.e. 49001, 74103, 37183 in 3 rows.
    Published by: user12240205 on June 18, 2012 03:19
    /* Formatted on 2012/06/18 17:25 (Formatter Plus v4.8.8) */
    SELECT REGEXP_SUBSTR ((REGEXP_SUBSTR (full_address, '[^,]+', 1, 4)), '[[:digit:]]+') RESULT
      FROM cus___addresses
    
  • Hi there is a balance of $20 showing on my Itunes account, however I don't seem to be able to use it to download a movie to rent.  Can someone tell me please how to get this balance...

    Hi there is a balance of $20 showing on my Itunes account, however I don't seem to be able to use it to download a movie to rent.

    Can someone tell me please how to get this balance...

    What happens when you try to rent the movie? If you use a family sharing and that you are the family Organizer so you won't be able to use your balance.

  • I reinstalled adobe CS6. my other macs, I had a printer named 'Adobe PDF', that I could choose that as my printer and a dialogue box came up, I named the file and the location.  I can't figure out how to get this done on my new mac.  Help

    I reinstalled adobe CS6. my other macs, I had a printer named 'Adobe PDF', that I could choose that as my printer and a dialogue box came up, I named the file and the location.  I can't figure out how to get this done on my new mac.  Help

    There are two ways to create a PDF on a Mac:

    (1) you can use the default method, which is to choose file > print. Click on the PDF menu below on the left, then click on save as PDF. This lets you name and save the PDF file using the mechanism of OS X to create PDF files.

    (2) in the same menu, you can save in Adobe PDF format. It runs a script (a little slow) that lets choose you what PDF settings file you want to use. This is the Adobe-developed mechanism that replaces the old Virtual PDF printer.

  • How to get more themes online, to use as a wallpaper?

    Original title: wallpaper

    How to get more themes online, to use as a wallpaper?

    I would like to know how.

    Thank you, with best regards,
    Ana Luisa 22

    Microsoft has a huge Gallery of themes and wallpapers which you can see here:

    Background screen Windows Gallery

    And you can also use your favorite search engine to find images to use also.  Just looking for pictures and when you see one that you like, right click to save it.  Later, you can go where you've saved (probably your photos or download folder) and right click any image for "(définir comme fond d'écran)."

  • CODE - 641 Windows update has encountered an error of unkonwn. How to get this right

    CODE - 641 Windows update has encountered an error of unkonwn.  How to get this right

    Try to run the tool:

    http://support.Microsoft.com/mats/windows_update/

  • Why I get this message when you use the magnetic lasso tool: "WARNING: no pixel is selected to more than 50 percent."  The edges of the selection will be not visible. ?

    Why I get this message when you use the magnetic lasso tool: "WARNING: no pixel is selected to more than 50 percent."  The edges of the selection will be not visible. ?

    See here:

    WARNING: no pixel is selected more than 50%

  • Please tell me how to get this blue screen error and "pop - up to warning off my screen". I can't use my laptop HP Pavillion with Windows 7 yet.

    Apparently, I have a virus. The episode began with an announcement of repair that kept popping up when I arrived at my first website through google Crome. This is the address "... peep...» "something. He said that I had to call a tech to 844-332-2558 microsoft and they would help me to solve the problem. So I did and discovered that it would cost me money. Now I don't know if this has anything to do with it, but I fell for the free 'update' thing to Windows 10. I hated this upgrade, couldn't use it and could not know even where to go to understand. Then, after much hassle and I mean DAYS going from one place to another to return to windows 7, I downloaded the "Magic jellybean" sahow me how to find the "product key" to go back to 7. You see, in 2013 or 2014, that I went to Missouri to help a friend who could undergo surgery. I bought this laptop in a pawn shop (Tiger pawn in Columbia, Missouri). It did not come with an installation cd. I already have t PROVIDED with Windows 7 on the laptop. When I tried to go back to Windows 7 from windows 10, and received the product of the drive key, well, when I entered on the screen provided, he says that the key is incorrect. I went cross-eyed trying to verify the accuracy of what I entered a second time. I called Microsoft who directed me to HP. HP said that this loaptop was conducted in Iran, according to me, he said. In any case, they said they couldn't help. Long story short, I finally was able to restore a setting the date early and returned to 7. BUT, since I get a msg saying that I didn't have a "true copy" of Windows 7. This msg is permanently on my rt, lower corner of the plate. Now I have this error screen and use my lap top. It's the whole story!

    Please run the Microsoft Genuine Diagnostics Tool then copy and paste the results into an answer here for further analysis:
    http://go.Microsoft.com/fwlink/?LinkId=52012

    The episode began with an announcement of repair that kept popping up when I arrived at my first website through google Crome. This is the address "... peep...» "something. He said that I had to call a tech to 844-332-2558 microsoft and they would help me to solve the problem.

    He's a crook. Ignore them, block it and delete.

    Avoid the scams of tech support phone - Microsoft

    and

    Support scam - Wikipedia, the free encyclopedia

    Is there a COA sticker attached to the laptop that might be able to tell what version and edition are pre-installed?

    COA certificate of authenticity:

    http://www.Microsoft.com/howtotell/content.aspx?PG=COA

    ??

    What is the certificate of authenticity for Windows?

    http://Windows.Microsoft.com/en-us/Windows7/what-is-the-Windows-certificate-of-authenticity

  • Qosmio G20-102 TV TUNER: how to get this to work - what cables are required?

    Hey everybody,

    I just installed vista on my laptop QOSMIO G20-102 (PQG20), I have media library now.
    My laptop came not like MEDIA CENTER EDITION, it came under the home edition of Windows XP (laptop purchased in July 2005).
    I got 3 cables which I have no idea how to use...
    laptop was purchased in Dubai/Emirates and I live in Malta

    These are the cables >
    http://img399.imageshack.us/img399/7189/dsc00780gi6.jpg

    Now for my question (s):
    1 which of these cables do I need? Im just trying to figure out how to get my satellite tv or digital cable to work on my laptop.
    2 antenna adapter (see picture) is not for coaxial cable, what can I do?
    3 I did WINDVR more due to the upgrade of vista, Media Center Gets the job done but I don't know what to do... This guide has confused me even more > http://www.microsoft.com/windowsxp/mediacenter/using/setup/settop.mspx
    I don't have IR control cable, I do not have a remote sensor (but I have some sort of built in the remote sensor on the front of my laptop.

    I'm looking for advice as for example buy this, get rid of it, install this etc...
    Please, anything that can help is appreciated!
    If you need information more just ask, I am here ;)

    Yours sincerely
    Ishmael

    Hi ismael,.
    I'll try to help with that, but it's a long way to the road...
    I don't know what Tv system is used to Malta (Pal)?

    The best way to set up your TV's with Media Center 2005 edition.
    Cables:
    Check the back of your cable TV installation box and find the composite or SVHS output. If you have only the composite, you can use the composite cable of the posted image. If your TV decoder has the SVHS, so you should use, to the better image than composite. You must obtain a SVHS cable for this.
    Look for the audio output rca, too. Mix with the composite cable for the audio Qosmio.

    But you must have:
    1 control cable IR, for media center 2005 configuration as well as your TV decoder. It is cable connected to the remote sensor (see fact sheet on the back).

    2 sensor for your remote control and configure it with the remote control of your TV decoder. In this way, you can control the receiver cable channels, using the remote control for your Qosmio G20 media center edition.
    Recovery: you can change the channels on your TV decoder using the qosmio remote control.

    3. remote control for you media Center 2005, one that came with your Qosmio g20.

    Open the TV on Media Center 2005 configuration and follow all the steps required for installation.
    You must follow the guide, as is explained in the image you posted:
    http://www.Microsoft.com/windowsxp/mediacenter/using/Setup/SetTop.mspx

    If you have all these cables, you can use the Qosmio player to watch TV. It is not tied to windows OS.
    Here, simply connect the coaxial cable and let the Qosmio player search for available channels in your area. Qosmio player has the opportunity to set the colour TV system in any part of the world. all NTSC regions in all PAL regions.
    If you have the remote control for your Qosmio, TV keys will work directly with the Qosmio remote sensor on board, without needing the external sensor of Microsoft.

    I hope this helps you
    Francisco

  • Instructions immediately talk about Firefox window, but does not say how to get this window.

    It took me almost an hour to get to this point. I am technologically challenged. I have an old version of Firefox. The instructions immediately embark on the 'Firefox window' but says nothing about how to access this window. Where this window? Maybe I should just download Opera?

    "Firefox" means Firefox, this is the window that appears when Firefox is opened.

    You must follow the directions to update to the latest version Firefox update to Firefox 33.0.2 (read to the bottom of the page to see the screenshots). This will take you to the most recent version of Firefox, and then we can help you with other problems you're having with Firefox.

    If you are a beginner in Firefox, try to start with Firefox – an overview of the main features of the reading

  • Have updated to F.F.6, I always get this error evertime I use it. [Message: [Javascript Application] TypeError: Components.classes[@softage.ru/skype/SkypeFfExtension;1'] is undefined - HELP

    Whenever I use f.f.. I get this error. [TypeError: Components.classes['@softage.ru/skype/SkypeFfExtension;1'] is undefined

    Anyone find it and or know how to remove it?

    Thanks a lot for your help and your support

    Extension to remove/disable Skype

    Uninstalling the modules

    Check and tell if its working.

  • How to get this effect?

    Hey guys, new user first here sorry in advance if this is a stupid question. Does anyone know how to get the effect that appears around: 14 in the next video? Where the waves fill the outline of the girl, but not big thing.

    Escape to exist • white s/s 16 on Vimeo

    Background scene on track V1

    Contrast shot of the girl on the floor V3

    Coup waves on track V2 with effect hides by applied approach, effect hiding approach specifying track V3 as source material Composite using Matte Luma, you will need to check the box to reverse the effect if it is darker as the background,

    MtD

  • Could someone tell me how to get this effect please?

    Hi all

    Use photoshop or illustrator, can someone tell me how I can get this effect of a normal picture please? I really like this effect.

    Thank you

    Sallyimage.jpeg

    It looks like the oil paint filter, with perhaps a slight blur. (Could be the picture too; every photo reacts differently). Oil paint is located under the filter > esthetics > oil painting. (Note that it is the latest version of Photoshop CC).

  • How to get this capacity planner &amp; what is its requirements?

    Hi friends,

    I'm looking for this product in the world, but its not available anywhere? How can we get this software? Is there a trial version? What is its needs, someone can explain to me please?

    Thank you!

    AFAIK Capacity Planner is only available for VMware partners, and the people using it are asked to take training online as well as a brief review.

    André

  • How to get host real cpu/mem using vCloud API?

    I try to get the actual use of the processor and memory for the host esxi with the vCloud API. Until know I figured out how to get total cpu/memeory available. However, I don't find a way to get use. Is this possible?

    You must use the vSphere API to retrieve that:

    http://pubs.VMware.com/vSphere-50/topic/com.VMware.wssdk.apiref.doc_50/Vim.host.summary.QuickStats.html

Maybe you are looking for

  • How to disable the "click to play" Bar warning

    Hello I would like to know how to change the behavior of the "Click to play" warning, or how turn it off. I have Firefox 27 (beta update channel, the version prior to RC1).I configured the plugin Flash to "ask every time", and "plugins.click_to_play"

  • Officejet 5610 - IP address

    How can I change the IP address for the Officejet 5610 to 192.168.1.1 to 192.168.7.1? Thank you BRU

  • Tecra S1 disk USB 2.0 external BACK

    I use Norton Ghost 2004 with an external drive USB 2.0 for backup.External drive works very well BACK in BIOS 2.00 External drive is not recognized back in the BIOS 2.1, 2.2 and 2.3. Is there a solution?

  • vicious circle to re - install Skype when the original msi file is missing

    I recently had problems with Skype, so I decided to uninstall and reinstall... maybe a newer version, I don't know, but that's not relevant. The point is that when I try to uninstall, it tells me that I can't do it (even when I run the task as an adm

  • Satellite L745 - how to remove the keyboard safely?

    Hello, people! I need help please. As the topic says, how to remove the keyboard?It's because I shared tea on my keyboard and, fortunately, no key was damaged. However, now it is sticky, and it is quite annoying! Can someone please help me with the e