line exists or not

Hi all, I'm writing and problem. consider these data.
WITH table1 AS(
SELECT 'T' l1, 'T' l2, NULL l3, NULL l4, NULL l5 FROM dual UNION ALL
SELECT 'K' l1, 'L' l2, NULL l3, NULL l4, 'I' l5 FROM dual UNION ALL
SELECT NULL l1, 'T' l2, 'Y' l3, NULL l4, 'J' l5 FROM dual UNION ALL

SELECT 'T' l1, 'T' l2, 'R' l3, 'E' l4, NULL l5 FROM dual UNION ALL
SELECT 'W' l1, 'T' l2, NULL l3, 'G' l4, NULL l5 FROM dual 
),
TABLE2 AS
(
SELECT 1 cid,'T' l1, 'T' l2, NULL l3, NULL l4, NULL l5 FROM dual UNION ALL
SELECT 2 cid,'K' l1, 'L' l2, NULL l3, NULL l4, 'I' l5 FROM dual UNION ALL
SELECT 3 cid,NULL l1, 'T' l2, 'Y' l3, NULL l4, 'J' l5 FROM dual 

)
 
what I want to do is take each row in table1 and whether they exists in table2.
If Yes, check the cid of table2. If the line does not exist in table2, then display the line
for table1 without the cid. for example, here is the result
CID    l1 l2  l3  l4  l5
====  === ==  === === ===
1      T  T          
2      K  L            I
3         T    Y       J
      
       T  T    R   E
       W  T        G
as you can see in the output, I went through all the rows in table1 and find out if they are comparing all of the columns of l.
If a row from table1 exist in table2 based on all the columns of l, then I view with decided to table2.
You can see in the output that the first 3 lines of table1 exists in table2 and cid is display for those.

for the last two lines, they do not exist in table2, but I still show but with cid null.

now here's the tricky part. This can be easily be done by joining the two tables and doing outer joins.
I would like to do this without the help of outer join. Maybe use exists keyword to another type of technology.

can someone help me write a query that produces the output above without using outerjoin as query below?

Select columns
FROM table1, table2 b
where a.l1 = b.l1 (+)
and a.l2 = bl2 (+)
and...
WITH table1 AS(
SELECT 'T' l1, 'T' l2, NULL l3, NULL l4, NULL l5 FROM dual UNION ALL
SELECT 'K' l1, 'L' l2, NULL l3, NULL l4, 'I' l5 FROM dual UNION ALL
SELECT NULL l1, 'T' l2, 'Y' l3, NULL l4, 'J' l5 FROM dual UNION ALL

SELECT 'T' l1, 'T' l2, 'R' l3, 'E' l4, NULL l5 FROM dual UNION ALL
SELECT 'W' l1, 'T' l2, NULL l3, 'G' l4, NULL l5 FROM dual
),
TABLE2 AS
(
SELECT 1 cid,'T' l1, 'T' l2, NULL l3, NULL l4, NULL l5 FROM dual UNION ALL
SELECT 2 cid,'K' l1, 'L' l2, NULL l3, NULL l4, 'I' l5 FROM dual UNION ALL
SELECT 3 cid,NULL l1, 'T' l2, 'Y' l3, NULL l4, 'J' l5 FROM dual
)
select table2.cid, table1.l1, table1.l2, table1.l3, table1.l4, table1.l5 from
table1 inner join table2
on
nvl(table1.l1,0) = nvl(table2.l1,0) and
nvl(table1.l2,0) = nvl(table2.l2,0) and
nvl(table1.l3,0) = nvl(table2.l3,0) and
nvl(table1.l4,0) = nvl(table2.l4,0) and
nvl(table1.l5,0) = nvl(table2.l5,0)
union all
select null, table1.l1, table1.l2, table1.l3, table1.l4, table1.l5 from
table1 where not exists (select 1 from table2 where nvl(table1.l1,0) = nvl(table2.l1,0) and
nvl(table1.l2,0) = nvl(table2.l2,0) and
nvl(table1.l3,0) = nvl(table2.l3,0) and
nvl(table1.l4,0) = nvl(table2.l4,0) and
nvl(table1.l5,0) = nvl(table2.l5,0)
)

