Performance the use of a 'Like' filter * is not due to the index right question *.

Hello
We have just published an Oracle APEX application for users and encountered a performance problem in the production version that wasn't developing. The interactive report contradicts a simple view that returns data similar to:

NAME VALUE MIN MAX
1 1 3 BEL123
3 3 4 BEL245
2 1 3 AB222


The problem is that when you use a filter on the column name with a similar operand (name LIKE "% NICE"). Performance of the queries are very poor (average is 29 seconds to return based on the statistics of the APEX). Are huge paintings, but the performance development is fast (almost instantly). Here are the things I looked in to try to identify the problem:

(1) I tried to run the same exact query in SQL * more performance is fast in production and development, so it's not the index.
(2) creating any new reports from zero causes the same results in production and development. So its not anything specific that has been changed in both versions (which are identical)
(3) put the NAME Like "% NICE" directly in the clause the report SQL product quick returns in production, so the problem is not the user of APEX not seeing the index for some reason any. It also ensures that differences in data in two databases are not the cause of this.

So my only theory that is somehow using similar filter does not allow the index on the column NAME to be used, but only in the production. Any ideas... I am at a loss.

Published by: user491396 on January 7, 2009 14:18

I think that if you run the same exact query that generates the APEX, it wouldn't matter if you ran the query of the APEX or SqlPlus. He would still use the same execution plan.
It seems to me that the optimizer for some reason any do not push predicates in the view which might then a more optimal plan. You could try the 'PUSH_PREDICATE' or 'FIRST_ROWS' advice in the report query and check the generated execution plans to see if they change.

CITY

Tags: Database

