Find the missing documents and insert accordingly

Oracle version: Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production

Hello gurus

I'm really grateful if someone would help out me. Thanks in advance

Examples of data

Drop, the creating and inserting in tables

drop table TYPE_MST;
drop table TYPE_VERSION;

-------------------------
Create Tables:

create the table TYPE_MST
(
Type_desc varchar2 (15)
);

-----------------

Table insert

insert into TYPE_MST
(
Select 'First' double
Union of all the
Select 'Second' double
Union of all the
Select 'Third' double
);

--------
create the table TYPE_VERSION
(
TYPE_DESC varchar2 (15).
MIN_AGE number (5),
MAX_AGE number (5),
VERSION_ID number (5)
);
---------
insert into TYPE_VERSION
(
Select 'First', 0, 5, 100 double
Union of all the
Select 'First', 5, 10, 100 double
Union of all the
Select 'First', 11,15, 100 double
);

---------

Queries against existing data
Select * from TYPE_VERSION;

The query result

TYPE_DESC, MIN_AGE, MAX_AGE, VERSION_ID

First                      0                5               100

First                      5                10             100

First                      11              15             100

My requirement is that system automatically inserts type_desc missing in TYPE_VERSION.

For example, we have 3 Type_Desc, first, second, third, but in the TYPE_VERSION table, we have data available for only 1 Type_Desc who is "First", this system should insert the missing data in this table using existing data.

I need result something like below:

Required result

TYPE_DESC, MIN_AGE, MAX_AGE, VERSION_ID

First                      0                5               100

First                      5                10             100

First                      11              15             100

Second 11 15 100

Second                   5                10             100

Second 11 15 100

Third                    0                5               100

Third                     5                10             100

Third 11 15 100

Thanks in advance

Concerning

Shu

Hello

It is still not clear what you want.

That's what you want for the examples you gave:

MERGE INTO dst type_version

WITH THE HELP OF)

SELECT DISTINCT

m.type_desc

v.min_age, v.max_age, v.version_id

OF type_mst m

CROSS JOIN type_version v

)                  src

WE (dst.type_desc = src.type_desc

AND dst.min_age = SRC. MIN_AGE

)

WHEN NOT MATCHED THEN INSERT

(dst.min_age, dst.max_age, dst.type_desc, dst.version_id)

VALUES (src.min_age, src.max_age, src.type_desc, src.version_id)

;

If she's going to do what you want in general depends on what you want in general.  As long as I don't know the General rules you want to set up, I don't know if it makes them or not.

This does not seem a very good design.  Why do you need a table with all possible combinations?  Sounds like you're saying, for example, if 2 lines have the same value of min_age, then have the same values for max_age and version_id, too.  This 3rd Normal violares form.  Why not have a table with the possible values for min_age max_age version_id, and simply join cross which type_mst when you need to see all possible combinations?

Tags: Database

