Searching for a more elegant way to write my where clause.

Hi,
I have a table T which has two columns : X(Varchar2(100)), and Y(Varchar2(100)).I want to know all the rows in the table T for which two conditions are simultaneously true: the first condition is X is not null or Y is not null, and the second condition is not(X  is not null and Y is not null). So I write my query like below:
select *
from T
where (X is not null or Y is not null) and  not(X  is not null and Y is not null)But the way I formulate my where clause doesn't seem elegant to me. Please, could I obtain the same result with a more elegant where clause?
Thanks.

<font face="courier">
where (X is not null or Y is not null) and <font color="red">not(X is not null and Y is not null)</font><br>
<font color="red">De Morgan</font><br>
where ((X is not null) or (Y is not null)) and (<font color="red">not(X is not null) or not(Y is not null)</font>)<br><br>
where ((X is not null) or (Y is not null)) and (<b>not(X is not null)</b> or <b>not(Y is not null)</b>)<br>
<b>double negation</b><br>
where ((X is not null) or (Y is not null)) and (<b>(X is null)</b> or <b>(Y is null)</b>)<br><br>
where (<font color="green">(X is not null) <b>or</b> (Y is not null)</font>) <font color="blue"><b>and</b> ((X is null) or (Y is null))</font><br>
Distributivity of <font color="blue"><b>and</b></font> over <font color="green"><b>or</b></font><br>
where (<font color="green">(X is not null)</font> <font color="blue"><b>and</b> ((X is null) or (Y is null))</font>) <font color="green"><b>or</b></font> (<font color="green">(Y is not null)</font> <font color="blue"><b>and</b> ((X is null) or (Y is null))</font>)<br><br>
where (<font color="red">(X is not null) <b>and</b></font> <font color="magenta">((X is null) <b>or</b> (Y is null))</font>) or (<b>(Y is not null) and ((X is null) or (Y is null))</b>)<br>
Distributivity of <font color="red"><b>and</b></font> over <font color="magenta"><b>or</b></font> applied to the <b>second term</b> too<br>
where ((<font color="red">(X is not null) <b>and</b></font> <font color="magenta">(X is null)</font>) <font color="magenta"><b>or</b></font> (<font color="red">(X is not null) <b>and</b></font> <font color="magenta">(Y is null)</font>)) or <br>      ((<b>(Y is not null) and (X is null)</b>)<b> or </b>(<b>(Y is not null) and (Y is null)</b>))<br><br>
<font color="green"><b>Negation</b></font><br>
where ((<font color="green"><strike>(X is not null)</strike> <b>not(Y is null)</b></font> and (X is null)) or ((X is not null) and (Y is null))) or <br>      (((Y is not null) and (X is null)) or (<font color="green"><strike>(Y is not null)</strike> <b>not(Y is null)</b>)</font> and (Y is null)))<br><br>
where ((<font color="blue">not(X is null) and (X is null)</font>) or ((X is not null) and (Y is null))) or <br>      (((Y is not null) and (X is null)) or (<font color="blue">not(Y is null) and (Y is null)</font>))<br>
<font color="blue">Complementation</font><br>
where ((<font color="blue">false</font>) or ((X is not null) and (Y is null))) or <br>      (((Y is not null) and (X is null)) or (<font color="blue">false</font>))<br><br>
<b>where ((X is not null) and (Y is null)) or ((Y is not null) and (X is null))</b><br><br>
preferring clarity (in the eye of beholder as always) over efficiency<br><br>
<b>where x || y in (x,y)</b><br><br>
Regards
Etbin
</font>
Edited by: Etbin on 28.8.2011 11:45
steps separated with empty lines, negation enhanced

