And condition within the same table

Hello all,
Was wondering if anyone knows what's the best and most efficient way to query for something similar to the example below.
Table1
ID CID VALUE
1 1 a
2 2 b
3 3 c
4 1 c
Find me all customer id where value is a and c
This should only bring back cid = 1.
Thanks in advance

select cid from table1 t1 where value='a'
and exists (select 1 from table1 t2 where t2.cid = t1.cid and t2.value='b');note: untested

Similar Messages

  • Multiple and conditions in the same table

    Ok I am going to kick myself for this, but I can't figure it out. I am trying to figure out how to find employees which match multiple criteria in the same table.
    create table emp
    (empno number,
    name  varchar2(10))
    create table skills
    (skill_id   number,
    skill_code varchar2(20))
    create table emp_skills
    (empno    number,
    skill_id number,
    rating   number)
    insert into emp values(1, 'SMITH');
    insert into emp values(2, 'JONES');
    insert into skills values (1, 'SQL');
    insert into skills values (2, 'PLSQL');
    insert into skills values (3, 'JAVA');
    insert into emp_skills values(1,1, 8);
    insert into emp_skills values(1,2, 9);
    insert into emp_skills values(1,3, 10);
    insert into emp_skills values(2,1,9);
    insert into emp_skills values(2,2,2);
    insert into emp_skills values(2,3,7);Now I need to come up with a query finding all employees who match all 3 of the following criteria:
    1) Have at least a 5 rating in SQL
    2) Have at least a 6 rating in PLSQL
    3) Have at least a 7 rating in JAVA
    So using this I would expect to return only SMITH since his/her skills meet all 3 criteria. I dont want to use OR in my query since I want all 3 to match not just one of them.
    I have a feeling I will need to self join the table - but this is going to be part of a dynamic query for APEX where the users can choose the skills and ratings they want employees to adhere to, so I dont know the number of criteria or the exact criteria in advance. But I figure if I can get a proof of concept SQL I can make it work dynamically.
    Any ideas are appreciated - sorry for the long post but I figure more detail is better

    with es1 as(
    select s.skill_code, es.empno, es.rating
    from skills s, emp_skills es
    where s.skill_id = es.skill_id
    /* main */
    select e.*
    from emp e
    where
    exists
    (select 'x' from es1
    where es1.rating >= 5
    and es1.skill_code = 'SQL'
    and es1.empno = e.empno)
    and
    exists
    (select 'x' from es1
    where es1.rating >= 6
    and es1.skill_code = 'PLSQL'
    and es1.empno = e.empno)
    and
    exists
    (select 'x' from es1
    where es1.rating >= 7
    and es1.skill_code = 'JAVA'
    and es1.empno = e.empno)
    -- Addition (Another example)
    with es1 as(
    select s.skill_code, es.empno, es.rating
    from skills s, emp_skills es
    where s.skill_id = es.skill_id
    /* main */
    select e.*
    from emp e
    where
    (select count(distinct es1.skill_code) from es1
    where
    ((es1.rating >= 5 and es1.skill_code = 'SQL')
    or
    (es1.rating >= 6 and es1.skill_code = 'PLSQL')
    or
    (es1.rating >= 7 and es1.skill_code = 'JAVA')
    and es1.empno = e.empno)
    =3;

  • XML document structures must start and end within the same entity

    Hi there,
    I'm working with a client/server application and using SaxParser for reading in xml. I get the SaxParserException: XML document structures must start and end within the same entity. I understand what that means, but it isn't applicable! The xml data being used is well-formed. I checked the well-formedness with Stylus Studio to make sure. Here's the data:
    <?xml version='1.0' encoding='UTF-8'?>
    <vcmessage>
         <vcsource>3</vcsource>
         <processevent>16</processevent>
         <shape>
              <llindex>0</llindex>
              <shapetype>9</shapetype>
              <shapeproperties>
                   <shapelocation>
                        <xcoord>54</xcoord>
                        <ycoord>184</ycoord>
                   </shapelocation>
                   <bounds>
                        <width>24</width>
                        <height>24</height>
                   </bounds>
                   <fgcolor>
                        <fgred>0</fgred>
                        <fggreen>0</fggreen>
                        <fgblue>0</fgblue>
                   </fgcolor>
                   <bgcolor>
                        <bgred>255</bgred>
                        <bggreen>255</bggreen>
                        <bgblue>255</bgblue>
                   </bgcolor>
                   <thickness>1</thickness>
                   <isfilled>false</isfilled>
              </shapeproperties>
         </shape>
    </vcmessage>The parser generally stops around the </bgcolor> tag.
    I'm using Eclypse as my IDE. I'm wondering if there's something wrong with it? Or maybe there's something wrong with the class I'm using for reading in the XML? Followng is the class.
    Please advise,
    Alan
    package vcclient;
    import java.io.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import javax.xml.parsers.*;
    public class XMLDocumentReader extends DefaultHandler
      private VCClient client = null;
      private Writer out;
      private String lineEnd =  System.getProperty("line.separator");
      private boolean haveSourceType = false;
      private boolean haveUserName = false;
      private boolean haveMessage = false;
      private boolean haveProcessEvent = false;
      private boolean haveLinkedListIndex = false;
      private boolean haveOpeningShapePropertiesTag = false;
      private boolean haveShapeType = false;
      private boolean haveOpeningShapeLocationTag = false;
      private boolean haveShapeLocation = false;
      private boolean haveOpeningXCoordTag = false;
      private boolean haveOpeningYCoordTag = false;
      private boolean haveOpeningBoundsTag = false;
      private boolean haveBoundsWidth = false;
      private boolean haveBoundsHeight = false;
      private boolean haveOpeningFGColorTag = false;
      private boolean haveOpeningBGColorTag = false;
      private boolean haveOpeningThicknessTag = false;
      private boolean haveOpeningIsFilledTag = false;
      private boolean haveOpeningImageDataTag = false;
      private boolean haveOpeningTextDataTag = false;
      private boolean haveFGRed = false;
      private boolean haveFGGreen = false;
      private boolean haveFGBlue = false;
      private boolean haveBGRed = false;
      private boolean haveBGGreen = false;
      private boolean haveBGBlue = false;
      private boolean haveThickness = false;
      private boolean haveIsFilled = false;
      private boolean haveImageData = false;
      private boolean haveTextData = false;
      private VCMessage vcmessage = null;
      public XMLDocumentReader(VCClient value)
           client = value;
           vcmessage = new VCMessage();
      public VCMessage getVCMessage()
           return vcmessage;
      public boolean haveSourceType()
         return haveSourceType; 
      public boolean ParseXML(InputStream stream)
         boolean success = false;
         // Use the default (non-validating) parser
        SAXParserFactory factory = SAXParserFactory.newInstance();
        try
             // Set up output stream
            out = new OutputStreamWriter(System.out, "UTF-8");
            // Parse the input
            SAXParser saxParser = factory.newSAXParser();
            saxParser.parse( stream, this );
            success = true;
        catch (SAXParseException spe)
            // Error generated by the parser
            System.out.println("\n** Parsing error"
               + ", line " + spe.getLineNumber()
               + ", uri " + spe.getSystemId());
            System.out.println("   " + spe.getMessage() );
            // Unpack the delivered exception to get the exception it contains
            Exception  x = spe;
            if (spe.getException() != null)
                x = spe.getException();
            x.printStackTrace();
            return success;
        catch (SAXException sxe)
             // Error generated by this application
             // (or a parser-initialization error)
             Exception  x = sxe;
             if (sxe.getException() != null)
                 x = sxe.getException();
             x.printStackTrace();
             return success;
        catch (ParserConfigurationException pce)
            // Parser with specified options can't be built
            pce.printStackTrace();
            return success;
        catch (Throwable t)
             t.printStackTrace();
             return success;
        return success;
      public void startDocument()throws SAXException
          emit("<?xml version='1.0' encoding='UTF-8'?>");
          nl();
      public void endDocument()throws SAXException
          try {
              nl();
              out.flush();
          } catch (IOException e) {
              throw new SAXException("I/O error", e);
      public void startElement(String namespaceURI,
                               String lName, // local name
                               String qName, // qualified name
                               Attributes attrs)throws SAXException
          String eName = lName; // element name
          if (eName.equals(""))
             eName = qName; // namespaceAware = false
          emit("<"+eName);
          if (attrs != null) {
              for (int i = 0; i < attrs.getLength(); i++) {
                  String aName = attrs.getLocalName(i); // Attr name
                  if (aName.equals("")) aName = attrs.getQName(i);
                  emit(" ");
                  emit(aName + "=\"" + attrs.getValue(i) + "\"");
          emit(">");
          if(makeStartTag(eName).equals(Constants.OPENING_SHAPEPROPERTIES))
                haveOpeningShapePropertiesTag = true;
          else if(makeStartTag(eName).equals(Constants.OPENING_SHAPELOCATION))
              haveOpeningShapeLocationTag = true;
          else if(makeStartTag(eName).equals(Constants.OPENING_BOUNDS))
                haveOpeningBoundsTag = true;
          else if(makeStartTag(eName).equals(Constants.OPENING_FGCOLOR))
                 haveOpeningFGColorTag = true;
          else if(makeStartTag(eName).equals(Constants.OPENING_BGCOLOR))
              haveOpeningBGColorTag = true;
          else if(makeStartTag(eName).equals(Constants.OPENING_BGGREEN))
               System.out.println("See BGGreen");
          else if(makeStartTag(eName).equals(Constants.OPENING_BGBLUE))
               System.out.println("See BGBlue");
          else if(makeStartTag(eName).equals(Constants.OPENING_THICKNESS))
              haveOpeningThicknessTag = true;
          else if(makeStartTag(eName).equals(Constants.OPENING_ISFILLED))
              haveOpeningIsFilledTag = true;
          else if(makeStartTag(eName).equals(Constants.OPENING_IMAGEDATA))
              haveOpeningImageDataTag = true;
          else if(makeStartTag(eName).equals(Constants.OPENING_TEXTDATA))
              haveOpeningTextDataTag = true;
      public void endElement(String namespaceURI,
                             String sName, // simple name
                             String qName  // qualified name
                            )throws SAXException
           if(sName.equals("") && !qName.equals(""))
              sName = qName;
              emit("</"+sName+">");
           else
              emit("</"+sName+">");
           if(makeEndTag(sName).equals(Constants.CLOSING_SOURCE_TYPE))
              haveSourceType = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_USER))
              haveUserName = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_MESSAGE))
              haveMessage = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_PROCESSEVENT))
               haveProcessEvent = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_LINKEDLISTINDEX))
               haveLinkedListIndex = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_SHAPETYPE))
               haveShapeType = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_SHAPELOCATION))
                haveOpeningShapeLocationTag = false;
           else if(makeEndTag(sName).equals(Constants.CLOSING_WIDTH))
               haveBoundsWidth = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_HEIGHT))
               haveBoundsHeight = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_BOUNDS))
                haveOpeningBoundsTag = false;
           else if(makeEndTag(sName).equals(Constants.CLOSING_FGRED))
               haveFGRed = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_FGGREEN))
               haveFGGreen = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_FGBLUE))
               haveFGBlue = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_FGCOLOR))
                haveOpeningFGColorTag = false;
           else if(makeEndTag(sName).equals(Constants.CLOSING_BGRED))
               haveBGRed = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_BGGREEN))
             haveBGGreen = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_BGBLUE))
               System.out.println("See closing BGBlue");
               haveBGBlue = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_BGCOLOR))
                haveOpeningBGColorTag = false;
           else if(makeEndTag(sName).equals(Constants.CLOSING_THICKNESS))
               System.out.println("XMLDocumentReader: Step2");
                haveOpeningThicknessTag = false;
           else if(makeEndTag(sName).equals(Constants.CLOSING_ISFILLED))
               haveOpeningIsFilledTag = false;
           else if(makeEndTag(sName).equals(Constants.CLOSING_IMAGEDATA))
               haveOpeningImageDataTag = false;
           else if(makeEndTag(sName).equals(Constants.CLOSING_TEXTDATA))
               haveOpeningTextDataTag = false;
      private String makeStartTag(String tag_name)
           String start = "<";
           String end = ">";
           return start.concat(tag_name).concat(end);
      private String makeEndTag(String tag_name)
           String start = "</";
           String end = ">";
           return start.concat(tag_name).concat(end);
      public void characters(char buf[], int offset, int len)throws SAXException
           String s = new String(buf, offset, len);
          if(haveSourceType == false)
               if(vcmessage.getSourceType() == null)
                  try
                    if(s.equals(""))return;
                   int sourcetype = Integer.parseInt(s);
                   vcmessage.setSourceType(sourcetype);                            
                  catch(NumberFormatException nfe){}
          else if(vcmessage.getSourceType() == SourceType.CHAT_SOURCE)
            if(vcmessage.getSourceType() == SourceType.CHAT_SOURCE && haveUserName == false)
                 vcmessage.setUserName(s);          
            else if(vcmessage.getSourceType() == SourceType.CHAT_SOURCE && haveMessage == false)
               //When the parser encounters interpreted characters like: & or <,
               //then this method gets invoked more than once for the whole message.
               //Therefore, we need to concatonate each portion of the message.  The
               //following method call automatically concatonates.
               vcmessage.concatMessage(s);                    
          else if(vcmessage.getSourceType() == SourceType.WHITEBOARD_SOURCE)
               if(haveProcessEvent == false)
                 try
                   vcmessage.setProcessEvent(Integer.parseInt(s));
                 catch(NumberFormatException nfe){}
               else if(haveLinkedListIndex == false)
                    try
                       vcmessage.setLinkedListIndex(Integer.parseInt(s));
                     catch(NumberFormatException nfe){}
               else if(haveShapeType == false)
                    try
                       vcmessage.setShapeType(Integer.parseInt(s));
                     catch(NumberFormatException nfe){}
               if(haveOpeningShapePropertiesTag)
                    if(haveOpeningShapeLocationTag)
                         if(haveOpeningXCoordTag)
                              try
                                vcmessage.setXCoordinate(Integer.parseInt(s));
                              catch(NumberFormatException nfe){}
                         else if(haveOpeningYCoordTag)
                              try
                                vcmessage.setYCoordinate(Integer.parseInt(s));
                                //reset all flags for ShapeLocation, X and Y coordinates
                                haveOpeningXCoordTag = false;
                                haveOpeningYCoordTag = false;
                                //haveOpeningShapeLocationTag = false;
                              catch(NumberFormatException nfe){}
                    else if(haveOpeningBoundsTag)
                         if(haveBoundsWidth == false)
                              try
                                vcmessage.setBoundsWidth(Integer.parseInt(s));
                              catch(NumberFormatException nfe){}
                         else if(haveBoundsHeight == false)
                              try
                                vcmessage.setBoundsHeight(Integer.parseInt(s));
                                //reset flag
                                //haveOpeningBoundsTag = false;
                              catch(NumberFormatException nfe){}
                    else if(haveOpeningFGColorTag)
                         if(haveFGRed == false)
                              try
                                vcmessage.setFGRed(Integer.parseInt(s));                           
                              catch(NumberFormatException nfe){}
                         else if(haveFGGreen == false)
                              try
                                vcmessage.setFGGreen(Integer.parseInt(s));                           
                              catch(NumberFormatException nfe){}
                         else if(haveFGBlue == false)
                              try
                                vcmessage.setFGBlue(Integer.parseInt(s));
                                //reset flag
                                //haveOpeningFGColorTag = false;
                              catch(NumberFormatException nfe){}
                    else if(haveOpeningBGColorTag)
                         if(haveBGRed == false)
                              try
                                vcmessage.setBGRed(Integer.parseInt(s));                           
                              catch(NumberFormatException nfe){}
                         else if(haveBGGreen == false)
                              try
                                vcmessage.setBGGreen(Integer.parseInt(s));                           
                              catch(NumberFormatException nfe){}
                         else if(haveBGBlue == false)
                         {   System.out.println("getting BGBlue data");
                              try
                                vcmessage.setBGBlue(Integer.parseInt(s));
                                //reset flag
                                //haveOpeningBGColorTag = false;
                              catch(NumberFormatException nfe){}
                    else if(haveOpeningThicknessTag)
                         try
                            vcmessage.setThickness(Integer.parseInt(s));                       
                          catch(NumberFormatException nfe){}
                    else if(haveOpeningIsFilledTag)
                         vcmessage.setIsFilled(s);
                    else if(haveOpeningImageDataTag && vcmessage.getProcessEvent() == org.jcanvas.comm.ProcessEvent.MODIFY)
                         vcmessage.setBase64ImageData(s);                    
                    else if(haveOpeningTextDataTag && vcmessage.getProcessEvent() == org.jcanvas.comm.ProcessEvent.MODIFY)
                         vcmessage.setTextData(s);
                    //reset
                    haveOpeningShapePropertiesTag = false;
          emit(s);
      //===========================================================
      // Utility Methods ...
      //===========================================================
      // Wrap I/O exceptions in SAX exceptions, to
      // suit handler signature requirements
      private void emit(String s)throws SAXException
          try {
              out.write(s);
              out.flush();
          } catch (IOException e) {
              throw new SAXException("I/O error", e);
      // Start a new line
      private void nl()throws SAXException
          try {
              out.write(lineEnd);
          } catch (IOException e) {
              throw new SAXException("I/O error", e);
      //treat validation errors as fatal
      public void error(SAXParseException e)
      throws SAXParseException
        throw e;
      // dump warnings too
      public void warning(SAXParseException err)
      throws SAXParseException
        System.out.println("** Warning"
            + ", line " + err.getLineNumber()
            + ", uri " + err.getSystemId());
        System.out.println("   " + err.getMessage());
    }

    Just out of curiosity what happens if you append a space to the end of the XML document?

  • Can we use exceptions and conditions at the same time?

    can we use exceptions and conditions at the same time? Are there any dependencies between exceptions an conditions?

    Exceptions are used when there are some mistakes , or exceeds the supposed values, we can highligt that in different colours for enabling the validator to notice easily. In this we are giving conditions for considering the value as exceptions. suppose, if the values is out of the range -1 to +1 then exception.
    But conditions can be considered as the restrictions given in measure level also. So please elaborate what you meant by conditions

  • Import data from few tables and export into the same tables on different db

    I want to import data from few tables and export into the same tables on different database. But on the target database, additional columns have been added
    to the same tables. how can i do the import?
    Its urgent can anyone please help me do this?
    Thanks.

    Hello Junior DBA,
    maybe try it with the "copy command".
    http://download.oracle.com/docs/cd/B14117_01/server.101/b12170/apb.htm
    Have a look at the section "Understanding COPY Command Syntax".
    Here is an example of a COPY command that copies only two columns from the source table, and copies only those rows in which the value of DEPARTMENT_ID is 30:Regards
    Stefan

  • How can I start a new paragraph within the same table cell?

    In Numbers, when adding text within a table frame, how can I start a new line within the same frame (rather than advancing to the next cell)?  I'd like to enter a mini-list of several items of various lengths of data.

    While Wayne's answer solves your problem, another possibility is to uncheck the box at the bottom of the Table inspector for "Return key moves to next cell." If that is unchecked, the return key types a paragraph return within the cell (the same as Option Return with the box checked).
    With that box unchecked, Shift Return types a soft return (new line without a paragraph break).

  • Can I have different font sizes and alignments within the same title?

    Apologies, haven't been able to search through previous discussions as I'm in Madagascar and my internet connection is not adequate today!
    I'm trying to put scrolling credits on a project. I want the list of credits - music, photos, text etc. - then underneath that a nice little thanks paragraph followed by the date and website. I want the paragraph, date and website to be centered, but when I try to do that it centres the whole thing and messes with the format of the credits part. Changing the font size also makes all the text the same, but ideally I need a couple of bits to be different.
    Does that make sense?
    There doesn't seem to be a way to just highlight the bit that I want to change - it's all or nothing. But I know it's been done before, because I've got a video made last year which has this exact thing as the credits. Unfortunately the person who made that isn't here at the moment.
    Any help very much appreciated, this has to be finished within the next few hours and I've been struggling for days. I tried to do it just as several screens of text instead of the scrolling thing, but couldn't format it properly for the credits.
    As a complete aside, I've just downloaded the same song 3 times from iTunes and every time it's dodgy and cuts out after 1/3 of the song. Don't know whether this is to do with my bad internet or what... but any help with that would also be amazing.
    Thanks.

    Not currently possible.
    A computer/catalog is a unique construct.
    An iOS device can only sync to one computer/catalog at a time.
    You can sync many devices to one computer/catalog but not the other way around.

  • Can I sync my two computers and ipad within the same license?

    I have my main desktop synced to my ipad. Now I would love to have my notebook synced as well but when I activate sync on the notebook it tells me there is a catalogue conflict and switched my ipad to to a different catalog and deletes all the stuff I had synced with the desktop.
    I normally use a an external hard drive to work, can I have the catalog be on the external and have both computer source from the one catalog on the external?  This make any sense?

    Not currently possible.
    A computer/catalog is a unique construct.
    An iOS device can only sync to one computer/catalog at a time.
    You can sync many devices to one computer/catalog but not the other way around.

  • Update and Select from the same table

    Hello,
    i have this select - i tested it and its working
    [code]
    select
    case
    when DTF_REEW_201301.KTMO =1 then DTF_REEW_201301.KTBT
    else DTF_REEW_201301.KTBT - CTF_REEW_KUM_201301.KTBT
    end
    as KTBT_ISO,
    case
    when DTF_REEW_201301.KTMO =1 then DTF_REEW_201301.KTZN
    else DTF_REEW_201301.KTZN - CTF_REEW_KUM_201301.KTZN
    end
    as KTZN_ISO,
    case
    when DTF_REEW_201301.KTMO =1 then DTF_REEW_201301.KTAB
    else DTF_REEW_201301.KTAB - CTF_REEW_KUM_201301.KTAB
    end as KTAB_ISO,
    DTF_REEW_201301.brnrn,
    DTF_REEW_201301.ktat
       from
    reewcore.CTF_REEW_KUM_201301 CTF_REEW_KUM_201301,
    reewdq.DTF_REEW_201301 DTF_REEW_201301
       where
    (DTF_REEW_201301.BRNRN = CTF_REEW_KUM_201301.BRNRN
    and DTF_REEW_201301.KTAT = CTF_REEW_KUM_201301.KTAT)
    and CTF_REEW_KUM_201301.KTMO = (DTF_REEW_201301.KTMO - 1)
    [/code]
    With the result from KTBT_ISO, KTZN_ISO and KTAB_ISO i want to update the table "reewdq.DTF_REEW_201301" - and this table is in the select-statement!
    I believe, i tried every update-statement - but no update is working.
    I need something like this:
    [code]
    update reewdq.DTF_REEW_201301 t1 set t1.KTBT_ISO=
    select
    case
    when DTF_REEW_201301.KTMO =1 then DTF_REEW_201301.KTBT
    else DTF_REEW_201301.KTBT - CTF_REEW_KUM_201301.KTBT
    end
    as KTBT_ISO
       from
    reewcore.CTF_REEW_KUM_201301 CTF_REEW_KUM_201301,
    reewdq.DTF_REEW_201301 DTF_REEW_201301
       where
    (DTF_REEW_201301.BRNRN = CTF_REEW_KUM_201301.BRNRN
    and DTF_REEW_201301.KTAT = CTF_REEW_KUM_201301.KTAT)
    and CTF_REEW_KUM_201301.KTMO = (DTF_REEW_201301.KTMO - 1)
    t1.KTZN_ISO=
    select
    case
    when DTF_REEW_201301.KTMO =1 then DTF_REEW_201301.KTZN
    else DTF_REEW_201301.KTZN - CTF_REEW_KUM_201301.KTZN
    end
    as KTZN_ISO
       from
    reewcore.CTF_REEW_KUM_201301 CTF_REEW_KUM_201301,
    reewdq.DTF_REEW_201301 DTF_REEW_201301
       where
    (DTF_REEW_201301.BRNRN = CTF_REEW_KUM_201301.BRNRN
    and DTF_REEW_201301.KTAT = CTF_REEW_KUM_201301.KTAT)
    and CTF_REEW_KUM_201301.KTMO = (DTF_REEW_201301.KTMO - 1)
    t1.KTAB_ISO=
    select
    case
    when DTF_REEW_201301.KTMO =1 then DTF_REEW_201301.KTAB
    else DTF_REEW_201301.KTAB - CTF_REEW_KUM_201301.KTAB
    end as KTAB_ISO
       from
    reewcore.CTF_REEW_KUM_201301 CTF_REEW_KUM_201301,
    reewdq.DTF_REEW_201301 DTF_REEW_201301
       where
    (DTF_REEW_201301.BRNRN = CTF_REEW_KUM_201301.BRNRN
    and DTF_REEW_201301.KTAT = CTF_REEW_KUM_201301.KTAT)
    and CTF_REEW_KUM_201301.KTMO = (DTF_REEW_201301.KTMO - 1)
    [/code]
    But this code isn´t working. Has someone an idea please? Can someone please help me.
    Best regards
    Heidi

    Use MERGE:
    merge
      into reewdq.DTF_REEW_201301 t1
      using (
             select  case
                       when DTF_REEW_201301.KTMO =1 then DTF_REEW_201301.KTBT 
                       else DTF_REEW_201301.KTBT - CTF_REEW_KUM_201301.KTBT
                     end as KTBT_ISO,
                     case
                       when DTF_REEW_201301.KTMO =1 then DTF_REEW_201301.KTZN 
                       else DTF_REEW_201301.KTZN - CTF_REEW_KUM_201301.KTZN
                     end as KTZN_ISO,
                     case
                       when DTF_REEW_201301.KTMO =1 then DTF_REEW_201301.KTAB 
                       else DTF_REEW_201301.KTAB - CTF_REEW_KUM_201301.KTAB
                     end as KTAB_ISO,
                     reewdq.ROWID as rid
               from  reewcore.CTF_REEW_KUM_201301 CTF_REEW_KUM_201301, 
                     reewdq.DTF_REEW_201301 DTF_REEW_201301
               where DTF_REEW_201301.BRNRN = CTF_REEW_KUM_201301.BRNRN
                 and DTF_REEW_201301.KTAT = CTF_REEW_KUM_201301.KTAT
                 and CTF_REEW_KUM_201301.KTMO = DTF_REEW_201301.KTMO - 1
            ) t2
      on (
          t1.rowid = t2.rid
      when mathed
        then
          update
             set t1.KTBT_ISO = t2.KTBT_ISO,
                 t1.KTZN_ISO = t2.KTZN_ISO,
                 t1.KTAB_ISO = t2.KTAB_ISO
    SY.

  • UPSERT Within the Same Table

    Hi All,
    I have the following two tables: ALLOWANCE and RANGES. ALLOWANCE has the key column AllowanceID and corresponding to each AllowanceID, there will be a number of RANGE entries. Range has a primary key called RangeID and a reference to AllowanceID. Besides these, it has the following columns.
    RANGESTART
    RANGEEND
    POUNDS
    SUM
    Now, I want to write a query to match the ranges of two AllowanceIDs. ie, Given SorceAllowanceID and TargetAllowanceID, I want to match the number of ranges as well as the range values of the souce to target. So I have the following query (I am using only one column here) followed by an INSERT statement(not shown here),
    UPDATE
    SELECT
    src.pounds AS src_pounds ,
    tgt.pounds AS tgt_pounds
    FROM
    SELECT rank() OVER (PARTITION BY PR.ALLOWANCEID ORDER BY PR.RANGESTART) RN
    ,PR.*
    FROM RANGES PR
    WHERE PR.ALLOWANCEID=sourceallowanceid
    ORDER BY PR.RANGESTART) src ,
    SELECT rank() OVER (PARTITION BY PR.ALLOWANCEID ORDER BY PR.RANGESTART) PN ,PR.*
    FROM ranges PR
    WHERE PR.aLLOWANCEID=targetallowanceid
    ORDER BY PR.RANGESTART) TGT
    WHERE src.Rn=tgt.PN
    SET tgt_pounds = src_pounds;
    But this has thrown ORA-01779. Then I tried with the MERGE statement
    MERGE INTO
    SELECT rank() OVER (PARTITION BY PR.ALLOWANCEID ORDER BY PR.RANGESTART) PN
    ,PR.*
    FROM RANGES PR
    WHERE PR.ALLOWANCEID=targetallowanceid
    ORDER BY PR.RANGESTART) tgt
    USING (SELECT rank() OVER (PARTITION BY PR.ALLOWANCEID ORDER BY PR.RANGESTART) RN
    ,PR.*
    FROM RANGES PR
    WHERE PR.ALLOWANCEID=sourceallowanceid
    ORDER BY PR.RANGESTART) src
    ON ( src.RN = tgt.PN )
    WHEN MATCHED THEN
    UPDATE SET tgt.pounds = src.pounds
    WHEN NOT MATCHED THEN
    --Insert
    which has thrown ORA-00903.
    Please guide me how to write a query for this.
    Thanking you all,
    Pradeep

    This it the forum for the SQL Developer tool. Your question will get better response int the SQL and PL/SQL forum.
    Having said that, you need to be updating a table, not an inline view.
    i.e.
    update x
    set ...
    not
    update (select * from x)
    set ...

  • I just entered the podcast world. I am having trouble with my rss code. This is the error i recieve from itunes when trying to submit the url. Error Parsing Feed: invalid XML:Error line 64:XML documents must start and end within the same entity

    <?xml version="1.0"?>
    <rss xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:itunes="http://www.itunes.com/DTDs/Podcast-1.0.dtd"
    Verson="2.0">
    <channel>
    <title>KPNC Regional Toxcast</title>
    <link>http://kpssctoxicology.org/edu.htm</link>
    <description>KP Toxcast test podcast</description>
    <webMaster>[email protected]</webMaster>
    <managingEditor>[email protected]</managingEditor>
    <pubDate>Tue, 27 Sep 2011 14:21:32 PST</pubDate>
    <category>Science & Medicine</category>
      <image>
       <url>http://kpssctoxicology.org/images/kp tox logo.jpg</url>
       <width>100</width>
       <height>100</height>
       <title>KPNC Regional Toxcast</title>
      </image>
    <copyright>Copyright 2011 Kaiser Permanente. All Rights Reserved.</copyright>
    <language>en-us</language>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <!-- iTunes specific namespace channel elements -->
    <itunes:subtitle>The Kaiser Permanente Northern California (KPNC) Regional Toxicology Service                  Podcast</itunes:subtitle>
    <itunes:summary>This is the podcast (toxcast) of the KPNC Regional Toxicology Service. Providing                 Kaiser and non-Kaiser physicians with anything toxworthy</itunes:summary>
    <itunes:owner>
       <itunes:email>[email protected]</itunes:email>
       <itunes:name>G. Patrick Daubert, MD</itunes:name>
    </itunes:owner>
    <itunes:author>G. Patrick Daubert, MD</itunes:author>
    <itunes:category text="Science & Medicine"></itunes:category>
    <itunes:link rel="image" type="video/jpeg" href="http://kpssctoxicology.org/images/kp tox                   logo.jpg">KPNC Toxcast</itunes:link>
    <itunes:explicit>no</itunes:explicit>
    <item>
       <title>KPNC Regional Toxcast Sample File</title>
       <link>http://kpssctoxicology.org/edu.htm</link>
       <comments>http://kpssctoxicology.org#comments</comments>
       <description>This is the podcast (toxcast) of the KPNC Regional Toxicology Service. Providing                Kaiser and non-Kaiser physicians with anything toxworthy</description>
       <guid isPermalink="false">1808@http://kpssctoxicology.org/Podcast/</guid>
       <pubDate>Tue, 27 Sep 2011 14:21:32 PST</pubDate>
       <category>Science & Medicine</category>
       <author>[email protected]</author>
       <enclosure url="http://kpssctoxicology.org/podcast/kptoxcast_test_092711.mp3" length="367000"                   type="audio/mpeg" />
       <!-- RDF 1.0 specific namespace item attribute -->
       <content:encoded><![CDATA[<p><strong>Show Notes</strong></p>
       <p><a href="KPNC" _mce_href="http://kpssctoxicology.org/">KPNC">http://kpssctoxicology.org/">KPNC Regional Toxicology Service</a> is comprised of               Steve Offerman, MD; Michael Young, MD; Patrick Whitely; and G. Patrick Daubert, MD.               Awesome team!
       <p>Download <a href="KPNC" _mce_href="http://kpssctoxicology.org/podcast/kptoxcast_test_092711.mp3">KPNC"> http://kpssctoxicology.org/podcast/kptoxcast_test_092711.mp3">KPNC Sample               Toxcast</a></p>]]</content:encoded>
       <!-- iTunes specific namespace channel elements -->
       <itunes:author>G. Patrick Daubert, MD</itunes:author>
       <itunes:subtitle>The Kaiser Permanente Northern California (KPNC) Regional Toxicology Service                    Podcast</itunes:subtitle>
       <itunes:summary>This is the podcast (toxcast) of the KPNC Regional Toxicology Service.                   Providing Kaiser and non-Kaiser physicians with anything
                       toxworthy </itunes:summary>
       <itunes:category text="Medicine"></itunes:category>
       <itunes:duration>00:00:18</itunes:duration>
       <itunes:explicit>no</itunes:explicit>
       <itunes:keywords>daubert,toxicology,toxcast</itunes:keywords>
      </item>
    </channel>
    </rss>

    Please when you have a query post the URL of your feed, not its contents.  Is this your feed? -
    http://kpssctoxicology.org/Podcast/kptoxcast_test_rss_092711.xml
    You have a number of cases of a string of spaces in titles: you also have one in a URL which will render that link invalid.
    But what is rendering the whole feed unreadable is your category link:
    <category>Science & Medicine</category>
    The presence of an ampersand ('&') by itself indicates the start of a code sequence, and in the absence of one, and its closing character, invalidates everything which follows, and thus the entire feed. You must replace the ampersand with the code
    &amp;
    Additionally, your opening lines should read thus:
    <?xml version="1.0" encoding="UTF-8"?>
    <rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
    (with the 'purl.org' line if you like).
    If you are going to submit a feed to iTunes you might want to reconsider have 'test' in the filename: apart from the Store having a tendency to reject obvious test podcasts which may not reflect the finished version, you will be stuck with this URL and though you can change the feed URL it's an additional hassle.

  • Can you drag and drop within the same list*?

    *without completely strange things happening?
    It seems like this ought to be fairly straight forward. This
    code is taken from the Flex 2 Component Explorer and I've just
    added a few Drag and Drop parameters to the list. It doesn't quite
    work. The items are duplicated, not selected, selectable. The
    behavior is a bit erratic.
    It seems very natural to want to be able to re-order a list
    using drag and drop so it seems like it should be easy. Obviously,
    I could create a second, empty list--but that would take up
    valuable screen real estate. I've seen a few posts about this and
    none of them were answered so either the solution is obvious
    (please share) or it's impossible (please share).
    Cheers,
    Steve
    <?xml version="1.0"?>
    <!-- Simple example to demonstrate the List Control -->
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml">
    <mx:Script>
    <![CDATA[
    [Bindable]
    public var selectedItem:Object;
    ]]>
    </mx:Script>
    <mx:Model id="mystates">
    <states>
    <state label="Alabama" data="AL"/>
    <state label="Alaska" data="AK"/>
    <state label="Arizona" data="AZ"/>
    <state label="Arkansas" data="AR"/>
    <state label="California" data="CA"/>
    <state label="Colorado" data="CO"/>
    <state label="Connecticut" data="CT"/>
    </states>
    </mx:Model>
    <mx:Panel title="List Control Example" height="75%"
    width="75%"
    paddingTop="10" paddingBottom="10" paddingLeft="10"
    paddingRight="10">
    <mx:Label text="Select a state to see its
    abbreviation."/>
    <mx:List id="source" width="100%" color="blue"
    dataProvider="{mystates.state}"
    change="this.selectedItem=List(event.target).selectedItem"
    dragEnabled="true"
    dropEnabled="true"
    dragMoveEnabled="true"/>
    <mx:VBox width="100%">
    <mx:Label text="Selected State:
    {selectedItem.label}"/>
    <mx:Label text="State abbreviation:
    {selectedItem.data}"/>
    </mx:VBox>
    </mx:Panel>
    </mx:Application>

    The answer is, yes you can. However, I'm not sure why this
    makes a difference.
    I added creationComplete="init();" to the application tag.
    <em>Removed the model</em> and implemented this method:
    public function init(): void {
    source.dataProvider = [
    {label: "Alabama", data: "AL"},
    {label: "Alaska", data: "AK"},
    {label: "Arizona", data: "AZ"},
    {label: "California", data: "CA"},
    {label: "Colorado", data: "CO"},
    {label: "Connecticut", data: "CT"}
    and removed the dataProvider attribute from the List tag.
    Can anyone tell me why the one works and the other
    doesn't?

  • How to have concurrent CSV upload and manual edit in APEX on the same table

    Hi there,
    my users want to have csv upload and manual edit on apex pages functions together...
    it means they want to insert the data by csv upload and also have interactive report and form on the same table...
    so if user A changes something in csv file...then user B update or delete another record from apex fronted (manually in the apex form)...then after that user A wants to upload the csv file,the record was changed by user B would be overwritten ...
    So how can I prevent it?????

    Hi Huzaifa,
    Thanks for the reply...
    I'm going to use File Browser so that end users can upload the files themselves...
    after editing data by users...a manger going to review it and in case of approval , i need to insert the data to one final table....
    so it needs much effort to check two source tables and in case of difference between table of csv and other one...what to do...

  • JTable fixed Row and Column in the same window

    Hi
    Could anyone tip me how to make fixed row and column in the same table(s).
    I know how to make column fixed and row, tried to combine them but it didnt look pretty.
    Can anyone give me a tip?
    Thanks! :)

    Got it to work!
    heres the kod.. nothing beautiful, didnt clean it up.
    * NewClass.java
    * Created on den 29 november 2007, 12:51
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package tablevectortest;
    * @author Sockan
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    public class FixedRowCol extends JFrame {
      Object[][] data;
      Object[] column;
      JTable fixedTable,table,fixedColTable,fixedTopmodelTable;
      private int FIXED_NUM = 16;
      public FixedRowCol() {
        super( "Fixed Row Example" );
        data =  new Object[][]{
            {      "","A","A","A","",""},
            {      "a","b","","","",""},
            {      "a","","c","","",""},
            {      "","","","d","",""},
            {      "","","","","e",""},
            {      "","","","","","f"},
            {      "","b","","","",""},
            {      "","","c","","",""},
            {      "","","","d","",""},
            {      "","","","","e",""},
            {      "","b","","","",""},
            {      "","","c","","",""},
            {      "","","","d","",""},
            {      "","","","","e",""},
            {      "","","","","","f"},
            {      "I","","W","G","A",""}};
        column = new Object[]{"A","B","C","D","E","F"};
        AbstractTableModel fixedColModel = new AbstractTableModel() {
          public int getColumnCount() {
            return 1;
          public int getRowCount() {
            return data.length;
          public String getColumnName(int col) {
            return (String) column[col];
          public Object getValueAt(int row, int col) {
            return data[row][col];
          public boolean CellEditable(int row, int col) {
            return true;
        AbstractTableModel    model = new AbstractTableModel() {
          public int getColumnCount() { return column.length-2; }
          public int getRowCount() { return data.length - FIXED_NUM; }
          public String getColumnName(int col) {
           return (String)column[col+1];
          public Object getValueAt(int row, int col) {
            return data[row][col+1];
          public void setValueAt(Object obj, int row, int col) {
            data[row][col+1] = obj;
          public boolean CellEditable(int row, int col) {
            return true;
        AbstractTableModel fixedTopModel = new AbstractTableModel() {
          public int getColumnCount() { return 1; }
          public int getRowCount() { return data.length - FIXED_NUM; }
          public String getColumnName(int col) {
           return (String)column[col];
          public Object getValueAt(int row, int col) {
            return data[row][col];
          public void setValueAt(Object obj, int row, int col) {
            data[row][col] = obj;
          public boolean CellEditable(int row, int col) {
            return true;
        AbstractTableModel fixedModel = new AbstractTableModel() {     
          public int getColumnCount() { return column.length-2; }
          public int getRowCount() { return FIXED_NUM; }
          public Object getValueAt(int row, int col) {
            return data[row + (data.length - FIXED_NUM)][col+1];
        table = new JTable( model );
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        fixedTable = new JTable( fixedModel );
        fixedTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        fixedTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        fixedColTable= new JTable(fixedColModel);
        fixedColTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        fixedColTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        fixedTopmodelTable = new JTable(fixedTopModel);
        fixedTopmodelTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        fixedTopmodelTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);   
        JScrollPane scroll      = new JScrollPane( table );
         scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
         scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        JScrollPane fixedScroll = new JScrollPane( fixedTable ) {
          public void setColumnHeaderView(Component view) {}
        fixedScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        fixedScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        JScrollBar bar = scroll.getVerticalScrollBar();
        JScrollBar dummyBar = new JScrollBar() {
          public void paint(Graphics g) {}
        dummyBar.setPreferredSize(bar.getPreferredSize());
        scroll.setVerticalScrollBar(dummyBar);
        final JScrollBar bar1 = scroll.getHorizontalScrollBar();
        JScrollBar bar2 = fixedScroll.getHorizontalScrollBar();
        bar2.addAdjustmentListener(new AdjustmentListener() {
          public void adjustmentValueChanged(AdjustmentEvent e) {
            bar1.setValue(e.getValue());
        JViewport viewport = new JViewport();
        viewport.setView(fixedColTable);
        viewport.setPreferredSize(fixedColTable.getPreferredSize());
        fixedScroll.setRowHeaderView(viewport);
        fixedScroll.setCorner(JScrollPane.UPPER_LEFT_CORNER, fixedColTable
            .getTableHeader());   
        JViewport viewport2 = new JViewport();
        viewport2.setView(fixedTopmodelTable);
        viewport2.setPreferredSize(fixedTopmodelTable.getPreferredSize());
        scroll.setRowHeaderView(viewport2);
        scroll.setCorner(JScrollPane.UPPER_LEFT_CORNER, fixedTopmodelTable
            .getTableHeader()); 
        scroll.setPreferredSize(new Dimension(600, 19));
        fixedScroll.setPreferredSize(new Dimension(600, 100)); 
        getContentPane().add(     scroll, BorderLayout.NORTH);
        getContentPane().add(fixedScroll, BorderLayout.CENTER);   
      public static void main(String[] args) {
        FixedRowCol frame = new FixedRowCol();
        frame.addWindowListener( new WindowAdapter() {
          public void windowClosing( WindowEvent e ) {
            System.exit(0);
        frame.pack();
        frame.setVisible(true);
    }

  • Insert and Delete at the same time?

    Hi,
    I have a dynamic list and dynamic form. When a person inserts a record using the dynamic form, I would like to delete a record from another table using a foreign key when the new record is added (assuming a record exists in the other table). Is this achievable, and if so, can anyone provide any help?
    Thanks in advance for any advice provided.
    Gary

    As kendenny says, this appears to be a misunderstanding of how database transactions work.
    As Hoek says, if it's an insert and delete on the same table, there is a MERGE statement that can help do that as a single statement.
    However, you do not do an INSERT from one table and a DELETE at the same time from another table.  But that doesn't matter, because that's the point of logica transactions on a database.
    You perform your insert, which starts a transaction (if one isn't already started).
    You then delete from your other table (which adds to the transaction)
    When you're happy that both things are done, you COMMIT your transaction which then applies those changes.
    If you're not happy with something you can ROLLBACK, and that will undo all the changes from the transaction.
    So, the commit and rollback allow the changes to be applied as one logical unit, even though the changes are applied in multiple steps.

Maybe you are looking for

  • SAP intermediary bank (Bank Chain)

    Hi My company wants to send money to a foreign Vendor. The scenario is as follows Our House Bank : A   Intermediate Bank :B     Vendor's correspondent Bank: C question 1:  In vendor master data I have selected "wire transfer" as mode of payment.  Wha

  • Special Character being replaced by Question Marks in Java Mapping

    Hi All, I need some help on Java Mapping related to special characters. The problem is that i'm using a Java Mapping to add some information to the XML inside the Interface Mapping. This works fine on our development environment but, in our productio

  • Online Redefinition of Binary XML column not possible?

    DB version 11.2.0.1 x64 (still working on upgrading to 11.2.0.3) create table redef_test (         id number(19,0) not null,         xml XMLType,         primary key (id)     XMLTYPE COLUMN "XML" STORE AS CLOB; table REDEF_TEST created. exec dbms_red

  • Is it possible to create a UDF at item_pressed event?

    Hai, I have designed a form with some edit text and one Button. When Button is pressed, given values are stored to a table Master Table. At the same time I want to insert a particular edit text value as a field in another No Object Table. Is it possi

  • Subforms within subforms add Instance problem

    Hi I am new to Adobe Livecycle Designer (I am using version 8.2.1) but I have successful made nearly all elements of the quite long form I need to produce except for one section I am having difficulty getting it to function correctly. In the example