Similar Questions

  • Computer makes a sound random bing and the word "Cup" will Flash in the lower right, questions also play photo slide show.

    Original title: random noise

    My computer is to produce a random audio bing and the word "Cup" will Flash in the lower right.  I connected a new keyboard, and then my speakers did not work, then I reconnected it to them.  The speakers work, but now this problem.  Also, I had a photo slideshow on my desk and now as a watch and everytime I try to change it to play the slideshow, it bings and changes back to a photo.   I tried to reboot several times.  Can anyone help?

    Run your anti-virus software, then download and run Malwarebytes Anti-malware program. Delete everything they find.

    Re-post if they find something, but the problem comes back.

    See you soon,.

    Jerry

  • scan of the index systematic range

    Hello

    I read about the differences between the systematic index scan range, single scan, skip scan.

    According to the docs, to how the CBO Evaluates in-list of iterators, http://docs.oracle.com/cd/B10500_01/server.920/a96533/opt_ops.htm

    , I can see that

    "The IN -list iterator is used when a query contains a IN clause with values." The execution plan is the same which would result for a statement of equality clause instead of IN with the exception of an extra step. This step occurs when the IN -list iterator feeds section of equality with the unique values of the IN -list. »

    Of course, the doc is Oracle9i Database. (I do not find it in the docs of 11 g)

    And the example 2-1 list iterators initial statement, shows that is used in the INDEX RANGE SCAN.


    On my Oracle 11 GR 2 database, if I issue a statement similar to the example of the doc, so: select * from employees where employee_id in (7076, 7009, 7902), I see that it uses a SINGLE SCAN


    On Oracle Performance Tuning: the Index access methods: Oracle Tuning Tip #11: Unique Index Scan , I read that

    If Oracle should follow the Index Unique Scan, and then in SQL, equality operator (=) must be used. If any operator is used in other than op_Equality, then Oracle cannot impose this Unique Index Scan.

    (and I think this sentence is somewhere in the docs also).

    Thus, when using predicates in the list, why in my case Oracle used the unique scan on primary key column index? Because it wasn't a level playing field.

    Thank you.

    It is Internet... find us a lot of information a lot but don't know who to trust.

    Exactly! It is thought, you should ALWAYS have in the back of your mind when you visit ANY site (no matter the author), read a book or document, listen to no matter WHAT presentation or read responses from forum (that's me included).

    All sources of information can and will be errors, omissions and inaccuracies. An example which is used to illustrate a point can involve/suggest that it applies to the related points as well. It's just not possible to cover everything.

    Your post doc 9i is a good example. The earliest records (even 7.3 always available online docs) often have a LOT of better explanations and examples of basic concepts. One of the reasons is that there were not nearly that many advanced concepts that explaining necessary; they did not exist.

    michaelrozar17 just posted a link to a 12 c doc to refute my statement that the article you used was bad. No problem. Maybe this doc has been published because of these lines:

    The database performs a unique sweep when the following conditions apply:

    • A query predicate refers to all columns in a unique index using an equality operator key, such as WHERE prod_id=10 .
    • A SQL statement contains a predicate of equality on a column referenced in an index created with the CREATE UNIQUE INDEX statement.

    The authors mean that a single scan is ONLY performed for these conditions? We do not know. There could be several reasons that an INLIST ITERATOR has not been included in this list:

    1. a LIST is NOT for this use case (what michaelrozar might suggest)

    2. the authors were not aware that the CBO may also consider a unique analysis for a predicate INLIST

    3. the authors WERE aware but forgot to include INLIST in the document

    4. the authors were simply provide the conditions most common where a single sweep would be considered

    We have no way of knowing what was the real reason. This does not mean that the document is not reliable.

    In the other topic, I posted on the analysis of hard steps, site of BURLESON, and Jonathan contradicted me. If neither Burleson isn't reliable, do not know which author have sufficient credibility... of course, the two Burleson and Jonathan can say anything, it's true I can say anything, of course.

    If site X is false, site is fake, Z site is fake... all people should read the documentation only and not other sites?

    This is the BEST statement of reality to find the info I've seen displayed.

    No matter who is the author, and what credibility that they could rely on the spent items you should ALWAYS keep these statements you comes to mind.

    This means you need to do ' trust and verify. " You of 'trust', and then you "checked" and now have a conflict between WORDS and REALITY.

    On those which is correct. If your reality is correct, the documentation is wrong. Ok. If your reality is wrong, then you know why.

    Except that nobody has posted ANY REALITY that shows that your reality is wrong. IMHO, the reason for this is because the CBO probably MUCH, done a LOT of things that are not documented and that are never explored because there is never no reason to spend time exploring other than of curiosity.

    You have not presented ANY reason to think that you are really concerned that a single scan is used.

    Back to your original question:

    Thus, when using predicates in the list, why in my case Oracle used the unique scan on primary key column index? Because it wasn't a level playing field.

    1. why not use a single sweep?

    2. what you want Oracle to use instead? A full table scan? A scan of the index systematic range? An index skip scan? A Full Scan index? An analysis of index full?

    A full table scan?  For three key values? When there is a unique index? I hope not.

    A scan of the index systematic range? Look a the doc 12 c provided for those other types of indexes

    How the Index range scans work

    In general, the process is as follows:

    1. Read the root block.
    2. Read the bundle branch block.
    3. Replacing the following steps until all data is retrieved:
      1. Read a block of sheets to get a rowid.

      2. Read a block to retrieve a table row.

    . . .
    For example, to analyze the index, the database moves backward or forward through the pads of sheets. For example, an analysis of identifications between 20 and 40 locates the first sheet block that has the lowest value of key that is 20 or more. The analysis produced horizontally through the linked list nodes until it finds a value greater than 40 and then stops.

    If that '20' was the FIRST index value and the '40' was the LAST one who reads ALL of the terminal nodes. That doesn't look good for me.

    How to index full scans of work

    The database reads the root block and then sailed on the side of the index (right or left hand if do a descending full scan) until it reaches a block of sheets. The database then reads down the index, one block at a time, in a sorted order. The analysis uses single e/s rather than I/O diluvium.

    Which is about as the last example is not?

    How to index Fast Full Scans work

    The database uses diluvium I/O to read the root block and all the blocks of leaf and branch. Databases don't know branch blocks and the root and reads the index on blocks of leaves entries.

    Seems not much better than the last one for your use case.

    Skip index scans

    An index skip scan occurs when the first column of a composite index is "skipped" or not specified in the query.

    . . .

    How Index Skip scan work

    An index skip scan logically divides a composite index in smaller subindex. The number of distinct values in the main columns of the index determines the number of logical subindex. The more the number, the less logical subindex, the optimizer should create, and becomes the most effective analysis. The scan reads each logical index separately and "jumps" index blocks that do not meet the condition of filter on the column no leader.

    Which does not apply to your use cases; you do not have a composite index, and there is nothing to jump. If Oracle were to 'jump' between the values of the list in it would be still reads these blocks 'inbetween' and them to jump.

    Which brings back us to the using a single scan, one at a time, for each of the values in the list in. The root index block will be in the cache after the first value lies, so it only needs to be read once. After that just Oracle detects that the entry of only ONE necessary index. Sounds better than any other variants for me if you are only dealing with a small number of values in the IN clause.

  • Using the index to extract data without filter predicate

    Hello

    does anyone have an explanation for the following scenario:

    I have a table T1 with an OID_IX index on column (object_id) - the table is a DEC dba_objects just to fill it with data.
    There are no other current index. The table and index are analysed.

    When I run the following query, the table is available in FULL (without using the index)

    SELECT OBJECT_ID FROM T1;

    SQL > select object_id from t1;

    485984 selected lines.

    Elapsed time: 00:00:01.76

    Execution plan
    ----------------------------------------------------------
    Hash value of plan: 3617692013

    --------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
    --------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | 485K | 2372K | 1528 (1) | 00:00:19 |
    | 1. TABLE ACCESS FULL | T1 | 485K | 2372K | 1528 (1) | 00:00:19 |
    --------------------------------------------------------------------------


    Statistics
    ----------------------------------------------------------
    1 recursive calls
    0 db block Gets
    7396 gets coherent
    0 physical reads
    0 redo size
    2887158 bytes sent via SQL * Net to client
    5684 bytes received via SQL * Net from client
    487 SQL * Net back and forth to and from the client
    0 sorts (memory)
    0 sorts (disk)
    485984 rows processed



    But if I add a predicate (even if it is useless in this case) the index is taken and that the query runs faster:



    JDBC@toekb > select object_id from t1 where object_id. = - 999;

    485960 selected lines.

    Elapsed time: 00:00:01.40

    Execution plan
    ----------------------------------------------------------
    Hash value of plan: 3555700789

    -------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
    -------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | 485K | 2372K | 242 (3) | 00:00:03 |
    |* 1 | FULL RESTRICTED INDEX SCAN FAST | OID_IX | 485K | 2372K | 242 (3) | 00:00:03 |
    -------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    1 Filter ("OBJECT_ID" <>-(999))


    Statistics
    ----------------------------------------------------------
    1 recursive calls
    0 db block Gets
    1571 gets coherent
    0 physical reads
    0 redo size
    2766124 bytes sent via SQL * Net to client
    5684 bytes received via SQL * Net from client
    487 SQL * Net back and forth to and from the client
    0 sorts (memory)
    0 sorts (disk)
    485960 rows processed


    Here is my setup:

    SQLsql-
    drop table t1 purge;
    create table t1 tablespace users in select * from dba_objects;
    Insert into t1 (select * from t1);
    commit;
    Insert into t1 (select * from t1);
    commit;
    Insert into t1 (select * from t1);
    commit;
    create index oid_ix on t1 (object_id) tablespace users;
    exec dbms_stats.gather_table_stats (null, 't1', cascade = > true, estimate_percent = > 100);
    SQLsql-

    In my case, the Table and the Index looks like this way:

    JDBC@toekb > select table_name, NUM_ROWS, BLOCKS, AVG_SPACE from user_tables;

    TABLE_NAME, NUM_ROWS BLOCKS AVG_SPACE
    =======================================
    485984 6944 T1 0

    Elapsed time: 00:00:00.11
    JDBC@toekb > select INDEX_NAME, BLEVEL, LEAF_BLOCKS, DISTINCT_KEYS, NUM_ROWS user_indexes.

    INDEX_NAME BLEVEL LEAF_BLOCKS DISTINCT_KEYS NUM_ROWS
    ===================================================
    2 1074 60745 485960 OID_IX

    Elapsed time: 00:00:00.07

    The table contains 7 times more than the index blocks!


    any answer welcome

    Best regards

    Published by: guenterp on August 12, 2010 14:44

    The column is not defined as NOT NULL, then there may be values that are not in the index (because the index does not include null values). The useless predicate implies NOT NULL, then the index may be used.

  • How to use the commands on the cmd prompt witout using a string like 'netstat' but I need output

    How use the commands on the cmd prompt witout using a string like netstat but I need output
    example: C:\ > netstat-an... will give its results
    But if the keyword netstat is blocked...
    I want to use the command netstat another way... can I convert it to binary, and then I can run or something else
    Please answer my questin

    Netstat is simply a file program located in the folder C:\Windows\System32.   It appears as "netstat.exe.  If you rename (or copy / paste / rename) to "abc.exe" then you can run it using 'abc' instead of 'netstat '.

    HTH,
    JW

  • Can I install my creative cloud on the second computer? I would also like to use it on my macbook, imac not only?

    Can I install my creative cloud on the second computer? I would also like to use it on my macbook, imac not only?

    And how to proceed?

    Help!

    use the installation cs6 files and your cs6 serial number:

    Available downloadable Setup files:

    Download and installation help links Adobe

    Help download and installation to Prodesigntools links can be found on the most linked pages.  They are essential; especially steps 1, 2 and 3.  If you click on a link that does not have these listed steps, open a second window by using the link to Lightroom 3 to see these "important Instructions".

  • If I buy only Flash Professional, will I be able to use older versions like CC 2014 instead of the latest version (CC 2015)?

    Hello world

    I want to buy Flash Professional and I have a mac with OS X 10.8 on it.

    If I wanted to buy a subscription to Flash, it says that I get the latest version of Flash, what is Flash Professional CC 2015.

    For Flash Professional CC 2015 you need OS X 1.9 or more, but I don't want to upgrade my computer because I use Logic Pro 9 that does not work with OS X 1.9.

    So my question is:

    "If I buy only Flash Professional, will I be able to use older versions like CC 2014 instead of the latest version (CC 2015)?"

    I hope someone can help me, thanks!

    Yes, you can use flash pro cs6, cc, cc 2014, cc 2015 and probably more in the future.

  • I just downloaded Creative Suite 6 on my new MacBook and not only the interface seems a bit different but I noticed that the oil paint filter is not available.  I used the same discs on my office iMac and the filter still works there.

    I just downloaded Creative Suite 6 on my new MacBook and not only the interface seems a bit different but I noticed that the oil paint filter is not available.  I used the same discs on my office iMac and the filter still works there.  I use it often and would appreciate any help to recover!

    Please download and install Photoshop CS6 from the following link: download Creative Suite 6 applications

  • Facebook like button does not work, I used the widget of muse and created the facebook code. Anyone know how to make this work?

    Facebook like button does not work, I used the widget of muse and created the facebook code. Anyone know how to make this work?

    Hi connally25,

    Here is a link to a video tutorial on how to add a Facebook button, please check if you have followed the same steps to add the video.

    http://TV.Adobe.com/watch/learn-Adobe-Muse-CC/adding-a-Facebook-like-button/

    If you followed the steps correctly and the button still does not; Here is a link to a forum thread which may help to solve the problem:

    Facebook follow Widget does not

    Concerning

    Sonam

  • Display performance of resources by using the index of area XDBHI_IDX

    Hi all

    We have an application XMLDB home grown to make the validation of diagram against incoming messages. Enforcement issues several queries like below. I know, it analyzes the hard, which is very bad, but it's not where the real problem is at the moment. The problem is with the index of XDBHI_IDX field against xdb resource table $. We use a very specific way of results in the rows returned 0 or 1, but as you can see that the domain index has an intermediate result of 48041 lines, so the index is not effective here. Statistics are up to date, the index has been rebuild. Does anyone know what we can do with the index of the field to do what he must do: identify an xml document in this way?
    SELECT 0 
    FROM
     resource_view WHERE any_path=
      '/home/app/incoming/ARCH_IN/2012/01/592174'
    
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        2      0.02       0.02          0       1041          0           0
    Execute      2      0.00       0.00          0          0          0           0
    Fetch        2     81.26      85.43          0     202556     576158           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        6     81.28      85.45          0     203597     576158           0
    
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 67  (app)   (recursive depth: 3)
    
    Rows     Row Source Operation
    -------  ---------------------------------------------------
          0  TABLE ACCESS BY INDEX ROWID XDB$RESOURCE (cr=341531 pr=0 pw=0 time=60883725 us)
      48041   DOMAIN INDEX  XDBHI_IDX (cr=311030 pr=0 pw=0 time=1548774 us)
    Kind regards
    Rob.

    PS: The database version is 10.2.0.3.0

    Hi Rob,

    See EQUALS_PATH (and UNDER_PATH) conditions: http://docs.oracle.com/cd/B19306_01/server.102/b14200/conditions010.htm#i1051094

    SQL> select *
      2  from resource_view v
      3  where equals_path(v.res, '/office/excel/docs') = 1
      4  ;
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 3007404872
    
    --------------------------------------------------------------------------------------------
    | Id  | Operation                   | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT            |              |    81 | 17172 |    32   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| XDB$RESOURCE |    81 | 17172 |    32   (0)| 00:00:01 |
    |*  2 |   DOMAIN INDEX              | XDBHI_IDX    |       |       |            |          |
    --------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - access("XDB"."EQUALS_PATH"(SYS_MAKEXML('8758D485E6004793E034080020B242C6',734
                  ,"XMLEXTRA","XMLDATA"),'/office/excel/docs',8888)=1)
    
  • I'm about to upgrade premium creative design cs4 for I mac 10.11.2. can I still use it? If it's not like I'm retired and I have only some minimum number of works during the year, I can upgrde at a regular bundel and to add a tax when I get to work, and/or

    I'm about to upgrade premium creative design cs4 for I mac 10.11.2. can I still use it? If it is not that I am retired and I have only some minimum number of works during the year, I can upgrde at a regular bundel and to add a tax when I get to work, and/or monthly pay depending on my work schedule?

    Move the discussion to the download, installation, commissioning.

    Please check the terms of System. Adobe Creative Suite 4, Point products. You can upgrade to the App only and add more applications each time as needed. Please check: pricing and membership creative cloud plans | Adobe Creative Cloud for more details on the plans and prices.

    I hope this helps.

  • LabVIEW can perform the wavelet coherence?

    Hello, thanks in advance for your time and advice.

    I am very interested in the analysis by Wavelet coherence on some data that I collected during my PhD thesis. In short, I would like to see consistency between the variable signals based on time and frequency. I understand that Labview is capable of performing FOIA using the short FFT and Wigner-Ville analysis, but I'm leaning more towards contemporary technique to determine the consistency of the wavelet spectrum.

    Toolkit for LabVIEW Wavelet is more than enough to perform a continuous Wavelet on my data separately, but is that what someone had success with making complex mathematics on the (output from the wavelet vi) Wavelet coefficients to produce time-FREQ spectrum cross - Wavelet and Wavelet coherence?

    Thank you once again!

    In fact, if you use the MATLAB Script node, which is separated from the MathScript RT Module, he actually called MATLAB of LabVIEW software using ActiveX.  So, I think that everything you use MATLAB Toolbox should work.

    See http://zone.ni.com/reference/en-XX/help/371361H-01/gmath/matlab_script_node/

    Good luck and keep me posted!

  • Help: Configure the simple test sequence, operator selects particular test connects to the part of the teststand sequence file and then performs the test

    Hello

    I am very new to TestStand, please see the question below and give advice.

    I want to set up a simple test sequence.

    I want a message to popup on the screen that asks the operator what unit of 6 units (maximum 10) to test (i.e. There is say box of 6 to 10 s to select from).

    Then the sequence goes to the specific part of the sequence and performs the test on a unit that either has been selected.

    What is the best way to do it?

    I use pop-up message windows to do this? and if so what should I connect to the correct part of the sequence file?

    Pop-up message windows allow only 6 options to select from?

    Thank you

    Hello

    You can do this by using the method of message popup. You can ask the user what unit want to run message by inserting in the expression of the message in the message popup step parameters. Something like below

    "Enter the number of execution unit.

    1 Unit1

    2 unit 2

    .......

    10 Unit 10 "

    then check the 'Enable response text box"tab is different from the stage. When the user enters the unit number you can get the value entered by the user by inserting the below statement post expression of message popup step parameters

    Locals.String = Step.Result.Response

    Note: The string is a local variable to be set.

    Convert string to number and send that output to pass the expression you can use a sequence of call step to call the sequence according to which must be performed. (I hope your each unit will file separate sequence)

    I hope that this solves your problem. If you do not understand please let me know so that I can put a small example and send it to.

    See you soon,.

    Krishna

  • Associate an e-mail program to perform the desired task

    I get this error message when I try to click on a link to another part of the article

    l

    I have aol and Hotmail e-mail services.

    I tried for weeks repair what can help you please?

    Hello

    Thanks for posting your query in Microsoft Community Forum.

    1. You can access your e-mail by using Internet Explorer?
    2. You use a client like Windows Live mail or Microsoft Office Outlook e-mail program?
    3. When you receive the error message exactly?

    This error is received when you try to perform a function without going through the required software, allowing a customer to e-mail. AOL or Hotmail address that they can be configured using an e-mail client program.

    If you have an e-mail client installed on your system, you can set this program as default to avoid this error. See the section: set your default programs in the following link:

    Change the programs that Windows uses by default

    Also, I suggest you post with the information required to provide you with better assistance.

  • ScriptUI Palette with button to perform the function

    Hey Hey. Ho ho. I have a question for you guys. Hey Hey. Ho ho.

    So I'm writing a script to automatically replace art existing in a file with the art of my network (specifically, necklaces. we work that says "made in usa" but we moved production overseas, then update the country of origin.) I have fixed all our model files, new orders are set up correctly, but we have tens of thousands of old orders with bad collars in the files. so far we have been manually accessing the network, opens a file that contains the correct collars and paste in the required file. A PITA serious, especially when you do 20 - 30 times per day.

    So, naturally, I started to think about how to automate it. For most files, this process is really simple and straightforward because the files that we use has set up a system of good address. However, orders more alumni dating back to before the address system, so the script in some cases, to do a break in order to let the artist select USA collars so that the script can move to a new layer and hide.

    To remedy this, I decided to use a scriptUI as an alert box pallet (if the artist still has access to the user interface, so they can select the necessary art, then click a button to perform a function and complete the task. The button in the palette works to perform the desired function, but then I get an error in ESTK that "there is no document. What I'm doing wrong here? Everything works until the promptToSelectCollars() function; The error occurs at line 291 trying to use docRef.layers.add (); I added the line 290 after the first time I got the error to see if docRef just need to be redefined, but that did not help.

    I guess I can just force the artist to select any work necessary before running the script, but I like it to be as smooth as possible and requires a minimum of steps pre...

    Here's the current code (must still be completed, I know)... Any thoughts?

    //Add DR Collars
    
    
    function container()
    {
    
    
        /////////////////////
        ///Logic Container///
        /////////////////////
    
    
        function whatStyleDialog()
        {
            // var docRef = app.activeDocument;
    
    
            var sports = ["SLOW_SS", "SLOWW_SS", "SLOWY_SS", "FAST_SL", "FAST_RB", "FAST_FB_SL", "FAST_FB_SS", //
            "FAST_2B_SS", "BASE_FB_SL", "BASE_FB_Y_SL", "BASE_FB_SS","BASE_FB_Y_SS", "BASE_2B_SS", "BASE_2B_Y_SS"];
    
    
            
    
    
            var wS = new Window("dialog", "What Collars Do You Need?");
    
    
            var inputGroup = wS.add("group");
                inputGroup.orientation = "column";
                var sportsGroup = inputGroup.add("group");
                    sportsGroup.add("statictext", undefined, "Choose Sport");
    
    
                    //populate sports dropdown list
                    var sportsList = sportsGroup.add("dropdownlist", undefined, sports);
                    sportsList.selection = 0;
    
    
                var styleGroup = inputGroup.add("group");
    
    
                    styleGroup.add("statictext", undefined, "Enter Style Number:");
    
    
                    //input text box for style number
                    var styleInput = styleGroup.add("edittext", undefined, "000");
    
    
            var buttonGroup = wS.add("group");
                var okButton = buttonGroup.add("button", undefined, "OK");
                var cancelButton = buttonGroup.add("button", undefined, "Cancel");
    
    
    
    
            if(wS.show() == 1)
            {
                var results = "";
                results = "FD_" + sportsList.selection.text + "_";
                results = results + styleInput.text + ".ait";
                return results;
            }
            else
            {
                return null;
            }
        }
    
    
        function getStyle(styles)
        {
            if(styles.length>1)
            {
                var result;
                var gS = new Window("dialog","Which Garment?");
                    var titleText = gS.add("statictext", undefined, "Which Garment Do You Need Collars For?");
                    var buttons = styles;
                    var buttonGroup = gS.add("group");
                    buttonGroup.orientation = "column";
                        for(var s=0;s<styles.length;s++)
                        {
                            addButton(s, styles[s]);
                        }
    
    
                    function addButton(num, style)
                    {
                        buttons[num] = buttonGroup.add("button", undefined, style);
                        buttons[num].onClick = function()
                        {
                            result = style + ".ait";
                            gS.close();
                        }
                    }
                gS.show();
                // alert(result)
                return result;
    
    
            }
            else
            {
                result = styles[0] + ".ait";
                return result;
            }
        }
        function whatGarment()
        {
            var result;
            var jerseyList = [];
    
    
            for(a=0;a<layers.length;a++)
            {
                if(layers[a].name.indexOf("FD")>-1)
                {
                    jerseyList.push(layers[a].name);
                }
            }
    
    
            //This prepress is not on a template
            if(jerseyList.length==0)
            {
                result = whatStyleDialog();
                return result;
            }
    
    
            else
            {
                result = getStyle(jerseyList);
            }
    
    
            return result;
        }
    
    
        function findCAD(path, garment)
        {
            var loc = new Folder(path);
            var theFile = new File(loc + "/" +  garment);
            return theFile;
        }
    
    
        function copyCollars(theCAD,coords)
        {
            var collars = [];
            var collarSource = open(theCAD);
            var sourceLayer = collarSource.layers[0].layers["Prepress"];
            var curLay;
            var curGroup;
    
    
            sourceLayer.visible = true;
    
    
            collarSource.selection = null;
    
    
            for (var a=0; a< sourceLayer.layers.length;a++)
            {
                curLay = sourceLayer.layers[a];
                for(var b=0;b<curLay.groupItems.length;b++)
                {
                    curGroup = curLay.groupItems[b];
                    if(curGroup.name.indexOf("Collar")>-1)
                    {
                        curGroup.selected = true;
                    }   
                }
                
            }
    
    
            app.executeMenuCommand("copy");
            docRef.activate();
            app.executeMenuCommand("paste");
    
    
            for(var a=0;a<docRef.selection.length;a++)
            {
                var curGroup = docRef.selection[a];
                var curName = curGroup.name.substring(0,curGroup.name.indexOf(" "));
                curGroup.left = coords[curName][0];
                curGroup.top = coords[curName][1];
            }
    
    
            
    
    
            // collarSource.close(SaveOptions.DONOTSAVECHANGES);
            
        }
    
    
        function addCollarsToCorrectLayer(garment,coords)
        {
            try
            {
                var theLayer = docRef.layers[garment.substring(0,garment.indexOf(".ait"))].layers["Prepress"];
                theLayer.visible = true;
                // alert("theLayer = " + theLayer);
                // alert(docRef.selection.length);
                for(var a=docRef.selection.length-1;a>-1;a--)
                {
                    var thisCollar = docRef.selection[a];
                    var targetLayer = theLayer.layers[thisCollar.name.substring(0, thisCollar.name.indexOf(" "))];
                    thisCollar.moveToBeginning(targetLayer);
                }
    
    
    
    
            }
            catch(e)
            {
                try
                {
                    if(docRef.selection[0].layer != "[Layer Artwork]")
                    {
                        var theLayer = docRef.layers["Artwork"];
                        theLayer.locked = false;
                        theLayer.visible = true;
                        for(var a=docRef.selection.length-1;a>-1;a--)
                        {
                            docRef.selection[a].moveToBeginning(theLayer);
                        }
                    }
                }
                catch(e)
                {
                    alert("something went wrong")
                }
            }
            if(theLayer.name == "Prepress")
            {
                var drCollarLabel = docRef.layers[0].layers["Mockup"].textFrames.add()
            }
            else
            {
                var drCollarLabel = theLayer.textFrames.add();
            }
            drCollarLabel.contents = "DR Collars";
            drCollarLabel.left = coords["Label"][0];
            drCollarLabel.top = coords["Label"][1];
            drCollarLabel.textRange.characterAttributes.size = 36;
        }
    
    
        function promptToSelectCollars()
        {
            alert("running prompt to select");
            var selCol = new Window("palette");
                var text = selCol.add("statictext",undefined, "Select the USA Collars and click OK");
                var button = selCol.add("button", undefined, "OK");
                button.onClick = function()
                {
                    selCol.close();
                    moveCollarsToUSALayer(false);
                }
            selCol.show();
        }
    
    
        function moveCollarsToUSALayer(template,garmentLayer)
        {
            if(template)
            {
                var usaLayer = garmentLayer.layers.add();
                usaLayer.name = "USA Collars";
                var theLayer = garmentLayer.layers["Prepress"];
    
    
                for(var a=0;a<theLayer.layers.length;a++)
                {
                    var curSize = theLayer.layers[a].name;
                    var curLay = theLayer.layers[a];
                    curLay.groupItems[curSize + " Collar"].moveToBeginning(usaLayer);
                }
    
    
                continueScript();
            }
            else
            {
                // docRef = app.activeDocument;
                var usaLayer = docRef.layers.add();
                usaLayer.name = "USA Collars";
    
    
                for(var a=0;a<docRef.selection.length;a++)
                {
                    var curCollar = docRef.selection[a];
                    curCollar.moveToBeginning(usaLayer);
                }
                continueScript();
            }
            
    
    
    
    
        }
    
    
        function continueScript()
        {
            var theCAD = findCAD(garmentInfo[garmentCode]["path"], garment);
    
    
            copyCollars(theCAD, garmentInfo[garmentCode]["coords"]);
    
    
            addCollarsToCorrectLayer(garment,garmentInfo[garmentCode]["coords"]);
        }
    
    
        /////////////////////
        ///Logic Container///
        /////////////////////
    
    
        var docRef = app.activeDocument;
        var layers = docRef.layers;
        
    
    
        var garmentInfo = 
        {
            "FD_SLOW_SS" : 
            {
                "path": "/Volumes/Customization/Library/cads/prepress/FD_SLOW_SS/ConvertedTemplates/FD_SLOW_SS",
                "coords" : 
                {
                    "XS" : [-946.67,622.35],
                    "S" : [-948.92,362.97],
                    "M" : [-951.17,96.54],
                    "L" : [-953.42,-177.48],
                    "XL" : [-955.22,-458.71],
                    "2XL" : [-957.92,-747.11],
                    "3XL" : [-960.17,-1042.73],
                    "4XL" : [-962.42,-1345.42],
                    "5XL" : [-964.67,-1654.82],
                    "Label" : [-949.1,708.39]
                }
            },      
            "FD_SLOWW_SS" : "/Volumes/Customization/Library/cads/prepress/FD_SLOW_SS/ConvertedTemplates/FD_SLOWW_SS",
    
    
            "FD_SLOWY_SS" : "/Volumes/Customization/Library/cads/prepress/FD_SLOW_SS/ConvertedTemplates/FD_SLOWY_SS",
            "FD_FAST_RB" : "/Volumes/Customization/Library/cads/prepress/FD_FAST_RB/Converted_Templates/",
            "FD_FAST_SL" : "/Volumes/Customization/Library/cads/prepress/FD_FAST_SL/Converted_Templates/",
            "FD_FAST_FB_SL" : "/Volumes/Customization/Library/cads/prepress/FD_FAST_FB_SL/Converted_Templates/",
            "FD_FAST_FB_SS" : "/Volumes/Customization/Library/cads/prepress/FD_FAST_FB_SS/Converted_Templates/",
            "FD_FAST_2B_SS" : {
                "path": "/Volumes/Customization/Library/cads/prepress/FD_FAST_2B_W_SS/Converted_Templates/",
                "coords" : 
                {
                    "XXS" : [-1011.89,455.31],
                    "XS" : [-1015.33,206.79],
                    "S" : [-1018.88,-60.25],
                    "M" : [-1022.12,-323.7],
                    "L" : [-1025.7,-595.67],
                    "XL" : [-1028.83,-879.72],
                    "2XL" : [-1032.38,-1168.08],
                    "3XL" : [-1035.83,-1457.79],
                    "Label" : [-949.1,708.39]
                }
            },
            "FD_BASE_FB_SL" : "/Volumes/Customization/Library/cads/prepress/FD_BASE_FB_SL/Converted_Templates/",
            "FD_BASE_FB_Y_SL" : "/Volumes/Customization/Library/cads/prepress/FD_BASE_FB_Y_SL/Converted_Templates/",
            "FD_BASE_FB_SS" : "/Volumes/Customization/Library/cads/prepress/FD_BASE_FB_SS/Converted_Templates/",
            "FD_BASE_FB_Y_SS" : "/Volumes/Customization/Library/cads/prepress/FD_BASE_FB_Y_SS/Converted_Templates/",
            "FD_BASE_2B_SS" : "/Volumes/Customization/Library/cads/prepress/FD_BASE_2B_SS/Converted_Templates/",
            "FD_BASE_2B_Y_SS" : "/Volumes/Customization/Library/cads/prepress/FD_BASE_2B_Y_SS/Converted_Templates/",
        }
    
    
        var garment = whatGarment(); 
    
    
        var garmentCode = garment.substring(0, garment.indexOf("_0"));
    
    
        var styleNum = garment.substring(garment.indexOf("_0"), garment.length);
    
    
        try
        {
            docRef.layers[garment.substring(0,garment.indexOf(".ait"))].layers["Prepress"].visible = true;
            moveCollarsToUSALayer(true,docRef.layers[garment.substring(0,garment.indexOf(".ait"))]);
    
    
        }
        catch(e)
        {
            //no discernable layer structure
            alert("using catch");
            promptToSelectCollars();
        }
    
    
        
    
    
        
    
    
        
    
    
        // alert("Results:\n" + "Sport: " + garment[0] + "\nCut: " + garment[1] + "\nStyle Number: " + garment[2]);
        // alert("Results:\n" + garment);
    
    
    
    
        
    }
    container();
    

    You do not have something wrong, sort of, pallets do not 'normally' work as do dialog windows, you must use BridgeTalk to bind your palette to Illustrator, do a quick search, a topical subject, there are many samples.

Maybe you are looking for