Similar Questions

  • How to create a document and insert the words and/or art on both sides of the page

    How to create a document and insert the words and/or art on both sides of the page

    How to create a document and insert the words and/or art on both sides of the page

    You create a document by using an application of word processor like Microsoft Word or Corel WordPerfect or OpenOffice Writer.  Think of it as a broad a page roll.

    When you print the document, you can print all pages of the document on one sheet of paper (the normal default value), or you can print on both sides of a sheet of paper.

    Some printers are capable of automatic double-sided printing.  With others, you print all the odd pages and then take the stack of paper, turn upside down and put it back into the printer to print all pages.  You need either to read your printer manual, or experiment a bit to determine if you need to re - organize the first last pages before printing the second side.

  • Power outage required that I put in place a new user in Vista that I did. Now I can't find the original user and associated files. All files seem to be missing. Help?

    Laptop must have been left on. Last night power Outtage. I went back and put the computer to find guests requiring that I created a user, I did. Now, I can't find the original user and all files seem to have disappeared.  Have Vista

    Hello

    1. don't you make changes on the computer before this problem?
    2. do you remember the exact and complete message on this line?

    Check if you can find the user original files of accounts in the following path:
    C:\Users\[user account name]

    The article could be useful to you.
    Difficulty of a corrupted user profile
    http://Windows.Microsoft.com/en-us/Windows-Vista/fix-a-corrupted-user-profile

  • Find the missing series or page n

    I have a table

    document_sl_no, from_page, book_no, to_page

    1                              1          1               9

    2                              1          10             12

    3                              1          18              33

    Documents binded in the books and the Livre_No is entered in the database, so that if we find the hard copy of the document we can search easily.

    I need to write a query that miss me page in the pagination sequence book will give.

    as in the above example page No 13,14,15,16,17 are missing.

    Y at - it no way out.

    I was tring to get the sequence first then thought to find the missing sequence using advance or delay.

    So any suggestions to get the sequence of this wise Livre_No table

    Livre_No page_no

    11
    12
    13
    14
    15
    16
    17
    18
    19
    110
    111
    112
    118
    119
    120
    121
    122

    Something like this:

    books (book_no, from_page, to_page) as)
    Select 1,1,9 from all the double union
    Select 1,10,12 from all the double union
    Select double 1,18,33
    )
    run like)
    Select
    Livre_No
    from_page
    to_page
    , (from_page, 1, to_page) ahead of (Livre_No order of from_page partition)
    -to_page diff
    books
    )

    Select
    Livre_No
    from_page
    to_page
    , case when diff > 2 then
    diff-1 | "the missing pages after" | to_page
    lack of end
    leaks

    BOOK_NO FROM_PAGE TO_PAGE MISSING
    1 1 9 -
    1 10 12 5 missing pages after 12
    1 18 33 -
  • I can't find the digital unicode to insert an apostrophe in the Times New Roman font

    Unicode for the Apostrophe

    I can't find the digital unicode to insert an apostrophe in the font Times New Roman 12 size. I used the table of characters, as always and apostrophe selected. The code usually comes at the bottom of the right hand of the box, but in this case it doesn't.  Can someone advise the code please. I searched through aid, but such a simple, and I would have thought, fundimental issue does not.

    Quote the num + 0039 Alt gives me just a closing speech.

    If U + 0027 is not the character you want to what?

    ---

  • went to the command and put in findstr/c: "[SR]" %windir%\logs\cbs\cbs.log > sfcdetails.txt to find the corrupted file and nothing happened

    I had a problem with my laptop. I let a friend use it and she got a virus. The screen is black. She took it to get fixed. When she returned I couldn't open some files. (Always have this problem with some files) my shortcut icons are no longer there. Then I get this message on the Catalyst Control Center does not work. In any case, I did a scan and he told me that I had corrupted in my cbs log files so I tried to do the command findstr/c: "[SR]" %windir%\logs\cbs\cbs.log > sfcdetails.txt to find the corrupted file and nothing happened. Help!

    Hello

    Departure - in the search box, type-> order

    at the top of the list to find COMMAND - CLICK RIGHT to it - RUN AS ADMIN

    Type the following commands (or copy and paste one at a time), each followed by pressing on enter.

    ipconfig/flushdns

    nbtstat-r

    nbtstat - RR

    netsh int Reinitialis

    netsh int ip reset

    netsh winsock reset

    RESET

    That resets your TCP/IP stack

    It might also be a good idea to updare drivers network - NETWORK card (wired) and WiFi (wireless)
    by checing at the site of the manufacturer of the system/card mother and/or sites of the manufacturer of the real device.
    Methods for manual update of driver at the end of this response.

    --------------------------------------------------------------------------------------
    --------------------------------------------------------------------------------------

    For settings.ini as this article sets out the question may be totally ignored.

    The SFC.exe command reports Settings.ini file errors in the CBS.log file after that you add gadgets
    for the Sidebar of Windows Vista by using the Sysprep tool and an Autounattend.xml file.
    http://support.Microsoft.com/kb/947595

    -----------------------------------------------------------------------------------------------------------------------------

    These errors only are in the settings.ini for the sidebar and are not a serious problem by all means.

    Close the sidebar for that.

    Something else for the settings.ini - run AutoRuns and look at the entries SideBar Gadget - y at - it
    all pointing to is no longer present as temp files or uninstalled gadgets or not running?
    Those who will reflect the "yellow icons" on the left side and the files/folders will not exist. If so just
    Click on it and delete - Reboot. This may correct the errors that you see.

    Autoruns - free - see what programs are configured so that it starts automatically when your system
    boots and you login. Autoruns shows you the full list of registry and file locations where
    applications can configure Auto-start settings.
    http://TechNet.Microsoft.com/en-us/sysinternals/bb963902.aspx
    -------------------------------

    Another process to try is to remove everything except a gadget - everything what you think is the most simple, that you use.
    Maybe the calendar. Then RESTART - use another simple gadget, and delete the first class used
    -RESTART again. See if that helps.

    Rarely, the error causing the problem with the sidebar and not not affect the system in general.

    The SFC.exe command reports Settings.ini file errors in the CBS.log file after that you add gadgets to
    the Sidebar of Windows Vista by using the Sysprep tool and an Autounattend.xml file.
    http://support.Microsoft.com/kb/947595

    -------------------------------

    Another method to try with the SideBar works does not is to copy the Settings.ini to another folder and
    and then delete - then start sidebar.

    --------------------------------

    For tcpmon.ini and settings.ini:

    You can also try to restore any copy of a Vista DVD (even 32 or 64 bit however).

    Access files on your Vista installation DVD
    http://www.Vistax64.com/tutorials/86959-access-Vista-install-DVD-files.html

    How to extract system files missing from the DVD of Windows 7/Vista.
    http://blog.NirSoft.NET/2009/09/17/how-to-extract-missing-system-files-from-the-DVD-of-Windows-7vista/

    ===================================================
    ===================================================

    Also update your drivers: (WiFi (wireless), NIC (Wired) and others as required)

    This is my generic how updates of appropriate driver:

    This utility, it is easy see which versions are loaded:

    -Free - DriverView utility displays the list of all device drivers currently loaded on your system.
    For each driver in the list, additional useful information is displayed: load address of the driver,
    Description, version, product name, company that created the driver and more.
    http://www.NirSoft.NET/utils/DriverView.html

    For drivers, visit manufacturer of emergency system and of the manufacturer of the device that are the most common.
    Control Panel - device - Graphics Manager - note the brand and complete model
    your video card - double - tab of the driver - write version information. Now, click on update
    Driver (this can do nothing as MS is far behind the certification of drivers) - then right-click.
    Uninstall - REBOOT it will refresh the driver stack.

    Repeat this for network - card (NIC), Wifi network, sound, mouse, and keyboard if 3rd party
    with their own software and drivers and all other main drivers that you have.

    Now in the system manufacturer (Dell, HP, Toshiba as examples) site (in a restaurant), peripheral
    Site of the manufacturer (Realtek, Intel, Nvidia, ATI, for example) and get their latest versions. (Look for
    BIOS, Chipset and software updates on the site of the manufacturer of the system here.)

    Download - SAVE - go to where you put them - right click - RUN AD ADMIN - REBOOT after
    each installation.

    Always check in the Device Manager - drivers tab to be sure the version you actually install
    presents itself. This is because some restore drivers before the most recent is installed (sound card drivers
    in particular that) so to install a driver - reboot - check that it is installed and repeat as
    necessary.

    Repeat to the manufacturers - BTW in the DO NOT RUN THEIR SCANNER device - check
    manually by model.

    Look at the sites of the manufacturer for drivers - and the manufacturer of the device manually.
    http://pcsupport.about.com/od/driverssupport/HT/driverdlmfgr.htm

    Installation and update of drivers to 7 (update drivers manually using the methods above is preferred
    to make sure that the latest drivers from the manufacturer of system and device manufacturers are located)
    http://www.SevenForums.com/tutorials/43216-installing-updating-drivers-7-a.html

    I hope this helps.

    Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle="" -="" mark="" twain="" said="" it="">

  • I'm unable to find the missing drivers on my device manager.

    OT: Re: lack of pilots.

    Hello

    I'm unable to find the missing drivers on my device manager. A unknown device watch. Other shows, like in the storage controllers. I checked Windows update, but it does not find the missing drivers. I don't have the drivers on my CD.

    Please download and run the display driver and download a copy of the report he produced on your OneDrive. To obtain a report all drivers Select Edition, select all followed by file, save selected items.
    http://www.NirSoft.NET/utils/DriverView.html

    Please provide a copy of your system information file. Type the system information in the search box above the Start button and press the ENTER key (alternative is select Start, all programs, accessories, System Tools, system information). Select file, Export and give the file a name noting where it is located. Not to place the cursor in the body of the report before exporting the file. The system creates a new information file system each time system information is available. You must allow a minute or two before the file is completely filled before exporting a copy. Please download the file to your OneDrive, to share with everyone and post a link here. Normal mode preferred report. Please say if the report was obtained in safe mode. The request for a copy of this file is additional to answer the question about the brand and the model. If the report is in one language other than English, please indicate the language.

    For assistance OneDrive see paragraph 9.3

    http://www.gerryscomputertips.co.UK/MicrosoftCommunity1.htm

  • Find the missing numbers

    I want to find the missing of a column that is alphanumeric numbers, its last five positions are digital. In the first three places there are different combinations of alphas that is * 'BA', 'BAW","SA","SAA"... * If alphas are two then 3rd position is empty. I also need to generalize this to cover all digital series existing alpha.
    SELECT SUBSTR (a.claim_no, 4, 5) + 1
      FROM core_business.cb_pensioner a
     WHERE SUBSTR (a.claim_no, 1, 3) = 'BA '
       AND NOT EXISTS (
                     SELECT NULL
                       FROM core_business.cb_pensioner b
                      WHERE to_number(SUBSTR (b.claim_no, 4, 5)) =  to_number(SUBSTR (a.claim_no, 4, 5)) + 1) 
       order by SUBSTR (a.claim_no, 4, 5);
    I get the error ORA-01722

    You have two problems with this task.

    1 problem is how to convert a number from the back so that you can compare the values.

    to_number(SUBSTR (b.claim_no, 4, 5)) 
    

    works, but only if the b.claim_no value is always a number regardless of the other criteria of the column.

    Such an assertion

    ...
    WHERE SUBSTR (a.claim_no, 1, 3) = 'BA ' /* filter 1 */
    and to_number(SUBSTR (b.claim_no, 4, 5)) > 1 /* filter 2 */
    ...
    

    may fail because your table can have value as

    b.claimno = "XYZ1234b".

    The way you wrote the query of the database will decide what filter criteria, it first runs. It could be filter1, but could also be filter2. If filter2 is executed first, you will get the error message.

    Problem 2 how to order and compare different lines, so that you can find the missing values.

    Here the analytical function of the LEAD (LAG) is very useful. It gives you access to the next (or previous row).

    Both problems can be overcome.

    Here is my test, but I don't know if it works in your case. You may have to adapt a little.
    This should work if all lines are digital which belong to specific groups. If you have too much data incorrect in there, then a different approach is necessary.

    with testdata as (select 'XYZ1234b' claim_no from dual union all
                select 'BA 12345' claim_no from dual union all
                select 'BA 12346' claim_no from dual union all
                select 'BA 12350' claim_no from dual union all
                select 'BAW11111' claim_no from dual union all
                select 'BAW11113' claim_no from dual union all
                select 'XYZ1234b' claim_no from dual )
    /* end of test data creation */
    select claim_no, substr(claim_no, 1,3) part1, substr(claim_no, 4) part2,
           to_number(substr(claim_no, 4)) current_num,
           lead(to_number(substr(claim_no, 4))) over (partition by substr(claim_no, 1,3) order by to_number(substr(claim_no, 4))) next_num,
           lead(to_number(substr(claim_no, 4))) over (partition by substr(claim_no, 1,3) order by to_number(substr(claim_no, 4)))
            - 1 - to_number(substr(claim_no, 4))
            as "missing_values"
    from testdata
    where substr(claim_no, 1,3) in ('BAW','BA ')
    order by claim_no;
    
    CLAIM_NO PAR PART2 CURRENT_NUM   NEXT_NUM missing_values
    -------- --- ----- ----------- ---------- --------------
    BA 12345 BA  12345       12345      12346              0
    BA 12346 BA  12346       12346      12350              3
    BA 12350 BA  12350       12350
    BAW11111 BAW 11111       11111      11113              1
    BAW11113 BAW 11113       11113
    

    1 problem is solved because where condition is always executed before the function in the select clause, in particular in the context of an analytic function.
    Problem 2 is also solved by using the analytical function, function LEAD. And it's fast, because you access the same table only once. Another solution could be a subquery to extract the value of the next line. This means that multiple access to the same table and is usually much slower.

    Published by: W. Sven 20 Sep, 2010 14:32

  • How to lift a picture in a document to print it without printing the entire document, and when I ask to print at 400%, how to tell me how many pages there are, and what's on them

    I have a pix of a quilt in a document. I would like to print the page of the document to 400% to allow me to see the quilt better. When I put in my percent effects, it prints the entire document and will not allow me to move to other pages. He says his p1 1. I take a class to make this quilt. I need this pix for the class.

    Have you tried to open the image in a new tab via the context menu and a middle - click on the Image of the view and the zoom of the image (Ctrl +)?

  • I can't find the bookmarks organize and/or export bookmarks from Safari with Firefox 4

    I can't find the bookmarks organize and/or export bookmarks from Safari with Firefox 4. View that all bookmarks does not help.

    Among the small icons - rightmost - in "show all bookmarks" is an import-export. Place your cursor on them and it will say what it is.

  • How to find the value max and min for each column in a table 2d?

    How to find the value max and min for each column in a table 2d?

    For example, in the table max/min for the first three columns would be 45/23, 14/10, 80/67.

    Thank you

    Chuck,

    With color on your bars, you should have enough experience to understand this.

    You're a loop in the table already.  Now you just need a function like table Max and min. loop.  And you may need to transpose the table 2D.

  • On my iMac running training camp. I get a message saying that my PC cannot find the wireless hub and it is unable to connect to internet Explorer. Help!

    Connection Wi - Fi with internet explorer 8

    I'm under Boot Camp on my iMac with OS 10.6.8. I am connected to the hub of my son-in-law over a wireless connection.  I can access the internet using Safari on the side of the Mac of the partition successfully, but I can't access the internet by using a wireless setup on the side of the PC of the partition by using Internet Explorer 8.  I get a message saying my side PC created by Boot Camp can not find the wireless hub and is unable to connect to internet Explorer.  Help!

    Hello

    ·          What is the version of the operating system running on your computer?

    I suggest you to install the drivers for the network card on the manufacturer's Web site and check if it helps.

    http://Windows.Microsoft.com/en-us/Windows7/update-a-driver-for-hardware-that-isn ' t-work correctly

    See: http://windows.microsoft.com/en-US/windows/help/wired-and-wireless-network-connection-problems-in-windows

  • I can't locate the folder document and setting on the C drive of my computer where it is...

    I can't locate the folder document and setting on the C drive of my computer where it is...

    In Windows XP, you should be able to see by opening my computer and clicking on the C: drive.  What do you see if you are doing this? Boulder computer Maven
    Most Microsoft Valuable Professional

  • How to find the first Sunday and the second Saturday of each month

    Hi all

    How to find the first Sunday and the second Saturday of each month

    Thank you

    Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production

    994122 wrote:

    Hello

    I need to pass the months parameter how to do this? like Jan, Feb etc... (one of those)

    Do you have a procedure?

    Should you output only for the months you passed in the parameter?

    The easiest way is to set the parameter as date. When you go such as p_date as DATE ' 2014-10-01', then you can

    PROCEDURE two_dates)

    p_date IN DATE

    p_first_sunday DATE

    p_second_saturday DATE

    )

    IS

    BEGIN

    p_first_sunday: = NEXT_DAY (TRUNC (p_date, 'MM') - 1, TO_CHAR (DATE ' 2014-10-12', 'DAY'));

    p_second_saturday: = NEXT_DAY (TRUNC (p_date, 'MM') - 1, TO_CHAR (DATE ' 2014-10-11', 'DAY')) + 7;

    END two_dates;

    Or you describe what you need.

  • where can I find the latest Photoshop and Bridge updated to version PC of CS6?

    where can I find the latest Photoshop and Bridge updated to version PC of CS6?

    Adobe - Photoshop: For Windows: Adobe Photoshop 13.0.1.3 updated for CS6

Maybe you are looking for