How to compare 2 lists of box-multi-select/shuttle APEX (e.g.1:2:3 and 3:1:2) for equality?

I want to validate 2 selections of list of shuttle for equality. for example

1:2:5:7:18:3

and

1:5:7:2:3:18

should be treated as equals and therefore valid (i.e. same selections but in different order)

While

1:2:5:7:18:3

and

1:2:18:9 are not equal and would fail validation.

If I use the function string_to_table() on the two lists, then I need sort the associative arrays and then compare them for equality.  Any suggestions on the best way to do it?

Thanks in advance

PaulP

Thanks for all help you, but I decided to stay with string_to_table APEX tables and keep things simple.  I decided to return Varchar2 ('TRUE', 'FALSE') instead of boolean (TRUE, FALSE) so I could use the function in a SQL WHERE clause.

Here's my working solution

create or replace FUNCTION CheckMultiSelectStringsEqual(
      p_string1    IN VARCHAR2 ,
      p_string2    IN VARCHAR2 ,
      p_separator IN VARCHAR2)
    RETURN varchar2
------------------------------------------------------------------------------------------------------------------
-- This function accepts 2 multi-select/shuttle box strings in the format '1:2:3:5:12:4'
-- and a string separator i.e.':' and irrespective of the order of individual selections within
-- the string, returns 'TRUE' if the strings are equal else returns 'FALSE'.
-----------------------------------------------------------------------------------------------------------------
  IS
    l_table1 apex_application_global.vc_arr2;
    l_table2 apex_application_global.vc_arr2;
    v_return varchar2(8);
  BEGIN
    if p_string1 is null or p_string2 is null or p_separator is null then
      raise_application_error(-20001,'USAGE: CheckMultiSelectStrings() function requires 2 not null strings and a separator character' );
    end if;
    l_table1 := apex_util.string_to_table(p_string1, p_separator);
    l_table2 := apex_util.string_to_table(p_string2, p_separator);
    if l_table1.count() <> l_table2.count() then
        return 'FALSE';
    end if;
    <>
    FOR i IN 1..l_table1.count() LOOP
        FOR j IN 1..l_table2.count() LOOP
           if l_table1(i)=l_table2(j) then
             v_return:='TRUE';
             continue OUTER_LOOP;
           else
             v_return:= 'FALSE';
             continue;
           end if;
        END LOOP; -- FOR j IN 1..l_table2...
        EXIT OUTER_LOOP WHEN v_return = 'FALSE';
    END LOOP; --FOR i IN 1..l_table1.
    RETURN v_return;
  END;

-= == HERE IS THE TEST FOR THE FUNCTION CODE =.

set serveroutput on
declare
v_return varchar2(8);
begin
v_return:= CheckMultiSelectStringsEqual('1:2:3:4','2:1:3:4',':');
      if v_return='TRUE' then
          dbms_output.put_line('Strings are equal');
      else
          dbms_output.put_line('Strings are NOT equal');
      end if;
end;

Hope this helps someone...

PaulP

Tags: Database

