Trying to simplify multiple steps into one - please help

I have a set up of steps to perform on 3 tables in order to populate two tables, please suggest best way (performance wise) to do this
CREATE TABLE AE
  EID    VARCHAR2(100 BYTE),
  UKEY   VARCHAR2(1000 BYTE),
  TNAME  VARCHAR2(10 BYTE)
CREATE TABLE TAB1V
  PID    VARCHAR2(100 BYTE),
  PUKEY  VARCHAR2(100 BYTE)
(join ae and tab1v with this condition: ae.ukey = tab1v.pukey);
CREATE TABLE PES
  EID    VARCHAR2(100 BYTE),
  UKEY   VARCHAR2(100 BYTE),
  TNAME  VARCHAR2(1000 BYTE)
(join condition with other tables, use ukey)
insert into ae (eid,ukey,tname) values ('eid1','ukey123','tname123');
insert into ae (eid,ukey,tname) values ('eid2','ukey123','tname123');
insert into ae (eid,ukey,tname) values ('eid3','ukey222','tname222');
insert into ae (eid,ukey,tname) values ('eid4','ukey222','tname222');
insert into ae (eid,ukey,tname) values ('eid5','ukey456','tname456');
insert into ae (eid,ukey,tname) values ('eid6','ukey789','tname789');
insert into ae (eid,ukey,tname) values ('eid7','ukey789','tname7891');
insert into pes(eid,ukey,tname) values('eid2','ukey123','tname123');
insert into pes(eid,ukey,tname) values('eid6','ukey789','tname789');
insert into pes(eid,ukey,tname) values('eid5','ukey456','tname456');
insert into pes(eid,ukey,tname) values('eid2','ukey123','tname123');
insert into tab1v(pid,pukey) values ('pid1','ukey123');
insert into tab1v(pid,pukey) values ('pid2','ukey222');
insert into tab1v(pid,pukey) values ('pid3','ukey111');
insert into tab1v(pid,pukey) values ('pid4','ukey456');
insert into tab1v(pid,pukey) values ('pid5','ukey789');my goal:
i have to populate two tables
1. result_table
CREATE TABLE RESULT_TABLE
PID VARCHAR2(100 BYTE),
UKEY VARCHAR2(100 BYTE),
EID VARCHAR2(100 BYTE),
TNAME VARCHAR2(100 BYTE),
SRC VARCHAR2(4 BYTE)
2. no_match table
CREATE TABLE NO_MATCH
PID VARCHAR2(100 BYTE),
UKEY VARCHAR2(100 BYTE),
my flow of logic:
1. check all the rows that are common to both tab1v and ae table (by joining with ukey),
if there are ukeys that are present in tab1v table, but absent in ae table, populate
them in no_match table, I got this with below query
select pid,pukey from tab1v
where not exists
(select ukey from ae
where ae.ukey = tab1v.pukey);
result of no_match table should be:
pid3 ukey111
for all those rows that match, probably populate in a staging table
CREATE TABLE STG_TABLE1
PID VARCHAR2(20 BYTE),
UKEY VARCHAR2(100 BYTE),
TNAME VARCHAR2(100 BYTE),
EID VARCHAR2(100 BYTE)
insert into stg_table1(pid,ukey,eid,tname)
select a.pid,b.ukey,b.eid,b.tname
from tab1v a, ae b
where A.PUKEY = b.ukey
2.After doing point 1, So if I find common rows in both tab1v and ae table (present in stg_tab1), pick up those records and check if they are present in pes table ?
join stg_table1 and pes table with ukey again
3. populate records found / and not found in point 2, do the following check and populate result_table
for records found in both stg_table1 (in other words, present in both ae and tab1v) and pes, do the following check
if each ukey has multiple same tnames attached to it (ukey123 has tname123, twice ), src should be A
if there is unique tname per ukey (ukey456 has only tname456), src should be A
if each ukey has multiple different tnames (ukey 789 has tname789 and tname7891), they should be populated and src column should be B
result_table should be like below :
PID     UKEY     EID     TNAME SRC
pid1     ukey123     eid1     tname123 A
pid1     ukey123     eid2     tname123 A
pid4     ukey456     eid5     tname456 A
pid5     ukey789     eid6     tname789       B
pid5     ukey789     eid7     tname7891      B
pid2     ukey222     null     tname222 A
pid2     ukey222     null     tname222 A
for records found in stg_table1 but absent in pes, populate the above table and same following check, but assign null to eid : (last 2 rows in above data)
following can be used to find difference
select pid,ukey,tname from stg_table1
where not exists
(select ukey from pes
where pes.ukey = stg_table1.ukey);
if each ukey has multiple same tnames attached to it (ukey222 has tname222, twice ), src should be A
if there is unique tname per ukey src should be A
if each ukey has multiple different tnames they should be populated and src should be B (none in my example data)
I am getting the results in individual sql statements, but how do I populate result_table and no_match with above data, given the above source data with minimal sql statements and considering performace as a key factor ?