Output:
"CID"     "L1"     "L2"     "L3"     "L4"     "L5"
"1"     "T"     "T"     ""     ""     ""
"2"     "K"     "L"     ""     ""     "I"
"3"     ""     "T"     "Y"     ""     "J"
""     "W"     "T"     ""     "G"     ""
""     "T"     "T"     "R"     "E"     ""

Published by: APRIL on February 28, 2011 19:51

Tags: Database

Similar Questions

  • RowAlreadyDeletedException so that the line exists in the database

    Hello

    JDev 11.1.2.4

    I put in place the mechanism to keep the current line on the restoration.

    http://andrejusb.blogspot.ch/2013/03/ADF-rollback-and-keep-current-row.html

    In a managed bean I call the restore operation, and if the restoreCurrentRow is called on all your.

    The code is in the VOImpl database which all your runs from:

    protected void restoreCurrentRow() {}

    If (currentRowKey! = null) {}

    _logger.fine ("START RESET CURRENT ROW");

    _logger.info ("restoreCurrentRow" + this.getClass () + "" + currentRowKey + "" + this.getName ());

    this.executeQuery (); < = RowAlreadyDeletedException thrown here

    Key k = new Key (currentRowKey.getAttributeValues ());

    [] Found line = this.findByKey (k, 1);

    If (found! = null & & found.length == 1) {}

    Line r = this.getRow (k);

    this.setCurrentRow (r);

    If (r! = null & & currentRowIndexInRange > = 0) {}

    this.scrollRangeTo (r, currentRowIndexInRange);

    }

    }

    _logger.fine ("FINISHING RESET CURRENT ROW");

    }

    currentRowKey = null;

    }

    For on VO, I get an RowAlreadyDeletedException exception:

    < Utils > < buildFacesMessage > ADF: addition of the following JSF error: line entity with key oracle.jbo.Key [2044346 null] is not in VwWrkdclWrkTitle.

    oracle.jbo.RowAlreadyDeletedException: Houston-25019: line entity with key oracle.jbo.Key [2044346 null] is not in VwWrkdclWrkTitle.

    at oracle.jbo.server.OracleSQLBuilderImpl.doEntitySelectForAltKey(OracleSQLBuilderImpl.java:875)

    at oracle.jbo.server.BaseSQLBuilderImpl.doEntitySelect(BaseSQLBuilderImpl.java:552)

    at oracle.jbo.server.EntityImpl.doSelect(EntityImpl.java:8311)

    at oracle.jbo.server.EntityImpl.populate(EntityImpl.java:6975)

    at oracle.jbo.server.EntityImpl.merge(EntityImpl.java:7314)

    at oracle.jbo.server.EntityCache.addForAltKey(EntityCache.java:1087)

    at oracle.jbo.server.EntityCache.add(EntityCache.java:541)

    at oracle.jbo.server.ViewRowStorage.entityCacheAdd(ViewRowStorage.java:3173)

    at oracle.jbo.server.ViewRowImpl.entityCacheAdd(ViewRowImpl.java:3799)

    at oracle.jbo.server.ViewObjectImpl.createInstanceFromResultSet(ViewObjectImpl.java:5913)

    at oracle.jbo.server.QueryCollection.populateRow(QueryCollection.java:3637)

    at oracle.jbo.server.QueryCollection.fetch(QueryCollection.java:3492)

    at oracle.jbo.server.QueryCollection.get(QueryCollection.java:2209)

    at oracle.jbo.server.ViewRowSetImpl.getRow(ViewRowSetImpl.java:5125)

    at oracle.jbo.server.ViewRowSetIteratorImpl.doFetch(ViewRowSetIteratorImpl.java:2961)

    at oracle.jbo.server.ViewRowSetIteratorImpl.ensureRefreshed(ViewRowSetIteratorImpl.java:2817)

    at oracle.jbo.server.ViewRowSetIteratorImpl.refresh(ViewRowSetIteratorImpl.java:3058)

    at oracle.jbo.server.ViewRowSetImpl.notifyRefresh(ViewRowSetImpl.java:2797)

    at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:1255)

    at oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:1413)

    at oracle.jbo.server.ViewRowSetImpl.executeQueryForMode(ViewRowSetImpl.java:1319)

    at oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:1304)

    at oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:7211)

    at org.xxx.common.model.adfbc.base.MyViewObjectImpl.restoreCurrentRow(MyViewObjectImpl.java:238)

    at org.xxx.common.model.adfbc.base.MyViewObjectImpl.afterRollback(MyViewObjectImpl.java:230)

    at oracle.jbo.server.DBTransactionImpl.rollback(DBTransactionImpl.java:2544)

    at oracle.adf.model.bc4j.DCJboDataControl.rollbackTransaction(DCJboDataControl.java:1600)

    VwWrkdclWrkTitle is a SQL view.

    In the managed bean, I call a PL/SQL operation. PL/SQL commits the changes, and then I call the restore operation.

    So I set a breakpoint after the operation of PL/SQL and test the SQL and I get a single record. Because the PL/SQL is committed, before restoring SQL must return the same as the restoreCurrentRow method.

    I do not understand this RowAlreadyDeletedException exception because the line exists.

    Thank you

    I changed to a primary key that is never zero, and it works. Seems to be a bug in the ADF.

  • "Order By" in Exists / condition not exist cause ORA-00907 in Apex4.1.1

    Hi guys,.
    We have just improved Apex 3.2.1 to 4.1.1. on Oracle DB V11.2.0.1, while testing the apps in the apex, I encountered this problem.

    When I have a page of the process with a defined condition.
    What Type of Condition is Exists (SQL query returns at least one row) or it does not exist (SQL query returns no line) and the Expression 1 is a query with an "Order By" clause, for example
    SELECT 123 DOUBLE
    ORDER BY 1

    When the process starts, Apex 3.2.1 assess the State and run the process very well, but the Apex 4.1.1 would throw an error: ORA-00907: lack the right parenthesis

    I understand that as an order of the clause in a condition Exists or it does not exist is not necessary and agree that they shouldn't be there in the first place.
    But unfortunately I'm dealing with other codes to developers, and these conditions were coded like that, probably from copy - paste the codes.

    Saying that, I also think that an upgrade of the Apex should not stop anything that works in previous versions without warning or provide a workaround solution, right?

    I don't know if this affects other types of artifacts that may have a condition by their Summit when upgraded to 3.2.1 e.g. areas, Items, calculations, Validations etc.
    Does anyone else get this behavior? and there at - it an easy way to fix these?
    Ideally I won't go through all the processes (and some other artifacts might be affected too) in all applications in all areas of work to verify the condition type and manually remove the "Order By" clause.

    Thank you for advising them

    Just did some tests more

    'Calculation', 'Validation', 'Process' and 'Branches' have the same problem, 3.2.1 takes 'Order By' fine condition Exists/Not Exists, but 4.1.1 throws the error message.

    "The regions", "Buttons", "Items" have the constant behavior - 3.2.1 both 4.1.1 throw error ORA-00907: lack the closing parenthesis, what page is rendered.

    Published by: Danny on 04/25/2012 20:07

    Hey Danny,

    It's interesting. I just had a peek at what happens when you use an EXISTS or NOT EXISTS condition type. The following SQL statement final will be generated with your example above. You can also see that if you run your application in debug mode.

    select count(*) from sys.dual where exists (select 123 from dual order by 1)
    

    The execution of this statement within SQL * Plus will also see the error ORA-00907. It seems that the SQL parser does not have an order by clause in a clause EXIST.

    I wonder why this should have worked in previous versions, but I can only suspect that in the past we can just running

    select 123 from dual order by 1
    

    which may be a little slower, because with the new engine EXISTS SQL statement may stop treatment earlier if it finds a record.
    We try to be backwards compatible, as much as possible, but I doubt that we will change the way it was before due to the alteration of performance would be faced with 99.9% of our customers.

    Possible workaround: you might be able to use the new "search request" to analyze your application "to" fix for all the shots where the attribute name is "Expression 1".

    Concerning
    Patrick
    -----------
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • I want addons 'TransTorrent', but the site says that we exist is not here then please put it again to download

    I want addons 'TransTorrent', but the site says that we exist is not here then please put it again to download

    Add - ons are not provided by Mozilla/Firefox.

    Who creates these add-ons?

    The modules listed here were created by thousands of developers in our community, ranging from individual amateurs to large companies. All of the listed modules are reviewed by a team of editors before being released. Modules marked as experimental have not been considered and must be installed carefully.

    https://addons.Mozilla.org/en-us/about

    https://addons.Mozilla.org/en-us/developers/

  • Trigger line asked could not be booked because it is already in use.

    Hi, I am trying to export the markers PFI0 and PXI_Trig0 on NI5450 (in script view)

    by using the following code

    There are no errors when I set up by using the following code.

    commWrapper.ExportSignal (PXICommonGenWrapper.niFgenConstants.MarkerEvent, "Marker1", "PFI0")
    commWrapper.ExportSignal (PXICommonGenWrapper.niFgenConstants.Marker, "Marker0", "PXI_Trig0")

    When I run the script, I get the following error

    Trigger line asked could not be booked because it is already in use.

    Good: Terminal output event marker
    Target unit: PXI1Slot2

    State code:-89126

    Would appreciate any solution that allows me to configure the two triggers/markers. I use these markers to trigger another card PXI (NI5644R on PXI_Trig0) and an external piece of equipment (using the output of PFI0).

    Thank you.

    Hi Surya,

    Thanks for this posting on the community page. It tells you what this error, it cannot route a trigger to your destination requested because something else has already booked this trigger line. A pottential typo, this is your second order ExportSignal specifies niFgenConstants.Marker and not. MarkerEvent. It is a simple error to solve, but there are many possible sources. Is it possible for you to share the complete code with me? Or, perhaps you could arrange a join.me and I can look at your full installer.

  • All icons changed to and will Outlook open, error message "command line argument is not valid."

    I have been using Windows 7 and Office 2010 since the beginning of this year. Suddenly, I have a problem.

    All my software program icons (shortcuts and start menu) moved somehow to be the Outlook icon. When you try to open Outlook and any other program, I get the message "cannot start Microsoft Outlook. The command line argument is not valid. Check the switch you are using. »

    None of the software opens. This is true for Microsoft products and software from other companies.  The only way I can open/use some of my software is to go to the file and open it from there. How can I solve this problem?

    I tried to use my Office CD to repair the software, but nothing has changed.  I tried to go into the properties of the icon to see if the problem can be corrected for other software but the links are to the correct files and the icon will not change.   Nothing I've tried works.  Even in Control Panel administrative tools are not open (they have also been changed to have the Outlook icon).

    . I need help as soon as POSSIBLE. THX

    Only, I've solved my problems with this re - create my profile.

    To re - create your user profile name just as a different user and ensure that the user have a good administrator.

    Go to my computer > users (Windows 7) or Document and settings (Win XP) > find the profile that have a questions and rename (* do not delete because we need a return to the top if there is all data must be transferred to a new profile)

    Another thing need to do is to change the registry by go to start and type regedit (make sure administrator too)

    Go down this path HKEY_LOCAL_MACHINE NT\CurrentVersion\ProfileLIST\ * only Applicable for Windows 7

    Oncve you see all the list such as S-1-5-18... something like this a check which is the profile who have questions and delete.

    The profile with a questions can be seen on you under ProfileImagePath: C:\Users\

    In fact, you can try to reconnect and it will be relaxing a new profile just transfer back up the old data of the profile that was rename in the new profile that has been re - create.

    Hope this helps, if so please mark this answer.

    Thank you

  • Application exist or not

    Hi all,

    I have two request to the card i.e. amps BB and Google maps.

    So, how can I know that google maps is installed in the device?

    While I can map from Google maps if not then it will map it through BB maps.

    So the main problem is how do I know the Google map (or other) application is exist or not at run-time?

    Thanks and greetings

    Isabelle

    To find out who all the visible application currently running:

    http://supportforums.BlackBerry.com/Rim/Board/message?board.ID=java_dev&message.ID=32516#M32516

  • How to remove lines under separate Notes?

    My document has strange lines between each note - does not know how to remove them. It is not the 'rule above,' as far as I can tell. I adjusted the rule above a lot, and that affects only the line between the body of the text and the Notes section. The problem is the lines between each note. They resemble the underscores, but I don't think that's what they are, either. Kind of a rule that I don't know how to change. See:

    Screen Shot 2016-01-21 at 11.01.45 AM.png

    Looks like the paragraph style that you are using has a rule in paragraph below market.

  • I XI Acrobat pro, under comment &gt; markup drawing the cloud, the polygon, gum and the line connect do not work. Eraser is visible, the rest are hidden a bit. all solutions?

    I XI Acrobat pro, under comment > markup drawing the cloud, the polygon, gum and the line connect do not work. Eraser is visible, the rest are hidden a bit. all solutions?

    You must disable the Touch Mode, with the toolbar button or the preference of the user: Edit > preferences > General > Mode Touch > never

  • How to display the id to exist or not?

    For example

    I have a table of students with the student_id, student_name and student_email fields. I need to write a function and passing a student card and show the output as

    Student_id exist
    There is no such thing as Student_id

    Please help me

    Hello
    create or replace function student_sample (studid number) return varchar2
    is
    cnumber varchar2 (20);
    cursor c1 is
    Select student_id in the student_class where student_id = studid;
    Start
    Open c1;
    Fetch c1 into cnumber;
    If found then % c1
    cnumber: = "exists";
    on the other
    cnumber: = "notexist".
    end if;
    Close c1;
    Return cnumber;
    end student_sample;

    I hope I've just fixed your function. Back he exist or not.

  • IE7 "could not open the file: * path *.» The file exists may not

    I created a package of IE7 a while back which works great.  Apart from this little problem.  It generates an error when the user tries to open a .msg to the WebApp.  It will try to open Outlook and display the following error message.  «Could not open the file: * path *.»  The file exists may not, you don't have permission to open it, or it may be open in another program.  Right click on the folder that contains the file, and then click action to check your permissions for the folder. »

    All the other files attached to work.  PDF, html, txt, rtf, etc.  I tried to move temporary Internet files to a different location with the same result.

    Someone at - it ideas?

    Thank you!

    He was captured on Windows Server 2003 x 64 running on W7 x 64

    Also note that when users choose to save him, it opens fine.  This isn't an "acceptable workaround solution.

    Looks a lot like this one: http://blogs.vmware.com/thinapp/2011/01/locally-installed-applications-and-integration-with-virtualized-internet-explorer.html

  • My Eraser tool leaves black lines and does not clear.

    It's my problem, I have the latest Illustrator and everytime I want to use the eraser it leaves a black line behind, do not erase anything. any ideas on how to fix it?

    Select the object that you do not want to have a stroke and click the shade of white that has a line through it. This nuance means no color. But she does not have a path. the object remains until you select the path and press the delete key.

  • Lines that do not migrated because of filters are saved somewhere?

    Hi all

    According to my understanding, if I put a constraint on the target table in the models and use the control flow through a seam in the interface, the lines that do not meet the constraint get connected to the table of errors E$.

    I want to know that if I put some filters or join conditions on the source, the lines that are not migrated because of these filters, do they get connected anywhere. Until now, I used to check tables $ ca and my source and see that all lines have not migrate but is there any other table where the journal is maintained?

    Thank you and best regards,
    Prerna

    Hey Loren,
    You cannt see these documents. You must look in the backend... Let's say you have a filter SAL > 100 then you will get all information abot SAL<100. if="" you="" need,="" then="" you="" create="" one="" refresh="" variable="" based="" on=""><100 and="" get="" the="" count(*)="" or="" other="" possible="" information="" as="" per="">

    Bottom line: ODI will occupy on those records satisfying the condition not others.

    Thank you.
    http://bhabaniranjan.com/

  • VCB: Another error occurred: at line number 7, not well formed (invalid token)

    I get the error message:

    2009-06-12 17:10:00.795 "vcbMounter" error of 2284 Error: Another errorencountered: line number 7, not well formed (invalid token)

    When I use the vcbMounter.exe (the same with vcbVmName.exe) of the VCB Proxy with the option "-a name: vm - name", since last week.

    With "- an ipaddr:vm - name ' it works well. We did not updates or upgrades at this time.

    Maybe a problem with a special character in the name or description of a virtual machine, but I can't find it.

    In the Victoria Cross are more than 1000 VM. Can anyone give me a tip how to find this character, or is there a differnet solution?

    Thank you very much

    Guenter

    Hello

    If you have a special character in the vmname, try with escape character.

    -@m!t

  • Line update does not update in the data of table view

    Hello

    I have Developer SQL 3.0.04 running on Windows XP.

    In the view of the table (Data tab) of the SENSOR table, after update of a line, I do not see the change. It's always the old value that is displayed. I managed to see if the table has been updated and it has been on sqlplus. After 'engage', I could see the same thing.

    The update statement has been:

    UPDATE safege.sensor SET lastacq = (select max (raw_date) of safege.msr_3566) where cmt = "W090QR01M002."

    And I got the answer "1 line Update". But when I look at I can't see the changes, still the old value.

    I tried to select
    Select lastacq from the probe where cmt = "W090QR01M003."
    and I could see that the change was made

    It was only after the closing of the view table and reopening, I could see the change presented in this table.

    It is a big problem for me because if I can't trust what I see under Developer slq, then I doubt on what I'm doing, if I'm really updating the table or what.


    Thank your for your entry.

    Christian

    I've seen a few bugs with 3.0.x, but I'm not sure you hit a bug. I have woked with 3.1 and 2.x versions and I didn't see this problem.
    Try to use the 3.1.x or 2.x version, I hope it is and must solve the problem.

    Kind regards
    http://www.oracleracexpert.com
    RMAN Oracle 11 g new features
    http://www.oracleracexpert.com/2011/12/Oracle-recovery-managerrman-new.html

Maybe you are looking for

  • How to leave a Web site without closing FireFox?

    When I want to close a page of the Web site at the top of the screen, it closes Firefox instead, and I have toreopen it. How can I close only the current web page and not Firefox?

  • Start Windows XP external hard drive

    The power supply on the old computer my wife THAT XP has dropped. I had another autour power that I swapped in, but it's not a SATA connector for internal hard drive of the computer. I had a hard drive enclosure and put the drive in it. With the disk

  • Problem with starting after trying to install XP.

    I have a Samsung NF110 netbook with an external cd drive. The hard drive has two partitions - c: and d:. C: installed Windows 7 and d: was empty. I wanted a machine to dual-boot with Windows 7 and XP in different partitions. I tried to install XP on

  • Is an external hard drive suitable for Asus memopad?

    I would like to connect a disk external drive in my Asus memopad ME 302 c compressed. Does anyone know if this is possible and if it is the guy's best example: 2'5 "or another? Would be grateful for any advice on this

  • Can't disable Windows Search

    Hey, y ' all. I ran some research tonight using Windows Search (and the little dog Wizard thing). Got the answers I wanted and Xe by windows. Later, however, when I went to access to the files in My Documents, I double-clicked on the folder you want