Similar Questions

  • Cascade lookup - Can you have a list combo box multiple selection among children

    Can we have a list of regular selection be parent and cascading to a list combo box multiple selection?

    Lol drop-down list multiple selection cannot be parent, Fahrenheit.

  • I need a box multi select drop-down list or list of selection with image or icon faclitliy

    Hello

    I tried to find a plugin or a jquery plugin that allows to perform the task of

    have a list of selection with images and there should be a facility such as multi select.

    How this can be accomplished. One have they implemented it in any of their application

    Any information will be greatly appreciated.

    Thank you

    pauljohny100 wrote:

    Hello

    I tried to find a plugin or a jquery plugin that allows to perform the task of

    have a list of selection with images and there should be a facility such as multi select.

    How this can be accomplished. One have they implemented it in any of their application

    Any information will be greatly appreciated.

    When ask questions user interface-related still State (at least) the full version of APEX, the theme and the version of browser compatibility / required.

    See the plugin jQuery Select2 , for which there is a plug in APEX .

    Pre-plugin when we have implemented requirements like this using a model report, CSS and personal...

  • How to turn of the yellow box with the magnifying glass in there? I hate that I'm looking for another browser to use!

    If I highlight a word or accidentally highlight a Word, I get this ubiquitous little yellow box with a magnifying glass or the mention "Loading". I hate it. I have to move the cursor on a blank area, then click to get rid of it. He is quite bored. I'm tired of fighting the browser to do my job! What fool this? I can't find a way to turn it off.

    In addition, to help further research, you could paste your list of extensions in response. For this list, the simplest method is to use the support information page, you can open using either:

    • button "3-bar" menu > "?" button > troubleshooting information
    • (menu bar) Help > troubleshooting information
    • type or paste everything: in the address bar and press Enter

    Scroll down a little the Extensions section, and then select the table below with your mouse and copy (for example, right-click > copy or Ctrl + c), then paste into an answer here. It's a bit messy, but we are used to it.

  • List several boxes of selections in the text area

    Hey all, I got a very helpful response last time, but now I want to put several list boxes selections in a box.  * Line * Help!

    Here is a script to custom calculation, you can use for the text field. I guess it's multiline and you want each element of list on a separate line box:

    Custom calculation script

    (function () {}

    Get field values

    var v1 = getField("lb1").value;

    var v2 = getField("lb2").value;

    var v3 = getField("lb3").value;

    Initialize the array

    var a1 = [];

    Add the list box values in table

    A1 = a1.concat (v1);

    A1 = a1.concat (v2);

    A1 = a1.concat (v3);

    Convert the table to a string, separating the values with a carriage return

    and set the value of this field

    Event.Value = a1.join ("\r");

    })();

    I coded this for more clarity, so you can be able to do so more effectively. Any decent JavaScript reference will have more information on the methods of array concat and join.

  • Compare 2 lists and running operation less

    Hello
    How to compare 2 lists and perform the operation with these lists less

    For ex:
    Declare
     list1 varchar2(100) := '1,2,3,4,5';
     list2 varchar2(100) := '2,3,4,5,6';
    Begin
      select list1 from dual
       minus list2 from dual
    
    end;

    Hello
    Assuming that your version of Oracle support regular expressions, this could be done like this:

    select rtrim(ltrim(regexp_substr('1,2,3,4,5', ',?[0-9]+,?',1, level), ','), ',')
    from dual
    connect by level <= length(translate('1,2,3,4,5',',0123456789', ','))+1
    minus
    select rtrim(ltrim(regexp_substr('2,3,4,5,6', ',?[0-9]+,?',1, level), ','), ',')
    from dual
    connect by level <= length(translate('2,3,4,5,6',',0123456789', ','))+1
    

    Published by: grey_narn on February 10, 2012 12:49 AM

  • can anyone tell how to compare two documents with two controlled with the same mouse pointers

    can anyone tell how to compare two documents with two controlled with the same mouse pointers?

    Windows and OS X can only display a mouse pointer - it is created by the operating system, not the application.

  • How do I now zoom in on a selected area?

    How do I now zoom in on a selected area? Previously he had command space and then drag the box, it seems to no longer work

    Delete two preferences of the main account files, then copy them from the new account.

  • How to hide a list box.

    Hello.

    Is it possible to hide a list box?

    For example I want five list boxes that overlap and the command buttons five, an associate of each list box. When you press a button in the associated list box should then be made visible.

    I couldn't find a SetCtrlAttribute (panelHandle, PANEL_LISTBOX1, ATTR_HIDE_ACTIVE_ITEM, 0) type command to hide a list box.

    How can this be accomplished?

    Thank you.

    That's all. Silly me, I was looking for Hide, hidden, not Visible.

    Thank you.

  • How to display the list of components in ultiboard 10?

    The DRC report the errors where the components that are no longer in the design have been removed. How to display the list component and then remove them from the netlist to stop this?

    Ultiboard reported missing errors of component (part 'X' is not about design) because the part is always referenced by a net. To fix this, you must remove the part of the net. Following the steps below to remove the part form the net.

    1 tools > Netlist Editor

    2. for each network that the part has been connected to, select the Net (upper-left).

    3. Select the tab of pine trees, select the part and it is the PIN in the dialog box, then click on remove

    The problem is when the part is removed, I see no easy way to determine the threads you need to remove the part of. I entered this as a feature request to make this easier, but as a workaround, you can put part and say Ultiboard what the missing part, then search the net names on the pins and remove the part of these pins

    1 place a piece with a lot of pine trees (for example the part that was removed, or for example through Hole technology > Connectors > SIL & headers > HEADER2X9). When you place the part, make sure that the RefDes matches the RefDes of the part which has been removed.

    2. once the room is placed, you should see rats nest lines that connect the part to the nets.

    3 Zoom on the pins. You should now see the net name on each of the axes. For each of the pins connected, remove it from the net as described above.

    4. remove the part that you placed.

  • How to expand the list of "trash".

    Currently the list of waste shows that recent deletions of 20 or longer.  How to extend this list or it back until you see the destruction that precedes

    Hello

    Recycle bin size are you referring?

    You can change the Recycle Bin settings according to your way of working. For example, if rarely, you empty the Trash because you want to save your discarded files, you can increase the maximum size of the Recycle Bin storage.

    If you like to keep all your deleted files in the Recycle Bin as a safety net, you can increase the maximum size of the Recycle Bin storage.

    1. On the desktop, right-click Recycle Bin, and then click Properties.

    2. Recycle Bin location, click the location of the Recycle Bin you want to change (probably your C drive).

    3. Click custom size, and then, in the maximum size (MB) box, enter a maximum size of storage (in megabytes) for the Recycle Bin.

    4. Click OK.

    Reference:

    Change the Recycle Bin settings

    http://Windows.Microsoft.com/en-IE/Windows7/change-the-Recycle-Bin-settings

    Hope this information helps.

  • Table multi-selection disabled the check boxes in ADF 10 g

    I think I met an obstacle when you work with a multi-selection table in 10 ADF.

    The selection itself works very well. However, my problem is to try to disable some of these boxes several selections. These boxes are disabled using the expression language. Once disabled, I can always choose these rows in the table using the button 'Select all' created by multiple selection facet. On the page sent, the disabled lines are not recognized as being selected, which is good. However, they always seem to be selected on the front-end server, which would be confusing for users.

    <af:table emptyText="No roles were found"
              binding="#{backing_userRoles.tableRoles}"
              id="tableRoles"
              value="#{backing_userRoles.userRoleList}"
              var="userRole">
                            <f:facet name="actions">
                              <af:commandButton text="Copy Roles"
                                                binding="#{backing_userRoles.cmdCopy}"
                                                id="cmdCopy"
                                                action="#{backing_userRoles.cmdCopy_action}"/>
                            </f:facet>
                            <f:facet name="selection">
                              <af:tableSelectMany text="Select items and ..."
                                                  binding="#{backing_userRoles.tableSelectMany1}"
                                                  id="tableSelectMany1"
                                                  rendered="#{backing_userRoles.managerFlag}"
                                                  disabled="#{userRole.role.autoGrantedFlag eq 'Y'}"/>
                            </f:facet>
    

    multiselecttable.PNG

    So as you can see, the disabled check box has been selected even when disabled. Any ideas on how to change this behavior? Or maybe just get rid of the default generated 'select all ' | 'Select none' orders?

    Thank you

    Cody

    Or, remove selection facet and make sure you have a selection logic - that is to say, some transient Boolean attribute of VO enabled/disabled state, and you have Select All/Select none

  • Automatically populate a drop-down list by using another selection from the drop-down list box

    New java/preparation forms so I apologize in advance.

    I currently have a menu drop-down box 1 (Occupation) with three options: "enter your own description/blank", retired housewife. When someone chooses either retirement or anyone at home, I would another drop box 2 (employer) to assign automatically "n/a. . The employer drop box has only two options: "enter your own/blank", N/A.

    Far, I could for that box to fill but only when the person clicks in the box (as if they were about to enter their own text.) Then only it will fill the drop-down list "employer." I would like it auto fill once the person has chosen retired, Virgin or stay-at-home woman without having to enter in the box (just using the arrow to the size of the drop-down list box).

    I currently have a key shot that resets the employer box when a person chooses the option vacuum/enter your own option. I then a JavaScript (only for the housewife now) that only works if you click the box of. Key combination works I want to than the other options work as well. If the client settles on white, the choice of the employer updates automatically empty without having to click in the box of. Any help (including general advice to make my code cleaner) is very appreciated!

    Current script of typing:

    If {(event.willCommit)

    If (event.value == "") this.resetForm (["use"]); of other SetFieldValues (event.value);

    }

    The current upward, mice running JavaScript :

    var v = this.getField ("Occupation") .value

    If (v is "Housewife")

    1. this.getField("Employer").value = "N/a".

    I think maybe I should use event.willCommit in my formula, but I'm not sure how to include it.

    Thank you!

    I would not use the key sequence or MouseUp actions for this, but the action post.

    Just make sure that you set the field option to validate the selected value immediately (under Properties - Options) and then use this code as the custom validation script:

    var employerField = this.getField("Employer");
    if (event.value=="Homemaker" || event.value=="Retired")
        employerField.value = "N/A";
    else employerField.value = employerField.defaultValue;
    
  • How to compare the structure of multiple tables... have just TOAD &amp; CAULK

    Hello

    Several times, I get a request to load the data in the tables of one schema to another. But before doing that I need to compare the structures of tables in the source and target schema.

    How can I do? The list of tables to continue to change every now and then. A TOAD there is no option to compare a selected table list. Comparing schemas whole is not an option before me that patterns are too huge and it takes a lot of time to do the level schema comparison.
    Note This is a client machine, and we are not allowed to install any s/w.


    I'm working on the provision of a unix script that does this for me. But that may take some time given the intense work schedule and my lack of knowledge of unix scripting languages.

    Can anyone suggest a way to do it?

    Regds,
    Malika

    I need to compare the structures of tables in the schema source & target.

    SELECT THE TABLE TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER, DATA_LENGTH, DATA_PRECISION, DATA_SCALE DBA_TAB_COLUMNS WHERE OWNER = 'SOURCE '.
    LESS
    SELECT THE TABLE TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER, DATA_LENGTH, DATA_PRECISION, DATA_SCALE DBA_TAB_COLUMNS WHERE OWNER = 'TARGET'
    UNION
    SELECT THE TABLE TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER, DATA_LENGTH, DATA_PRECISION, DATA_SCALE DBA_TAB_COLUMNS WHERE OWNER = 'TARGET'
    LESS
    SELECT THE TABLE TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER, DATA_LENGTH, DATA_PRECISION, DATA_SCALE DBA_TAB_COLUMNS WHERE OWNER = 'SOURCE '.

  • Adobe Acrobat 9: Javascript populated the drop-down list box - response selected array will not save

    I have a combo on one of my forms box that is filled with the help of a Javascript array.  The drop-down list box is filling very well, but when an item is selected in this drop-down list box, the selected item does not save when the user saves the document.  Any suggestions as to what is the problem and how it can be corrected?  I am a loss to know where even to start the search.  Any help is greatly appreciated.

    Thank you.

    Lisa

    It seems that the drop-down list box may be getting filled with code that runs when the form is opened. If so, it will overwrite the value selected, whenever it opens. The solution would be to change the code so that it is not than that. If not, you can post the form somewhere so we can take a look?

Maybe you are looking for