Why so many unanswered questions? 66 (47 unresolved) . Are they really unanswered? Please review your 47 unresolved questions and give credit to the people with either HELPFUL or ANSWERED as appropriate. They will appreciate it.
Please provide you 4 digit Oracle version number.
In 11g you could use the INSERT ALL multi-table insert to do this: http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9014.htm
See the above doc at 'The next examples insert into multiple tables' where you will find this excerpt:
>
INSERT ALL
WHEN order_total < 1000000 THEN
INTO small_orders
WHEN order_total > 1000000 AND order_total < 2000000 THEN
INTO medium_orders
WHEN order_total > 2000000 THEN
INTO large_orders
SELECT order_id, order_total, sales_rep_id, customer_id
FROM orders;
>
This will let you insert into both tables with one query. Your query can use an OUTER JOIN between your tables so that the key value will be NULL when a record is not found. Then your WHEN condition will check the key value and if NULL will insert into one table and if NOT NULL will insert into the other.
Should not be a need for a staging table. Try to modify the example in the doc for your tables.

Similar Messages

  • Trying to combine multiple reports into one

    We have several reports that are targeted to a certain group, for example, one version for the employee to pull their own sales info, one version for supervisors to pull their information for all subordinates, and one version for management and accounting
    to pull information for all employees.  I have a solution to combine the employee and supervisor reports by using the login ID of the user and showing them "my" and "my subordinates" information.  But, I can't figure out a way
    to combine the management "all" option.  When an employee logs in, they will have a drop down to choose themself and one or more subordinates (if applicable).  But they will only see the employee names that are under them.  My CFO
    needs a report to show all employees but he is not the supervisor.  When he logs in, he needs to see a drop down with all employee names.
    Does anyone have any ideas for combining all of these options into one report? 
    Milissa Hartwell

    Hi Milissa,
    Based on your description, you have three report: employee, supervisors, management and accounting. When an employee use their Login ID login the report, they will have permission to access their own information and their supervisors’ information. You have
    meet issue how to configure CFO access permission.
    In your case, we can use subreport to work around the issue. We can use three subreport to contain these three report. Then, pass the Login ID to filter these data in corresponding report. According to your description, you have a report which is contains
    full information for all employees. Then, we can use Visibilities property to control this subreport’s visibility.  For example: =IIF(Fields!LoginID.Value=”CFO”, False, True)
    Alternatively, we can use drillthrough to open the corresponding report. The Following document is for your references.
    Subreports: http://technet.microsoft.com/en-us/library/dd239314.aspx
    Drillthrough Reports:
    http://msdn.microsoft.com/en-us/library/ff519554.aspx
    If you want to achieve the same effect use SQL query, I recommend you post a thread in the
    Transact-SQL forum. It is appropriate and more experts will assist you.
    If there are any misunderstanding, please feel free to let me know.
    Regards,
    Alisa Tang
    Alisa Tang
    TechNet Community Support

  • Trying to combine multiple PDF into one file

    I have several of my daughters online assignments that I scanned in then converted to a PDF. But, now I need to make them into one document but cant find how to do that.  I am using Adobe Reader X.

    The PDF Pack online service can also combine PDF files.

  • How do I scan multiple pages into one pdf file using the PIXMA MG7520 on Windows 8.0? Please help!

    I recently received a PIXMA MG7520 for a gift.  It works great with my lenovo laptop/tablet running on Windos 8.0.  The one drawback to the HP all-in-one that it replaced is it does not have an ADF.  That being said, there must be some way to scan multiple pages into one pdf file.  I need help figuring thing out.  Thanks in advance!
    Solved!
    Go to Solution.

    Hi mdtolbert54,
    There is a program that comes with the printer called the IJ Scan Utility that can assist you with scanning multiple pages into a single PDF document.  To do this, please follow these steps:
    1. On your keyboard, press the Windows key.
    2. Start typing IJ SCAN UTILITY. The search window opens as you type. Once the IJ SCAN UTILITY is displayed, please select and open it.
    3. In the Canon IJ Scan Utility window that opens, click SETTINGS.... in the bottom right of the window. The Settings dialog box appears.
    4. Click the DOCUMENT SCAN option on the left pane of the window.
    5. In the SAVE SETTINGS section of the window, you will select the save format and location of the document you are about to scan.
    a.) In the FILE NAME field, specify the name you would like to give the file. By default the filename will begin with IMG; you can remove IMG and change it to whatever you would like to name the file.
    b.) In the DATA FORMAT field, use the drop-down arrow to select the PDF (Multiple Pages) option. 
    c.) In the SAVE IN field, please navigate to the area where you would like the file to be saved once it is scanned in. By default, the file will be saved in the MY DOCUMENTS folder.
    6. Once all settings have been selected, click the OK button at the bottom of the window to save the changes. The IJ Scan Utility main screen appears.
    7. Click the DOCUMENT button. Scanning starts. Click the CANCEL button to cancel scanning if needed. Scanned items are saved in previously selected folder location specified in the SETTINGS... window.
    If you find that you need advanced scanning options such as adjusting resolution, brightness, contrast, saturation, color balance, etc. in addition to the options selected above, please click on the SCANGEAR button on the IJ Scan Utility Main screen, then adjust the items as necessary.
    Once the items above are set for document scanning, in the future, you will only need to launch the IJ Scan Utility, then press the DOCUMENT button to perform the scan (unless you want to make changes to the settings).
    Hope this helps!
    This didn't answer your question or issue? Please call or email us using one of the methods on the Contact Us page for further assistance.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • HT4059 I'm trying to organize my PDFs in iBooks on my ipad2 and I can't figure out how to combine multiple PDFs into one. Any thoughts?

    I'm trying to organize my PDFs in iBooks on my ipad2 and can't figure out how to combine multiple PDFs into one. Any thoughts?

    I'm trying to organize my PDFs in iBooks on my ipad2 and can't figure out how to combine multiple PDFs into one. Any thoughts?

  • How do I scan multiple pages into one pdf document on a HP Envy 4501 Printer

    My HP Envy 4501 Printer won't let me scan multiple pages into one pdf document.
    I went to "Advanced Settings", clicked on "file" and made sure that the check box next to "Create a separate file for each scanner page" was unchecked.
    When I clicked the Save button it showed the page that I scanned and showed 1/1.  On the right side it had options for changing the brightness and Contrast, Rotate and Crop and "Back", "Save" and "Done" buttons, but nothing about scanning another page.
    Not to mention HP's Customer Support is useless!
    I'd appreciate any help I can get with this problem.
    Thanks,
    Mark

    Hi BH,
    I see your diagram.  I just scanned something.  The screen that I'm looking at right now shows the preview page and the scroll box to the left of that just like in your diagram.  The screen does not show the + button nor does it show the red x button under the scroll box as in your diagram.  I can't see the plus sign because it is not there.
    I tried re-installing the software and drivers as you suggested but that did not have any affect.
    Thank you for trying to help me with this problem but it hasn't worked, therefore I can't mark the reply "Accept as Solution".
    I've noticed that on HP's support forum web page there is only 1 solved request for assistance.  That doesn't give me much confidence in HP.
    Please reply back to this post to let me know if there is anything else that I can try or if you know someone else at HP that can help.
    If I don't here back from you, I'm returning this HP Envy 4501 Printer to get my money back to use it to buy a printer from one of HP's competitors.
    Thanks,
    Mark  

  • How do I scan multiple pages into one document using the CanoScan LiDE 200?

    How do I scan multiple pages into one document using the CanoScan LiDE 200?
    I can't seem to find a way to get them to scan continuously, or a way to stitch them together afterwards.

    Hi dagda24,
    You can scan multiple pages into a single document with the scan to PDF option.  Use the following steps to do so:
    1.  Open MP Navigator.
    2.  Click One Clcik.
    3.  Click Save to PC.
    4.  Change the File Type from PDF to PDF (multiple pages).
    5.  Make any other changes as needed, then click scan.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • SQL Query -How2bring multiple results into one field using Formatted Search

    Hi Everyone
    i am trying to bring in the results of the field dbo.Lot_ITEM.LOT using a formatted search into a row level using the following query:
    SELECT     dbo.LOT_ITEM.LOT
    FROM       dbo.DLN1 INNER JOIN dbo.LOT_ITEM ON dbo.DLN1.ItemCode = dbo.LOT_ITEM.ITEM
    WHERE     dbo.LOT_ITEM.ITEM=$[DLN1.ItemCode]
    however the result of the dbo.Lot_ITEM.LOT field could be more then one value depending on how many lots are assigned for that item
    (for example this query would be similar to assigning batch/serial numbers to an item being despatched - as you can choose multiple batches/serials depending on the quantities available and required and then move from the left to the right side of the selection window) if that makes sense!
    is it possible to bring in the multiple results into one field? and how can i amend the above query to include this?
    Thankyou in advance :o)
    Edited by: Asma Bi on Apr 23, 2008 7:22 PM
    Edited by: Asma Bi on Apr 23, 2008 7:24 PM

    Hi Suda
    Thanks for replying :o) but im not sure about the query?
    just to simplify it (as the query im working with is to do with 3rd party addons) i have used the serial/batchs field instead and used standard demo database fields from SBO 2005 sp01:
    SELECT     dbo.ixvSerialNoFact.SRI1_IntrSerial
    FROM       dbo.DLN1 INNER JOIN
                    dbo.ixvSerialNoFact ON dbo.DLN1.DocEntry = dbo.ixvSerialNoFact.SRI1_BaseEntry
    WHERE     dbo.ixvSerialNoFact.ItemCode='g1000' and dbo.ixvSerialNoFact.SRI1_BaseEntry = '193'
    The above brings me the relevant results but when i change it to be used in a formatted search:
    SELECT     dbo.ixvSerialNoFact.SRI1_IntrSerial
    FROM       dbo.DLN1 INNER JOIN
                    dbo.ixvSerialNoFact ON dbo.DLN1.DocEntry = dbo.ixvSerialNoFact.SRI1_BaseEntry
    WHERE     dbo.ixvSerialNoFact.ItemCode=$[dln1.itemcode] and dbo.ixvSerialNoFact.SRI1_BaseEntry = $[dln1.DocEntry]
    i cant seem to get it to work - now this may be because the serial number is not allocated until teh record is added to the system, however when this happens i am unable to go back in and manually trigger the query as the delivery note rows cannot be selected!
    i  think as what im originally wanting an answer for is same as this example, im wanting to know if this is even possible?
    Thanks
    Edited by: Asma Bi on Apr 24, 2008 3:53 PM
    Edited by: Asma Bi on Apr 24, 2008 3:55 PM

  • Move multiple events into one album

    Hi,
    I am trying to tidy up our photos on iPhoto.
    Is there a fast, easy way to move multiple 'Events' into one 'Folder'
    For example:
    We have all of our photos from our honeymoon in Europe saved as seperate 'Events' According to the location. It was a 3 month trip so there are a lot of 'Events' or locations. Is there a way i can select all of them and put them into the Honeymoon 'folder' without them all merging into one big album?
    I want to keep them as separate events within the folder so we can remember where they were taken.
    I have been trying to drag the 'Event' over to the Honeymoon 'Folder' but instead of just going straight in there it creates a new unnamed folder on the left panel, and then i have to drag the event up to the honeymoon folder and delete the unnamed folder. It is proving rather time consuming and i have over 12000 photos to sort.
    Any help would be great. Simple terms please!!
    Thanks

    lf you drag an event onto a folder in the left hand pane the photos in that Event will be added to a new album in that folder with the same name as the Event. .
    OT

  • Text issues merging multiple pdfs into one pdf

    Hello, when I merge multiple pdfs into one pdf document my text is missing or garbled.  I spent hours yesterday trying to figure this out, from insuring the text was embedded and print setting were correct.  Please help!!
    Using Adobe Pro 9.0
    Thanks,
    Faith

    Acrobat Pro is the application you use for working with PDFs, making minor edits, combining multiple PDFs into a single file, extracting or replacing pages, doing fancier form work than ID has the ability to produce, and even creating PDF from a number of other file formats. I'm not sure your question about maintaining the quality of your photos is really applicable -- it would depend on how youare getting from the photo to PDF to begin with. The use of Acrobat in and of itself won't be the determiner.
    That said, I couldn't live without Acrobat Pro in my workflow. Since you are on CS5.5 you have a couple of options. You could purchase a subscription to Creative Cloud (at a discount for the first year), which would give you access not only to Acrobat, but all of the other programs and tools included in the suite, but you pay a monthly or yearly fee, or you can buy a standalone perpetual license to either Acrobat Pro or Acrobat Standard (I didn't realize Standard was still an option, and you might not need all the features of Pro -- you can compare at http://www.adobe.com/products/acrobatpro/buying-guide.html).

  • Scanning multiple pages into one document with an automatic document feeder

    when using automatic document feeder to scan in multiple pages - using the Image Capture app, this process does not work for more than 2 pages. However works perfectly in PC environment.
    Using a MacBook Pro with 10.8.4 and a Lexmark Interpret 405S All In One Scanner.
    Is there any other all in one device that can perform this function in a Mac environment?
    Please advise.

    Hi @FentyFly ,
    I see by your post that you would like to know how to scan multiple pages into one file. I would like to help you out today.
    From the HP Scan Software, click on the link for Advanced Settings, then uncheck Create a separate file for each scanned page.
    Here is a URL for how to scan and change the settings. Just select your operating system.
    Scan.
    What operating system are you using? How to Find the Windows Edition and Version on Your Computer.
    If you need further assistance, just let me know.
    Have a great day!
    Thank You.
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!
    Gemini02
    I work on behalf of HP

  • How do I scan multiple pages into one document?

    How do I scan multiple pages into one document?
    HP Photosmart 5514-e-All-in-One Printer B111h
    Model CQ 183 A

    Hi,
    Have you tried this (using PDF format).
    Launch the scan from the HP Solution Center
    Click Change Settings.
    Select the desire Scan Shortcut, then click Save to file save options
    Make sure Create One File per scanned page... is Unchecked, Approve and perform the Scan.
    Regards,
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • HP Officejet 6500A How do I scan a document with multiple pages into one file?

    HP Officejet 6500A Plus e-All-in-One Printer - E710n
    Windows 7 (64 bit)
    How do I scan a document with multiple pages into one file?  My old printer (psc 2110) asked after each scan if I wanted to scan another page.  At the end I had one pdf file with multiple pages.
    This new one creates one file for each page and I cannot find a way to create one pdf file with multiple pages.
    This question was solved.
    View Solution.

    Hi mpw101,
    If you load the papers into the ADF - Automatic Document Feeder, and then select Document to PDF then they will all be scanning into one file. Let me know if this works for you?
    I am an HP employee.
    Say Thanks by clicking the Kudos Star in the post that helped you.
    Please mark the post that solves your problem as "Accepted Solution"

  • BI for NW04S: Concatenating multiple chars into one field in BI query

    Hi,
      We have BI for NW04S. We have a requirement of concatenating multiple characteristics into one field in the BI report. This single field should have the usual drill down and other olap functionalities that a single characteristic usually enjoy in a BI report.
      In BI for NW04 (Not the S) this probably can be done using the table interface in WAD. However in BI7 WAD functionality are through Java.
      Also can this be done using Query designer alone.
      Can anybody help?
      Thanks

    Hi,
      Can you please elaborate on your Query designer option. You can always have a variable and in the user exit can write code, but what is not clear that
    1> How will you acheive the contatenation done for every row of the report in the BEX user exit variable( since it's called during the beginning of the query execution and not for all rows of the report
    2> How do you transfer the char variable into a char field in the report.
    Please elaborate .
    Thanks

  • HT1338 After I installed OS X Mountain Lion system, I can't use my Safari to log into my online banking and some other websites which require passwords. Can some one please help?

    After I installed OS X Mountain Lion system, I can't use my Safari to log into my online banking and some other websites which require passwords. Can some one please help?

    It could be browser incompatibility or something else. When you say you can't log in, what happens? Is the bank website generating an error saying you're not using a supported browser? Does the login form for your bank account display as usual, but once you submit the form to log in it doesn't work? Give me a specific step-by-step of what you're doing, such as...
    1. I load bankofamerica.com
    2. I type in my login
    3. When I submit, the page does nothing
    Obviously that may not be your issue, but giving us details like that will help us come to a quicker conclusion.

Maybe you are looking for