Similar Messages

  • IPod touch - more elegant way to sync to a new library?

    I recently had to change the motherboard in my machine, and took the opportunity to upgrade the machine and put on a fresh install of the OS.  I had expected my iPod touch to work like every other device I've had and just sync with a new install of iTunes (ie pull everything off the device and onto the host machine and be up and running without further action required), but unfortunately it gives me an error saying:
    This iPod "..." is synced with another iTunes library.  Do you want to erase this iPod and sync with this iTunes library?
    When I click cancel it lets me do most of what I'd like, but unfortunately it won't let me do a firmware update (from 4.3.4 to 5.1.1) as it says that:
    There are purchased items on the iPod "..." that have not been transferred to your iTunes library...
    I have done a backup of the device successfully, so I'm guessing that I can say yes to the 'erase the iPod' prompt and then just restore it when complete, but before I do that I want to be 100% sure that this process will back everything on the device up (ie after the process will the device function identically to what it is doing now).  Unfortunately the backup process just completes without providing any details, so I have no way to verify that and would appreciate more detail on this front (or if it will restore the link to the old iTunes library as well, at which point I will have just wasted my time)?  As such, I havn't been confident enough in this process to go about risking the erasure.
    The other thing I am wondering is whether the syncrhonization process and/or backup functionality store system level settings as well or just the data?  For instance, entering my WPA2 key was a royal PITA when I first got the device as the UI isn't really well designed to handle long, cryptic encryption keys (no way to show the characters as you enter it (ie can't double check it before clicking okay), no way to paste it from an email, etc.) and I don't particularly want to go through that process again.
    Ideally, I'd like to find a more elegant way around this (ie I'd really like to avoid having to wipe the device) as this is kind of a ridiculous process to have to go through for such a simple task.  If it helps, I still have all of the old files (the new OS and iTunes were installed on a new HDD, so the old iTunes folder/data is still on the old HDD (can't boot to it on the new hardware, but Ican access the raw files)) so if there is some way to convince iTunes to just load up those files and be done with it I'd be very appreciative.

    You need to:
    Transfer iTunes purchases by:
    http://support.apple.com/kb/HT1848?viewlocale=en_USiTunes Store: Transferring purchases from your iOS device or iPod to a computer
    - Transfer othre music by using a third-party program like one of those discussed here:
    Copy music
    - To retain app data and other information, connect the iPod to yur computer and make a backup by right clciking on the iPod under Devices in iTunes and select Back Up
    - Restore the iPod from that backup
    Note that the Backup that iTunes makes does not include synced media like apps and music.

  • No output for XML Publisher Report using CASE/DECODE in Where Clause

    Hi,
    I've a business requirement to modify an existing report which has two input parameters,
    -> p_statcode (Closed Status) which can have values 'Y' or 'N'
    -> p_overdue (Overdue Flag) which can have values 'Y' or 'N'
    The Overdue Flag is an evaluated column having values of Y/N and it is evaluated as follows,
    ONTF_MOD_VAL(NVL (
                                         (TRUNC (SYSDATE)
                                          - (TO_DATE (oe_order_lines.attribute18,
                                                      'DD-MON-RRRR')
                                             + TO_NUMBER (fnd_lookup_values.meaning))),
                                         0
                            overdue_flagThe user requirement now is they needs to be a third option for parameter p_overdue called ALL,
    passing which the output should include records having
    p_statcode is Y ELSE p_statcode is N AND p_overdue is Y OR p_overdue is N
    In other words records having both Y and N vlaues for Overdue Flag have to be returned irrespective of the value given to Closed Status.
    Original where clause in the Data Definition file is as follows,
    WHERE Closed_Status = nvl(:p_statcode,Closed_Status)
                       AND overdue_flag = nvl(:p_overdue,overdue_flag)My modified code is as follows,
    WHERE   Closed_Status = NVL (:p_statcode, Closed_Status)
             AND overdue_flag = (CASE
             WHEN :p_overdue = 'Y' THEN 'Y'
             WHEN :p_overdue = 'N' THEN 'N'
             ELSE overdue_flag
             END)
    OR
    WHERE   Closed_Status = NVL (:p_statcode, Closed_Status)
             AND overdue_flag = DECODE (:p_overdue, 'Y', 'Y', 'N', 'N',overdue_flag)Both approaches have the same problem.
    The output is in EXCEL format. The modified query works fine for p_overdue as Y or N but when p_overdue is passed as ALL it returns an empty EXCEL sheet with just the report output column headers.
    Any help as to why this is the case ?? What is wrong in my approach ?
    Regards,
    Vishal

    not clear about p_overdue = ALL
    which values needed for p_overdue = ALL ?
    try smth like
    WHERE   Closed_Status = NVL (:p_statcode, Closed_Status)
    AND (
       overdue_flag = DECODE (:p_overdue, 'Y', 'Y', 'N', 'N',overdue_flag) and :p_overdue != 'ALL'
       or
      :p_overdue = 'ALL' and (overdue_flag = 'Y' or overdue_flag = 'N')
    )for overdue_flag which has more then 'Y', 'N' values
    if overdue_flag only in ('Y','N') then
    WHERE   Closed_Status = NVL (:p_statcode, Closed_Status)
    AND (
       overdue_flag = DECODE (:p_overdue, 'Y', 'Y', 'N', 'N',overdue_flag) and :p_overdue != 'ALL'
       or
      :p_overdue = 'ALL'
    )

  • Sending a binary attachment via email, looking for a more clean way

    Hi experts.
    I finally managed to send a binary attachment via email. Why "finally"? Never done before!
    Also I got to manage the "not standard" .SAP file extension, because the attachment is a transaction link.
    So let me explain how i did it:
    take SO_NEW_DOCUMENT_ATT_SEND_API1, filling following input data:
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = st_docdata
          commit_work                = 'X'
        TABLES
          packing_list               = lt_packlist
          contents_hex               = lt_hex
          contents_txt               = lt_content
          receivers                  = lt_recv
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          OTHERS                     = 8.
    But how to fill lt_hex? Well I did not found a way to transfer text data into raw data structure (lt_hex is type SOLIX).
    So, here is the trick:
    fill another table, lt_bin type SOLISTI1, with attachment content (text data);
    dump lt_bin content to a file on application server, having care to specify TEXT MODE and UTF-8 encoding;
    now reopen the same file in BINARY MODE and transfer content to lt_hex.
    Why I did not use parameter
    content_bin
    ? Because SAP ECC 6 is unicode enabled (I think UTF-16) and file has got to be UTF-8 or ASCII. Also, packing_list for attachment must specify binary tranfer mode. And doing so each UTF-16 character (2 bytes) is split into 2 characters (1 char + 1 NUL byte). Attachment is now unusable.
    What is the question? Here it is: how to fill lt_hex data directly from text (UTF-16) data, avoiding conversion errors?
    Thank you in advance.

    Hi Chhayank,
    the problem is not the exported xls. If you have a look inside with Notepad or something like that, you will see that your leading zeros are exported correct.Excel-settings occurs this problem, it is all about how to open the document. If you use the import-assistant you will have no problems because there are options available how to handle the different columns.
    Another solution might be to get familiar with ABAP2XLS-Project. I got in my mind, that there is a method implemented, that will help you solving this problem. But that is not a five minute job
    ~Florian

  • External Display w/o Internal Display, More elegant way to do it?

    My desk has a spot for my MBP and a 19" LCD monitor connected via DVI cables. currently (to dissipate heat as i play warcraft) i have to leave the MBP open, and turn down the display brightness to 0.
    Is there an way to get this going automatically? the F7 button only switches between mirrored mode or not. I would like to disable the internal display all-together, rather than dim it to 0.
    suggestions? programs? anything?

    as for a solution, i have found one!
    simple too... in this order:
    1. put the computer to sleep with lid shut
    2. attach an external monitor (i've used DVI, im sure VGA will work too)
    3. attach USB keyboard & mouse (i've used a combo wireless logitech)
    4. attach the power adapter
    5. wake the computer from sleep with lid closed.
    6. open lid (after the computer fully awakes)
    upon completion the internal display is open but the lcd is in fact disabled.

  • How to write the where clause

    Hi ,
    i needed to write a select query  in which the search criteria is
    a part of a string .
    eg.
    select * from DBTABLE where DESCRIPTION = 'abc'.
    here abc is a part of any string.
    Is the way of writing the select query correct,
    If not what is the correct way?

    >
    Harshit Rungta wrote:
    > Hi ,
    >
    > i needed to write a select query  in which the search criteria is
    > a part of a string .
    >
    > eg.
    > select * from DBTABLE where DESCRIPTION = 'abc'.
    >
    >
    >
    > here abc is a part of any string.
    >
    > Is the way of writing the select query correct,
    > If not what is the correct way?
    Hi,
        select * from dbtable into table i_dbtable where description = 'ABC'.
    note : whenever you are checking a condition the string should be in capital letters within quotes.

  • Using for all entries of two internal tables in where clause of the select

    Hi experts,
    My requirement is, need to select Marc-minbe and wrpl-sobst, for all the entries of the two internal tables it_mara , and it_t001w.
    here is the select queries i have used,
    select matnr normt from  mara into it_mara for all entries in it_data where normt = it_data-normt.
    select konnr werks from t001w into it_t001w for all entries in it_data where konnr = it_data-konnr.
    now i need to select minbe of marc table and sobse of wrpl table for all the entries of above internal tables, it_mara and it_t001w, using both matnr of it_mara and werks of it_t001w in where condition.
    Pls advise how i can do it.
    Thanks.
    Moderator message: very basic, please work on this yourself first, these forums are not a substitute for ABAP training.
    Edited by: Thomas Zloch on Dec 6, 2010 9:38 AM

    Hi
    call SE16 with table TFTIT in order to get a full list (it will be long...)
    A list of FMs with parameters can be found in table FUNCT.
    Finally go to sm37rsdf4
    that will give you all the function modules with description
    Here is the list:
    http://www.erpgenie.com/abap/functions.htm
    hope this helps...
    Regards
    CSM Reddy

  • MDX - More efficient way?

    Hi
    I am still learning MDX and have written this code. It needs to recalculate all employees in a cost center (COSTCENTER is a property of the DIM EMPLOYEE) when one of the assumptions (e.g P00205 etc) change. These assumptions are planned on cost center level and planned against employee DUMMY. Is there a more efficient way to write this code as there are lots of accounts that needs to be posted to::
    *SELECT (%EMPLOYEE%, ID, EMPLOYEE, [COSTCENTER]  = %COSTCENTER_SET%)
    //Workmens Comp
    *XDIM_MEMBERSET P_ACCT = "IKR0000642000"
    *FOR %EMP% = %EMPLOYEE%   
             [EMPLOYEE].[#%EMP%] = ( [P_ACCT].[P00205],[EMPLOYEE].[DUMMY ]) * ( [P_ACCT].[P00400],[EMPLOYEE].[%EMP%] )
    *NEXT
    *COMMIT
    //Fringe Benefits Employer
    *XDIM_MEMBERSET P_ACCT = "IKR0000628100" 
    *FOR %EMP% = %EMPLOYEE%
             [EMPLOYEE].[#%EMP%] = ( [P_ACCT].[P00210],[EMPLOYEE].[DUMMY ]) * ( [P_ACCT].[P00400],[EMPLOYEE].[%EMP%] )
    *NEXT
    *COMMIT
    //Fringe Benefits Other
    *XDIM_MEMBERSET P_ACCT = "IKR0000626100" 
    *FOR %EMP% = %EMPLOYEE%
             [EMPLOYEE].[#%EMP%] = ( [P_ACCT].[P00209],[EMPLOYEE].[DUMMY ]) * ( [P_ACCT].[P00400],[EMPLOYEE].[%EMP%] )
    *NEXT
    *COMMIT

    Maybe the following?
    *SELECT (%EMPLOYEE%, ID, EMPLOYEE, [COSTCENTER]  = %COSTCENTER_SET%)
    *XDIM_MEMBERSET EMPLOYEE = %EMPLOYEE%
    *XDIM_MEMBERSET P_ACCT = IKR0000642000,IKR0000628100,IKR0000626100
    //Workmens Comp
    [P_ACCT].[#IKR0000642000] = ( [P_ACCT].[P00205],[EMPLOYEE].[DUMMY] ) * ( [P_ACCT].[P00400] )
    //Fringe Benefits Employer
    [P_ACCT].[#IKR0000628100] = ( [P_ACCT].[P00210],[EMPLOYEE].[DUMMY] ) * ( [P_ACCT].[P00400] )
    //Fringe Benefits Other
    [P_ACCT].[#IKR0000626100] = ( [P_ACCT].[P00209],[EMPLOYEE].[DUMMY] ) * ( [P_ACCT].[P00400] )
    *COMMIT
    You should probably also restrict explicitly on all other dimensions in your applications so that none are accidentally left open that don't need to be.
    Ethan

  • Searching for the fields of a table(very very urgent)

    Hi all,
    i am in graet trouble now.i am searching for the fields like
    1)country of origin where the finished good is created.
    2) customer sales order number
    3)customer sales order line number
    i am writing a report for delivery order.in this report i have to refer customer PO & customer SO .
      i mean, my company has a customer ( seagate) & seagate has a customer (let maxtor).initially maxtor will give a PO to seagate then seagate will raise a SO againest maxtor.
       Then seagate will send PO number(of maxtor), PO line number,SO number(seagate), SO line number(seagate) to our company.
       Then i have to write a report for sales order & delivery order.in these reports i have to refer seagate PO number & seagate SO number for reference.
    i got PO number as vbkd-bstkd but not getting any field for reference Sales order.plz advice me on this. it is very very urgent.
    ur idea is highly appreaciated.
    Thank u very much.
    Regards
    pabitra

    check out tables VBAK(sales order header), VBAP(sales items)

  • Why won't Adobe X search for hyphens?

    I'm using Adobe X with Windows 7 to proof fiction for a publishing firm.  I would like to be able to search for words at the end of the lines where there is a word break but Adobe X will not let me search for those.
    For example, I found in the text I'm reading the word animals and it is at the end of the line and is broken out like this:
    ani-
    mals.
    I would like to search for ani- and see if there are more occurances like this so I can make sure I catch all broken out words to see if they are done correctly, but if I search for that hypen, it won't bring up this example in the results (or any other words at the end of lines that are broken).  If I copy and paste ani- into the search box it won't paste the hypen at the end.
    Now, If I manually type in the hypen it won't search for the right kind of hyphen.  It always leaves out in the results the ones I need to look at the most, which are broken words with hypens at the end of the lines.
    Is this some sort of "special character" that I'm searching for?  If so, how do I search for it?  Any suggestions would be most appreciated!

    Hi. As a workaround you can enable "Always use native photo browsers"  in the PS Touch settings. It's listed under "Preferences" -> "Access Local Photos setting". See attached screenshot
    We are working on a fix for the next release.
    Guido

  • Recently opening an HTML file on my computer makes firefox attempt a search for the entire file name in the search engine online, how to do i correct that?

    when opening an HTML file recently my Firefox automatically opens up a yahoo search screen and the file, the entire file name and route for the file is searched for online. I don't even use Yahoo Search i use Google but that doesn't mater have to open the file manually with searching it on on the open screen to read it because it's trying to search for it online instead of reading it from where i clicked on it.
    I.E.
    file:///F:/Reading/II.html
    would try to search
    https://us.search.yahoo.com/yhs/search?hspart=aztec&hsimp=yhs-default&type=derr_100_476&p=file%3A%2F%2F%2FF%3A%2FReading%2Fhtml&rnd=737753354&param1=sid%3D476%3Aaid%3D100%3Aver%3D15005%3Atm%3D264%3Asrc%3Dderr%3Alng%3Den%3Aitype%3Da%3Auip%3D1124173343
    I have no idea what the
    &rnd=737753354&param1=sid%3D476%3Aaid%3D100%3Aver%3D15005%3Atm%3D264%3Asrc%3Dderr%3Alng%3Den%3Aitype%3Da%3Auip%3D1124173343
    is for but it's never done this before.

    Please read this article about restoring bookmarks:
    http://kb.mozillazine.org/Lost_bookmarks
    As far as your passwords are concerned, I don't think there's anything you can do. But for the future, you can use the following add-ons to avoid any future loss:
    https://addons.mozilla.org/en-US/firefox/addon/2848/
    or
    http://www.xmarks.com/
    Both are good.
    And a simple way to import your bookmarks (since you already saved it on your desktop as html) is:
    Bookmarks / Organized Bookmarks / Import and Export
    Good luck.

  • Sales Order in PCUI: Search for products based on BP?

    Hello,
    my customer wants to migrate to PC-UI and has the requirement that when creating a new sales order the search for products only returns those products that are defined by a partner-product relation PPR, as is possible in standard SAPGui. Unfortunately I do not see a way to restrict the search for products in a way like this, is there?
    Thanks
    Thomas

    Hello thomas,
    If it is not available in standard, you can always enhance the query method of your MAC to show select only products based on your parner-product relation PPR.
    Regards,
    Frederic

  • More elegant timing solution

    Hi all.
    Im am looking for some advice regarding a GUI that I am developing using netbeans.
    When a particular button is clicked on the interface I have a series of jPanels which I wish to make visisble with a delay in between each one.
    I currently have a solution posted here using a Timer and a switch statement within the timer class but it all seems a little cumbersome and basic. I just wondered if anyone had any ideas for a more elegant solution.
    Thanks
    int listCount =1;
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
            timer = new Timer(2500, new ListAction());
            timer.start();
    class ListAction implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                switch (listCount) {
                case 1: jLabel32.setVisible(true);  
                        jLabel33.setVisible(true);
                        jLabel34.setVisible(true);
                        jLabel35.setVisible(true);
                        jLabel36.setVisible(true);
                        jLabel37.setVisible(true);
                        jLabel38.setVisible(true);                 
                        listCount++;                  
                        break;
                case 2:
                        jLabel32.setBackground(new Color(241,114,114));               
                        listCount++;
                        break;
                case 3:
                        jLabel32.setBackground(new Color(240,240,240));
                        jLabel33.setBackground(new Color(241,114,114));                                      
                        listCount++;
                        break;
                case 4:
                        jLabel33.setBackground(new Color(240,240,240));
                        jLabel34.setBackground(new Color(241,114,114));  
                        jLabel35.setBackground(new Color(241,114,114));  
                        jLabel28.setVisible(true);
                        jLabel29.setVisible(true);
                        jLabel41.setVisible(true);
                        jLabel30.setVisible(true);
                        jLabel30.setText("NULL");                   
                        listCount++;
                        break;
                case 5: 
                        jLabel34.setBackground(new Color(240,240,240));
                        jLabel35.setBackground(new Color(240,240,240));
                        jLabel36.setBackground(new Color(241,114,114));                                       
                        listCount++;
                        break;
                case 6: 
                        jLabel30.setText("12");
                        jLabel31.setVisible(true);
                        listCount++;
                        break;
                case 7: 
                        jLabel42.setVisible(true);
                        jLabel43.setVisible(true);
                        jLabel44.setVisible(true);
                        listCount++;
                        break;
                case 8: 
                        jLabel45.setVisible(true);
                        jLabel46.setVisible(true);                   
                        listCount++;
                        break;
                case 9:
                        jLabel36.setBackground(new Color(240,240,240));
                        jLabel37.setBackground(new Color(241,114,114));                                      
                        listCount++;
                        break;
                case 10:
                        jLabel30.setText("");
                        jLabel31.setText("");
                        listCount++;
                        break;
                case 11:
                        jLabel30.setText("21");
                        jLabel31.setText("NEXT");
                        jLabel43.setText("NULL");
                        jLabel44.setVisible(false);
                        jLabel45.setVisible(false);
                        jLabel46.setVisible(false);                   
                        listCount++;
                        break;
                case 12:
                        jLabel37.setBackground(new Color(240,240,240));
                        jLabel38.setBackground(new Color(241,114,114));                  
                        listCount++;                   
                        break;
               case 13:
                        jLabel38.setBackground(new Color(240,240,240));                                     
                        listCount=1;
                        timer.stop();
                        break;
                default: System.out.println("Invalid");break;
        }

    Create an Interface. Something like:
    interface PropertyChanger
         public void changeProperty();
    }Then implement the interface for each property. Something like:
    public class VisiblePropertyChanger
        private JComponent compoennt;
        private boolean visibility;
        public VisiblePropertyChanger(JComponent component, boolean visibility)
            this.component = component;
            this. visibility = visibility;
        public void changeProperty()
            component.setVisible( visibility );
    }Now your Timer will need an ArrayList of ArrayLists to store all the property changes:
    ArrayList main = new ArrayList();
    Add property changes information to an array list for each interval
    ArrayList interval1 = new ArrayList();
    interval1.add( new VisiblePropertyChanger(label32, true) );
    interval1.add( new VisiblePropertyChanger(label33. true) );
    main.add(interval1);
    ArrayList interval2 = new ArrayList();
    interval2.add( new BackgroundPropertyChanger(label32, new Color(...)) );
    main.add(interval2);
    ...Now the code in the actionPerformed would need to be change to get the "interval" array list from the main. Then you iterate through each PropertyChanger and invoke the changeProperty() method.

  • How can I use SQL to search for a pattern within a field?

    Hello, Frank, Solomon, ect
    I am now faced with this particular scenario, I've got the SQL to search through a field to find text within the field, but I have to know what it is before it can look for it.
    What I have to do is this:
    Search through a field, for a pattern, and I won't know what the data is I am looking for. Can this be done in SQL?
    For instance, Here is my SQL this far, I was helped allot in order to get to this point.
    select table_name,
           column_name,
           :search_string search_string,
           result
      from (select column_name,
                   table_name,
                   'ora:view("' || table_name || '")/ROW/' || column_name || '[ora:contains(text(),"%' || :search_string || '%") > 0]' str
              from cols
             where table_name in ('TABLE1', 'TABLE2')),
           xmltable (str columns result varchar2(10) path '.')
    When you execute the above SQL, you have to pass in a value. What I really need is to alter the above SQL, to make it search for a pattern that exist's within the text of the field itself.
    Like for instance, lets say the pattern I am looking for is this" xx-xxxxx-xxxx" and it's somewhere in a field.
    I need to alter this SQL to take this pattern and search through all the schemas and tables to look for this pattern match.
    Can be done?

    When you use something dynamically within a function or procedure, roles do not apply and privileges must be granted directly.  So, you need to grant select on dba_tab_cols directly.  If you want to do pattern matching then you should use regular expressions.  The following example grants the proper privileges and uses regexp_instr to find all values containing the pattern xxx-xxxx-xxxx, where /S is used for any non-space character.  I limited the tables in order to save time and output for the test, but you can eliminate that where clause.
    SYS@orcl> CREATE USER test IDENTIFIED BY test
      2  /
    User created.
    SYS@orcl> ALTER USER test QUOTA UNLIMITED ON USERS
      2  /
    User altered.
    SYS@orcl> GRANT CREATE SESSION, CREATE TABLE TO test
      2  /
    Grant succeeded.
    SYS@orcl> GRANT SELECT ON dba_tab_cols TO test
      2  /
    Grant succeeded.
    SYS@orcl> CONNECT test/test
    Connected.
    TEST@orcl> SET LINESIZE 90
    TEST@orcl> CREATE TABLE table1
      2    (tab1_col1  VARCHAR2(60))
      3  /
    Table created.
    TEST@orcl> INSERT ALL
      2  INTO table1 (tab1_col1) VALUES ('xxx-xxxx-xxxx')
      3  INTO table1 (tab1_col1) VALUES ('matching abc-defg-hijk data')
      4  INTO table1 (tab1_col1) VALUES ('other data')
      5  SELECT * FROM DUAL
      6  /
    3 rows created.
    TEST@orcl> CREATE TABLE table2
      2    (tab2_col2  VARCHAR2(30))
      3  /
    Table created.
    TEST@orcl> INSERT ALL
      2  INTO table2 (tab2_col2) VALUES ('this BCD-EFGH-IJKL too')
      3  INTO table2 (tab2_col2) VALUES ('something else')
      4  SELECT * FROM DUAL
      5  /
    2 rows created.
    TEST@orcl> VAR search_string VARCHAR2(24)
    TEST@orcl> EXEC :search_string := '\S\S\S-\S\S\S\S-\S\S\S\S'
    PL/SQL procedure successfully completed.
    TEST@orcl> COLUMN "Searchword"     FORMAT A24
    TEST@orcl> COLUMN "Table"     FORMAT A6
    TEST@orcl> COLUMN "Column/Value" FORMAT A50
    TEST@orcl> SELECT DISTINCT SUBSTR (:search_string, 1, 24) "Searchword",
      2               SUBSTR (table_name, 1, 14) "Table",
      3               SUBSTR (t.column_value.getstringval (), 1, 50) "Column/Value"
      4  FROM   dba_tab_cols,
      5          TABLE
      6            (XMLSEQUENCE
      7           (DBMS_XMLGEN.GETXMLTYPE
      8              ( 'SELECT ' || column_name ||
      9               ' FROM ' || table_name ||
    10               ' WHERE REGEXP_INSTR
    11                     (UPPER (' || column_name || '),''' ||
    12                  UPPER (:search_string) || ''') > 0'
    13              ).extract ('ROWSET/ROW/*'))) t
    14  WHERE  table_name IN ('TABLE1', 'TABLE2')
    15  ORDER  BY "Table"
    16  /
    Searchword               Table  Column/Value
    \S\S\S-\S\S\S\S-\S\S\S\S TABLE1 <TAB1_COL1>matching abc-defg-hijk data</TAB1_COL1>
    \S\S\S-\S\S\S\S-\S\S\S\S TABLE1 <TAB1_COL1>xxx-xxxx-xxxx</TAB1_COL1>
    \S\S\S-\S\S\S\S-\S\S\S\S TABLE2 <TAB2_COL2>this BCD-EFGH-IJKL too</TAB2_COL2>
    3 rows selected.

  • Search for certain Characters within set of Characters - in a field

    Hello -
    I know a search can be made within a field for a word, but I am not to sure, or I don't know how to accomplish this...To do a search in a field for certain characters within a larger set of charcters.
    For example: I would search, in the Call Description field, for DXXXX within CA0001DXXXXYYY or search for LXXXX within CA0001LXXXXYYY, the X is numeric characters and the Y's are Alpha characters. Can crystal accomplish this....
    Thanks for your gracious help....
    G.

    Like I said earlier, this code:
    If instr({database_field}, 'DXXXX') > 0 then "String Found" else "Not Found"
    cannot be used in a Record Selection formula.
    The following code can be used in the Record Selection formula:
    Instr({database field}, "string") > 0
    If you wish to search for 'D4444' in the field and return records where a match is found, you would use:
    Instr({database field}, "D4444") > 0
    -Abhilash

Maybe you are looking for