SQL between clause & index question

I currently have the below CTAS that uses between clause to identify the date range from the parameter table and then query a history table on a different database. The history table has index in the acct_date column. The below SQL is slow and takes a long time.
create table temp1 as
select acct_date,cust_ord_1,fin_fclty_2,cust_ord_ship_3,
cust_ship_4,fin_item_5,sls_q,sls_tran_a
from pgt.pg_orders@jtu where acct_date between
(select value from pgm_parameters where parameter='wk_minday') and
(select value from pgm_parameters where parameter='wk_maxday');
Please advise of any changes that I can do to tune the script and make it execute faster. Thanks in advance.

See:
[url http://forums.oracle.com/forums/thread.jspa?threadID=863295] How to post a SQL tuning request
[url http://forums.oracle.com/forums/thread.jspa?messageID=1812597] When your query takes too long
But you might want also want to read this:
http://jonathanlewis.wordpress.com/2008/12/05/distributed-dml/

Similar Messages

  • Difference between Create Index without and with Parallel Clause

    Hi all.
    I want to know the difference between Create Index with Parallel clause and Create Index without Parallel clause.
    Any documentation.
    Thanks,
    Hassan

    Sure?
    dimitri@VDB> create table t parallel 3 as select * from all_objects;
    Table created.
    dimitri@VDB> set autotrace traceonly
    dimitri@VDB> select * from t;
    40934 rows selected.
    Execution Plan
    Plan hash value: 3050126167
    | Id  | Operation            | Name     | Rows  | Bytes | Cost (%CPU)| Time     |    TQ  |IN-OUT| PQ Distrib |
    |   0 | SELECT STATEMENT     |          | 40601 |  5075K|    50   (0)| 00:00:01 |        |      |            |
    |   1 |  PX COORDINATOR      |          |       |       |            |          |        |      |            |
    |   2 |   PX SEND QC (RANDOM)| :TQ10000 | 40601 |  5075K|    50   (0)| 00:00:01 |  Q1,00 | P->S | QC (RAND)  |
    |   3 |    PX BLOCK ITERATOR |          | 40601 |  5075K|    50   (0)| 00:00:01 |  Q1,00 | PCWC |            |
    |   4 |     TABLE ACCESS FULL| T        | 40601 |  5075K|    50   (0)| 00:00:01 |  Q1,00 | PCWP |            |
    --------------------------------------------------------------------------------------------------------------Looks like PQ to me.
    alter table t noparallel;
    Table altered.
    dimitri@VDB> select * from t;
    40934 rows selected.
    Execution Plan
    Plan hash value: 1601196873
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      | 40601 |  5075K|   135   (1)| 00:00:02 |
    |   1 |  TABLE ACCESS FULL| T    | 40601 |  5075K|   135   (1)| 00:00:02 |
    --------------------------------------------------------------------------Same if we use an Index:
    dimitri@VDB> create index t_idx on t(object_name) parallel 3;
    Index created.
    dimitri@VDB> select object_name from t;
    40934 rows selected.
    Execution Plan
    Plan hash value: 4278805225
    | Id  | Operation               | Name     | Rows  | Bytes | Cost (%CPU)| Time     |    TQ  |IN-OUT| PQ Distrib |
    |   0 | SELECT STATEMENT        |          | 40601 |   674K|    50   (0)| 00:00:01 |        |      |            |
    |   1 |  PX COORDINATOR         |          |       |       |            |          |        |      |            |
    |   2 |   PX SEND QC (RANDOM)   | :TQ10000 | 40601 |   674K|    50   (0)| 00:00:01 |  Q1,00 | P->S | QC (RAND)  |
    |   3 |    PX BLOCK ITERATOR    |          | 40601 |   674K|    50   (0)| 00:00:01 |  Q1,00 | PCWC |            |
    |   4 |     INDEX FAST FULL SCAN| T_IDX    | 40601 |   674K|    50   (0)| 00:00:01 |  Q1,00 | PCWP |            |
    -----------------------------------------------------------------------------------------------------------------Everything done on a single CPU (also only one core in the CPU) AMD Box.
    Dim

  • Perf tuning issue with a query involving between clause

    Hi all,
    I am getting issues with performance when I try to execute this query. Given below the query and it is going for a full table scan. I think the problem is with the between clause. But I dont know how to resolve this issue
    SELECT psm.member_id
    FROM pre_stg_member psm
    WHERE psm.map_tran_agn BETWEEN :start_transaction_agn and :end_transaction_agn
    and psm.partition_key = :p_partition_key;
    Having composite index on map_tran_agn and partition_key.
    Please help me in this regard.
    Thanks,
    Swami

    Please consider the following when you post a question.
    1. New features keep coming in every oracle version so please provide Your Oracle DB Version to get the best possible answer.
    You can use the following query and do a copy past of the output.
    select * from v$version 2. This forum has a very good Search Feature. Please use that before posting your question. Because for most of the questions
    that are asked the answer is already there.
    3. We dont know your DB structure or How your Data is. So you need to let us know. The best way would be to give some sample data like this.
    I have the following table called sales
    with sales
    as
          select 1 sales_id, 1 prod_id, 1001 inv_num, 120 qty from dual
          union all
          select 2 sales_id, 1 prod_id, 1002 inv_num, 25 qty from dual
    select *
      from sales 4. Rather than telling what you want in words its more easier when you give your expected output.
    For example in the above sales table, I want to know the total quantity and number of invoice for each product.
    The output should look like this
    Prod_id   sum_qty   count_inv
    1         145       2 5. When ever you get an error message post the entire error message. With the Error Number, The message and the Line number.
    6. Next thing is a very important thing to remember. Please post only well formatted code. Unformatted code is very hard to read.
    Your code format gets lost when you post it in the Oracle Forum. So in order to preserve it you need to
    use the {noformat}{noformat} tags.
    The usage of the tag is like this.
    <place your code here>\
    7. If you are posting a *Performance Related Question*. Please read
       {thread:id=501834} and {thread:id=863295}.
       Following those guide will be very helpful.
    8. Please keep in mind that this is a public forum. Here No question is URGENT.
       So use of words like *URGENT* or *ASAP* (As Soon As Possible) are considered to be rude.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Still problem with SQL Between... Help me GURUS!

    I've already posted this, but I will try to put it more simple:
    Imagine these Tables:
    Absentee Table
    ID_TRABALHADORES (Number PK) (Trabalhadores=Worker in english)
    DAT_INI_AUS (Date) - Initial date of absence
    DAT_FIM_AUS (Date) - End of Absence
    Justification Table
    ID_TRABALHADORES (Number PK)
    DAT_INI_JST (Date)
    DAT_FIM_JST (Date)
    Now imagine that an user (Thru a Oracle Form) inputs one absence from 2005/12/13 to 2005/12/29.
    Now the user must input the specified Justification for that absence. Suppose there's 2 Justifications for one SINGLE Absence.
    From 2005/12/13 to 2005/12/20 as justified as ilness and from 2005/12/21 to 2005/12/29 as Death of a relative.
    If I want to find out if someone forgot to fill in a justification, or if it's wrong justified (wrong dates, etc...), how can I work the SQL with Between? It doesn't work if an user puts 1 Absence to 2 Justifications, because it reports it as being an error, but it's not, because the period is correct. It works fine if an user puts the example above like this:
    Absentee Form:
    2005/12/13 to 2005/12/20 (Ilness)
    2005/12/21 to 2005/12/29 (Death of relative)
    Justific Form:
    2005/12/13 to 2005/12/20 - Ilness
    2005/12/21 to 2005/12/29 - Death of relative
    With this I don't catch it because it's not an error and the date periods are correct, but using this way:
    Absentee Form:
    2005/12/13 to 2005/12/29 (Ilness and Death of relative)
    Justific Form:
    2005/12/13 to 2005/12/20 - Ilness
    2005/12/21 to 2005/12/29 - Death of relative
    1 Absence to 2 Justific I catch it as error, but the period is also correct...
    There's any SQL script that can turn around this problem?
    PS- I don't want to use any sort of code in FORMS or PL/SQL

    If I understand the question correctly, you are trying to find out if the justification data matches the absence data or not. Also, if the user puts in two absences then there should be two justifications, right?
    Also, the date range of absence should match date range of justification.
    The two tables are linked by ID_TRABALHADORES column.
    One approach could be:
    Figure out if the number of absence records and justification records match or not:
    select ID_TRABALHADORES , count(*) from Absentee
    group by ID_TRABALHADORES
    MINUS
    select ID_TRABALHADORES , count(*) from justification
    group by ID_TRABALHADORES
    This will give a list of all those IDs where :
    1. There are more records in Absentee but fewer justifications, e.g. 2 date ranges but a single justification
    2. User forgot to enter a justification
    Now let's take it further ... I understand that you want to catch cases where the dates do not match for the IDs identified above.
    select id, min(dat_ini_aus), max(dat_fim_aus) from absentee group by id
    minus
    select id, min(dat_ini_aus), max(dat_fim_aus) from justification group by id
    If the date ranges match then the query above will eliminate further records as the date range identified by min/max would match.
    Anything that does not match could be due to missing records, bad dates etc.
    I think it will help if we can see more data samples and some more explanation of the problem you are trying to solve. A BETWEEN clause may not be needed here.
    Shakti
    http://www.impact-sol.com
    Developers of Guggi Oracle - Tool for DBAs and Developers

  • Help with SQL MODEL Clause

    I have the privilege of performing a very tedious task.
    We have some home grown regular expressions in our company. I now need to expand these regular expressions.
    Samples:
    a = 0-3
    b = Null, 0, 1
    Expression: Meaning
    1:5: 1,2,3,4,5
    1a: 10, 11, 12, 13
    1b: 1, 10, 11
    1[2,3]ab: 120, 1200, 1201, ....
    It get's even more inetersting because there is a possibility of 1[2,3]a.ab
    I have created two base queries to aid me in my quest. I am using the SQL MODEL clause to solve this problem. I pretty confident that I should be able to convert evrything into a range and the use one of the MODEL clause listed below.
    My only confusion is how do I INCREMENT dynamically. The INCREMENT seems to be a constant in both a FOR and ITERATE statement. I need to figure a way to increment with .01, .1, etc.
    Any help will be greatly appreciated.
    CODE:
    Reference:          http://www.sqlsnippets.com/en/topic-11663.html
    Objective:          Expand a range with ITERATE
    WITH t AS
    (SELECT '2:4' pt
    FROM DUAL
    UNION ALL
    SELECT '6:9' pt
    FROM DUAL)
    SELECT pt AS code_expression
    -- , KEY
    -- , min_key
    -- , max_key
    , m_1 AS code
    FROM t
    MODEL
    PARTITION BY (pt)
    DIMENSION BY ( 0 AS KEY )
    MEASURES (
                        0 AS m_1,
                        TO_NUMBER(SUBSTR(pt, 1, INSTR(pt, ':') - 1)) AS min_key,
                        TO_NUMBER(SUBSTR(pt, INSTR(pt, ':') + 1)) AS max_key               
    RULES
    -- UPSERT
    ITERATE (100000) UNTIL ( ITERATION_NUMBER = max_key[0] - min_key[0] )
    m_1[ITERATION_NUMBER] = min_key[0] + ITERATION_NUMBER
    ORDER BY pt, m_1
    Explanation:
    Line numbers are based on the assupmtion that "WITH t AS" starts at line 5.
    If you need detailed information regarding the MODEL clause please refer to
    the Refrence site stated above or read some documentation.
    Partition-
    Line 18:     PARTITION BY (pt)
                   This will make sure that each "KEY" will start at 0 for each value of pt.
    Dimension-
    Line 19:     DIMENSION BY ( 0 AS KEY )     
                   This is necessary for the refrences max_key[0], and min_key[0] to work.
    Measures-
    Line 21:      0 AS m_1
                   A space holder for new values.
    Line 22:     TO_NUMBER(SUBSTR(pt, 1, INSTR(pt, ':') - 1)) AS min_key
                   The result is '1' for '1:5'.
    Line 23:     TO_NUMBER(SUBSTR(pt, INSTR(pt, ':') + 1)) AS max_key                                        
                   The result is '5' for '1:5'.
    Rules-
    Line 26:     UPSERT
                   This makes it possible for new rows to be created.
    Line 27:     ITERATE (100000) UNTIL ( ITERATION_NUMBER = max_key[0] - min_key[0] )
                   This reads ITERATE 100000 times or UNTIL the ITERATION_NUMBER = max_key[0] - min_key[0]
                   which would be 4 for '1:5', but since the ITERATION_NUMBER starts at 0, whatever follows
                   is repaeted 5 times.
    Line 29:     m_1[ITERATION_NUMBER] = min_key[0] + ITERATION_NUMBER
                   m_1[ITERATION_NUMBER] means m_1[Value of Dimension KEY].
                   Thus for each row of KEY the m_1 is min_key[0] + ITERATION_NUMBER.
    Reference:          http://www.sqlsnippets.com/en/topic-11663.html
    Objective:          Expand a range using FOR
    WITH t AS
    (SELECT '2:4' pt
    FROM DUAL
    UNION ALL
    SELECT '6:9' pt
    FROM DUAL)
    , base AS
    SELECT pt AS code_expression
    , KEY AS code
    , min_key
    , max_key
         , my_increment
    , m_1
    FROM t
    MODEL
    PARTITION BY (pt)
    DIMENSION BY ( CAST(0 AS NUMBER) AS KEY )
    MEASURES (
                        CAST(NULL AS CHAR) AS m_1,
                        TO_NUMBER(SUBSTR(pt, 1, INSTR(pt, ':') - 1)) AS min_key,
                        TO_NUMBER(SUBSTR(pt, INSTR(pt, ':') + 1)) AS max_key,     
                        .1 AS my_increment     
    RULES
    -- UPSERT
              m_1[FOR KEY FROM min_key[0] TO max_key[0] INCREMENT 1] = 'Y'
    ORDER BY pt, KEY, m_1
    SELECT code_expression, code
    FROM base
    WHERE m_1 = 'Y'
    Explanation:
    Line numbers are based on the assupmtion that "WITH t AS" starts at line 5.
    If you need detailed information regarding the MODEL clause please refer to
    the Refrence site stated above or read some documentation.
    Partition-
    Line 21:     PARTITION BY (pt)
                   This will make sure that each "KEY" will start at 0 for each value of pt.
    Dimension-
    Line 22:     DIMENSION BY ( 0 AS KEY )     
                   This is necessary for the refrences max_key[0], and min_key[0] to work.
    Measures-
    Line 24:      CAST(NULL AS CHAR) AS m_1
                   A space holder for results.
    Line 25:     TO_NUMBER(SUBSTR(pt, 1, INSTR(pt, ':') - 1)) AS min_key
                   The result is '1' for '1:5'.
    Line 26:     TO_NUMBER(SUBSTR(pt, INSTR(pt, ':') + 1)) AS max_key                                        
                   The result is '5' for '1:5'.
    Line 27:     .1 AS my_increment     
                   The INCREMENT I would like to use.
    Rules-
    Line 30:     UPSERT
                   This makes it possible for new rows to be created.
                   However seems like it is not necessary.
    Line 32:     m_1[FOR KEY FROM min_key[0] TO max_key[0] INCREMENT 1] = 'Y'
                   Where the KE value is between min_key[0] and max_key[0] set the value of m_1 to 'Y'
    */

    Of course, you can accomplish the same thing without MODEL using an Integer Series Generator like this.
    create table t ( min_val number, max_val number, increment_size number );
    insert into t values ( 2, 3, 0.1 );
    insert into t values ( 1.02, 1.08, 0.02 );
    commit;
    create table integer_table as
      select rownum - 1 as n from all_objects where rownum <= 100 ;
    select
      min_val ,
      increment_size ,
      min_val + (increment_size * n) as val
    from t, integer_table
    where
      n between 0 and ((max_val - min_val)/increment_size)
    order by 3
       MIN_VAL INCREMENT_SIZE        VAL
          1.02            .02       1.02
          1.02            .02       1.04
          1.02            .02       1.06
          1.02            .02       1.08
             2             .1          2
             2             .1        2.1
             2             .1        2.2
             2             .1        2.3
             2             .1        2.4
             2             .1        2.5
             2             .1        2.6
             2             .1        2.7
             2             .1        2.8
             2             .1        2.9
             2             .1          3
    15 rows selected.--
    Joe Fuda
    http://www.sqlsnippets.com/

  • SQL IN clause with Bind parameter?

    Hi
    I have a simple task that hasn't been so simple to figure out. I want to allow a user to search for one or more comma-separated values in a simple JClient ADF app. Is there a way to use a SQL IN clause with a single bind variable? e.g. SELECT TITLE FROM CITATION WHERE ID IN (:0)
    When I pass a single value it works fine but a comma separated list doesn't.
    Thanks
    John

    Update: I wanted to combine the techniques found in two of Steve Muench's articles -
    1) Providing Default Values for View Object Bind Variables (so I could display an ADF-bound JPanel with defaults)
    http://radio.weblogs.com/0118231/stories/2004/10/07/providingDefaultValuesForViewObjectBindVariables.html
    2) Array of String Domain Example (so a user could enter one or more comma-separated values into a text box for DB searches)
    http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html
    I learned some helpful stuff about the framework but spent lots of time banging my head against the wall because the two examples wouldn't work when directly combined. To best understand this, be sure to study Steve's examples above.
    In example 1 Steve passes an array of objects (Object[] DEFAULT_VALUES) to the ViewObject's where clause using the setWhereClauseParams(Object[] values). However, in example 2 he creates an Oracle Array which contains an Oracle ArrayDescriptor, Connection, and array of values to pass to the "IN" bind variable. Also, example 1 allows for multiple bind vars to be included whereas example 2 allows for an array of data to be passed to a single bind var. Even though my code provides an array to a single bind var (per ex. 2) it should still allow for the passage of multiple bind vars with minimal code modification.
    Code from Steve's example 1 was copied into my EmpView ViewObject but certain modifications were necessary:
    1) Change the ViewObject's DEFAULT_VALUES from Object[] to String[].
    2) Modify the executeQueryForCollection() method in the ViewObject to call a function which will set the bind variables as Oracle Arrays (effectively converting the "params" data type from that of String[] to Oracle Array[])
    3) Create a setManagerID(String[]) method in the EmpView object and expose it to the client.
    (there are a number of others so it's best for you to go through the code and compare)
    I finally got it working so I'm attaching the code, however beware - I'm new to this so there may be other, better ways to go about it. Also, there are no framework bind vars so that section of code is never executed...it compiles but may fail at run time.
    In order for this to work I suggest you use JDev to re-create the EmpView and Panel1 objects. This will ensure that the necessary ADF framework components are generated. Once complete, then copy in the code provided.
    *File: EmpViewImpl.java
    *Created as Read-Only access view object with the
    *query:
    *select manager_id, last_name from hr.employees
    *where manager_id IN
    *(select * from TABLE(CAST(:0 as TABLE_OF_VARCHAR)))
    *order by manager_id
    package model;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    import oracle.jbo.domain.Array;
    import oracle.jbo.server.ViewObjectImpl;
    import oracle.sql.ArrayDescriptor;
    // --- File generated by Oracle ADF Business Components Design Time.
    // --- Custom code may be added to this class.
    // --- Warning: Do not modify method signatures of generated methods.
    public class EmpViewImpl extends ViewObjectImpl implements model.common.EmpView
    private ArrayDescriptor descriptor;
    private final static String[] DEFAULT_VALUES_STRING = new String[]{"100"};
    private final static int NUM_DEFAULT_VALUES = DEFAULT_VALUES_STRING.length;
    * This is the default constructor (do not remove)
    public EmpViewImpl()
    protected void executeQueryForCollection (Object qc, Object[] params, int numUserParams)
    Object pars[] = null;
    // Bind default variables only if none have been provided by the user
    if (numUserParams == 0)
    numUserParams = NUM_DEFAULT_VALUES;
    int numFwkSuppliedBindVals = (params != null) ? params.length : 0;
    if (numFwkSuppliedBindVals > 0)
    // Allocate a new Object[] array with enough room for both user- and framework-supplied vars
    Object[] newBinds = new Object[numFwkSuppliedBindVals + numUserParams];
    // Copy the framework-supplied bind variables into a new Object[] array
    // leaving enough slots at the beginning for the user-supplied vars
    System.arraycopy(params, 0, newBinds, numUserParams, numFwkSuppliedBindVals);
    // Now copy in the user-supplied vars to the beginning of the array
    System.arraycopy(DEFAULT_VALUES_STRING, 0, newBinds, 0, numUserParams);
    params = newBinds;
    } else
    params = DEFAULT_VALUES_STRING;
    // We have to call this method to convert the default values into the proper Oracle Array expected by the query.
    // If you set a debugger breakpoint at this line you can see that the "params" data type changes from String[] to Object[]
    setWhereClauseParamsToDefaultValues();
    // Now retrieve the params of the new data type
    params = this.getWhereClauseParams();
    super.executeQueryForCollection(qc, params, numUserParams);
    private void setWhereClauseParamsToDefaultValues()
    this.setManagerID(DEFAULT_VALUES_STRING);
    private Connection getCurrentConnection() throws SQLException
    // Create a bogus statement so that we can access our current connection
    // JBD note - Does this get run each time??
    PreparedStatement st = getDBTransaction().createPreparedStatement("commit", 1);
    Connection conn = st.getConnection();
    st.close();
    return conn;
    private synchronized void setupDescriptor(Connection conn) throws SQLException
    descriptor = new ArrayDescriptor("TABLE_OF_VARCHAR", conn);
    * setManagerID
    * Exposed to client to accept an array of values (presumably passed in by user-entry into text box
    * @param aryMan
    public void setManagerID(String[] aryMan)
    Array arr = null;
    try
    // Find the connection
    Connection conn = getCurrentConnection();
    //Create the ArrayDescriptor by looking for our custom data type in our connected DB
    if(descriptor == null)
    setupDescriptor(conn);
    // Create the Oracle Array by passing in the descriptor, connection, and object array of data
    arr = new Array(descriptor, conn, aryMan);
    } catch (SQLException se)
    System.out.println("SQL Exception: " + se.getMessage());
    // Now we can set the WHERE clause parameter bind variable (index = 0) to the Oracle Array
    if (arr != null) setWhereClauseParam(0, arr);
    * FILE: Panel1.java
    * Created as an empty panel. Then a JTextField, a
    * JButton, and an EmpView1 table were dragged on.
    * A custom actionPerformed method was created for the
    * JButton which grabs the data from the text box.
    * The user can enter either a single manager id or
    * multiple, comma-separated ids.
    * All code in this class was created by JDev except
    * for the Jbutton action
    package view;
    import java.awt.*;
    import javax.swing.*;
    import model.common.*;
    import oracle.jbo.ApplicationModule;
    import oracle.jbo.SQLStmtException;
    import oracle.jbo.uicli.jui.*;
    import oracle.jbo.uicli.controls.*;
    import oracle.jbo.uicli.binding.*;
    import oracle.jdeveloper.layout.*;
    import oracle.adf.model.*;
    import oracle.adf.model.binding.*;
    import java.util.ArrayList;
    import oracle.jdeveloper.layout.VerticalFlowLayout;
    import javax.swing.JTextField;
    import javax.swing.JButton;
    import javax.swing.JTable;
    import javax.swing.table.TableModel;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    public class Panel1 extends JPanel implements JUPanel
    * NOTE: You need to have previous created the Oracle8 type named
    * ==== TABLE_OF_VARCHAR by doing the following at the SQL*Plus
    * command prompt:
    * create type table_of_varchar as table of varchar2(20)
    // Panel binding definition used by design time
    private JUPanelBinding panelBinding = new JUPanelBinding("Panel1UIModel");
    private VerticalFlowLayout verticalFlowLayout1 = new VerticalFlowLayout();
    private JTextField jTextField1 = new JTextField();
    private JButton jButton1 = new JButton();
    private JTable jTable1 = new JTable();
    * The default constructor for panel
    public Panel1()
    * the JbInit method
    public void jbInit() throws Exception
    this.setLayout(verticalFlowLayout1);
    jTextField1.setText("jTextField1");
    jButton1.setText("jButton1");
    jButton1.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    jButton1_actionPerformed(e);
    this.add(jTextField1, null);
    this.add(jButton1, null);
    this.add(jTable1, null);
    jTable1.setModel((TableModel)panelBinding.bindUIControl("EmpView1", jTable1));
    public static void main(String [] args)
    try
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    catch(Exception exemp)
    exemp.printStackTrace();
    Panel1 panel = new Panel1();
    panel.setBindingContext(JUTestFrame.startTestFrame("DataBindings.cpx", "null", panel, panel.getPanelBinding(), new Dimension(400, 300)));
    panel.revalidate();
    * JUPanel implementation
    public JUPanelBinding getPanelBinding()
    return panelBinding;
    private void unRegisterProjectGlobalVariables(BindingContext bindCtx)
    JUUtil.unRegisterNavigationBarInterface(panelBinding, bindCtx);
    private void registerProjectGlobalVariables(BindingContext bindCtx)
    JUUtil.registerNavigationBarInterface(panelBinding, bindCtx);
    public void setBindingContext(BindingContext bindCtx)
    if (panelBinding.getPanel() == null)
    panelBinding = panelBinding.setup(bindCtx, this);
    registerProjectGlobalVariables(bindCtx);
    panelBinding.refreshControl();
    try
    jbInit();
    panelBinding.refreshControl();
    catch(Exception ex)
    panelBinding.reportException(ex);
    private void jButton1_actionPerformed(ActionEvent e)
    // Get the user-supplied values
    String txt = jTextField1.getText();
    String[] mIds = txt.split(",");
    // Now trim
    for (int i=0; i<mIds.length; i++)
    mIds[i] = mIds.trim();
    ApplicationModule am = (ApplicationModule)panelBinding.getDataControl().getDataProvider();
    EmpView vo = (EmpView)am.findViewObject("EmpView1");
    vo.setManagerID(mIds);
    try
    vo.executeQuery();
    } catch (SQLStmtException s)
    System.out.println("Query failed: " + s.getMessage());

  • Help required in Index Question

    Hi,
    This is an interview question that i faced.
    Theres a table Statistics having more than 300 columns. It has normal indexes on say five columns col1, col2, col3, col4, col5.
    Queries involving the first four columns give excellent performance but the query involving col5 gives poor performance.
    COL5 has around 5 million data and 1 normal index ix created on it and theres just one value in it say 'STATS'.(He said the query can be simple select queries or join queries, the queries may select all the rows of few rows may be 5%, 10% etc).
    The question was what could be the possible reason?
    I was unable to answer it but i think BITMAP index might be useful in this scenario.
    Any help or suggestions will be highly appreciated.

    Is it a good idea to creat a normal index on a column that have just one value as 'STATS' and the total no of rows is more than 5 million??
    No
    See the I/O
    SQL> CREATE TABLE bitmap_table AS SELECT ROWNUM rn FROM all_objects
      2  /
    Table created.
    SQL> ALTER TABLE bitmap_table ADD (status VARCHAR2(1))
      2  /
    Table altered.
    SQL> SELECT COUNT(*) FROM bitmap_table
      2  /
    COUNT(*)
        64177
    SQL> UPDATE bitmap_table SET status='Y'
      2  /
    64177 rows updated.
    SQL> COMMIT
      2  /
    Commit complete.
    SQL> CREATE TABLE btree_table AS SELECT * FROM bitmap_table
      2  /
    Table created.
    SQL> CREATE BITMAP INDEX bitmap_table_idx ON bitmap_table (status)
      2  /
    Index created.
    SQL> CREATE INDEX btree_table_idx ON btree_table (status)
      2  /
    Index created.
    SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SCOTT','BITMAP_TABLE')
    PL/SQL procedure successfully completed.
    SQL> EXEC DBMS_STATS.GATHER_INDEX_STATS('SCOTT','BITMAP_TABLE_IDX')
    PL/SQL procedure successfully completed.
    SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SCOTT','BTREE_TABLE')
    PL/SQL procedure successfully completed.
    SQL> EXEC DBMS_STATS.GATHER_INDEX_STATS('SCOTT','BTREE_TABLE_IDX')
    PL/SQL procedure successfully completed.
    SQL> SET AUTOTRACE TRACEONLY
    SQL> SELECT status
      2    FROM bitmap_table
      3   WHERE status='Y'
      4  /
    64177 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=2 Card=64177 Bytes
              =128354)
       1    0   BITMAP CONVERSION (TO ROWIDS) (Cost=2 Card=64177 Bytes=128
              354)
       2    1     BITMAP INDEX (FAST FULL SCAN) OF 'BITMAP_TABLE_IDX' (IND
              EX (BITMAP))
    Statistics
            171  recursive calls
              0  db block gets
             31  consistent gets
              0  physical reads
              0  redo size
         804546  bytes sent via SQL*Net to client
         475281  bytes received via SQL*Net from client
           4280  SQL*Net roundtrips to/from client
              4  sorts (memory)
              0  sorts (disk)
          64177  rows processed
    SQL> DROP INDEX BITMAP_TABLE_IDX
      2  /
    Index dropped.
    SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS('SCOTT','BITMAP_TABLE')
    PL/SQL procedure successfully completed.
    SQL> SET AUTOTRACE TRACEONLY
    SQL> SELECT status
      2    FROM bitmap_table
      3   WHERE status='Y'
      4  /
    64177 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=26 Card=64202 Byte
              s=128404)
       1    0   TABLE ACCESS (FULL) OF 'BITMAP_TABLE' (TABLE) (Cost=26 Car
              d=64202 Bytes=128404)
    Statistics
            192  recursive calls
              0  db block gets
           4405  consistent gets
              0  physical reads
              0  redo size
         804546  bytes sent via SQL*Net to client
         475281  bytes received via SQL*Net from client
           4280  SQL*Net roundtrips to/from client
              4  sorts (memory)
              0  sorts (disk)
          64177  rows processed
    SQL> SELECT status
      2    FROM btree_table
      3   WHERE status='Y'
      4  /
    64177 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=27 Card=64177 Byte
              s=128354)
       1    0   INDEX (FAST FULL SCAN) OF 'BTREE_TABLE_IDX' (INDEX) (Cost=
              27 Card=64177 Bytes=128354)
    Statistics
            171  recursive calls
              0  db block gets
           4429  consistent gets
              0  physical reads
              0  redo size
         804546  bytes sent via SQL*Net to client
         475281  bytes received via SQL*Net from client
           4280  SQL*Net roundtrips to/from client
              4  sorts (memory)
              0  sorts (disk)
          64177  rows processed
    SQL> SELECT index_name,blevel,num_rows
      2    FROM user_indexes
      3   WHERE index_name='BTREE_TABLE_IDX'
      4  /
    INDEX_NAME                        BLEVEL  NUM_ROWS
    BTREE_TABLE_IDX                        1     64177
    SQL> SELECT index_name,blevel,num_rows
      2    FROM user_indexes
      3*  WHERE index_name='BITMAP_TABLE_IDX'
    SQL> /
    INDEX_NAME                        BLEVEL  NUM_ROWS
    BITMAP_TABLE_IDX                       1         3Khurram

  • Query With BETWEEN Clause Slows Down

    hi,
    I am experiencing slow down query by using BETWEEN clause. Is there any solution for it?

    Here is the difference if I use equal not between.
    SQL> select to_char(sysdate,'MM-DD-YYYY HH24:MI:SS') from dual;
    TO_CHAR(SYSDATE,'MM
    11-14-2005 15:44:03
    SQL> SELECT COUNT(*) /*+ USE_NL(al2), USE_NL(al3), USE_NL(al4),
    2 USE_NL(al5), USE_NL(al6) */
    3 FROM acct.TRANSACTION al1,
    4 acct.account_balance_history al2,
    5 acct.ACCOUNT al3,
    6 acct.journal al4,
    7 acct.TIME al5,
    8 acct.object_code al6
    9 WHERE ( al1.reference_num = al4.reference_num(+)
    10 AND al1.timekey = al5.timekey
    11 AND al5.timekey = al2.timekey
    12 AND al3.surrogate_acct_key = al2.surrogate_acct_key
    13 AND al3.surrogate_acct_key = al1.surrogate_acct_key
    14 AND al1.report_fy = al3.rpt_fy
    15 AND al6.object_code = al1.object_adj
    16 )
    17 AND ((al1.timekey = 20040701
    18 or al1.timekey = 20040801
    19 or al1.timekey = 20040901
    20 or al1.timekey = 20041001
    21 or al1.timekey = 20041101
    22 or al1.timekey = 20041201
    23 or al1.timekey = 20050101
    24 or al1.timekey = 20050201
    25 or al1.timekey = 20050301
    26 or al1.timekey = 20050401
    27 or al1.timekey = 20050501
    28 or al1.timekey = 20050601
    29 or al1.timekey = 20050701
    30 or al1.timekey = 20050801
    31 or al1.timekey = 20050901)
    32 AND al3.dept = '480');
    COUNT(*)/*+USE_NL(AL2),USE_NL(AL3),USE_NL(AL4),USE_NL(AL5),USE_NL(AL6)*/
    34245
    SQL> select to_char(sysdate,'MM-DD-YYYY HH24:MI:SS') from dual;
    TO_CHAR(SYSDATE,'MM
    11-14-2005 15:44:24

  • How to implement Select Between clause? ..help

    Hi
    I want to implent typical select between clause in the mappings. It is like i want to check whether the "Given date" exists between the range of dates. The range of dates is obtained from the various dimension tables. I dont know how implement that. please help.
    Typical SQL query would be ....
    and A."Month End Date" between dim.efcv_bgdt and dim.efcv_endt
    and A."Month End Date" between dim2.efcv_bgdt and dim2.efcv_endt
    and A."Month End Date" between dim3.efcv_bgdt and dim3.efcv_endt          
    and so on..............................
    ***************************************************************

    Hi
    Use a joiner operator and connect dim1, dim2, dim3 to it and in the join expression use your netween expression.
    Or do you want to use the between in the select clause? Then use an expression operator and define a case when ... between ... and ... then ... else ... expression.
    Ott Karesz
    http://www.trendo-kft.hu

  • What is difference between sy-index and sy-tabix and where both are using ?

    what is difference between sy-index and sy-tabix and where both are using ?

    hi nagaraju
    sy-tabix is in Internal table, current line index. So it can only be used while looping at the internal table.
    sy-index is in Loops, number of current pass. This you can use in other loop statements also (like do-enddo loop, while-endwhile)
    SY-INDEX is a counter for following loops: do...enddo, while..endwhile
    SY-TABIX is a counter for LOOP...ENDLOOP, READ TABLE...
    Here is an example from which you can understand the difference between sy-tabix and sy-index.
    Itab is an internal table with the following data in it.
    id Name
    198 XYZ
    475 ABC
    545 PQR.
    loop at itab where id > 300.
    write :/ itab-id, itab-name , sy-tabix, sy-index.
    endloop.
    My output will be :
    475 ABC 2 1
    545 PQR 3 2
    Sy-tabix is the index of the record in internal table.
    sy-index gives the no of times of loop passes.
    So, for the first record in the output (475 ABC), 2 is the index of the record in internal table and as it is first time loop pass occured, sy-index value is 1.
    Regards,
    navjot
    award points

  • Difference between sy-index & sy-tabix

    Dear friends,
    Please tell me the difference between sy-index & sy-tabix
    Actually my problem is i don't know how to compare for example between first record'field n and second record'field n when u r in loop so i can take particular action based on result
    on current recor
    if possible send me sample code.
    Regards;
    Parag Gavkar.

    SY-TABIX:
    Current line in an internal table. With the following statements SY-TABIX is set for index tables. With hashed tables, SY-TABIX is not filled or it is set to 0.
    - APPEND sets SY-TABIX to the index of the last table row, that is the total number of entries in the target table.
    - COLLECT sets SY-TABIX to the index of the existing or appended table row. With hashed tables, SY-TABIX is set to 0.
    - LOOP AT sets SY-TABIX to the index of the current table row at the beginning of every loop pass. After leaving a loop, SY-TABIX is set to the value it had before entering the loop. With hashed tables, SY-TABIX is set to 0.
    - READ TABLE sets SY-TABIX to the index of the table row read. If no row is found with binary search while reading, SY-TABIX contains the index of the next-highest row or the total number of rows +1. If no row is found with linear search while reading, SY-TABIX is undefined.
    - SEARCH itab FOR sets SY-TABIX to the index of the table row, in which the search string was found.
    SY-INDEX:
    SY-INDEX contains the number of loop passes in DO and WHILE loops, including the current loop pass.
    Regards,
    Santosh

  • Difference Between Unique Index vs Unique Constraint

    Can you tell me
    what is the Difference Between Unique Index vs Unique Constraint.
    and
    Difference Between Unique Index and bitmap index.
    Edited by: Nilesh Hole,Pune, India on Aug 22, 2009 10:33 AM

    Nilesh Hole,Pune, India wrote:
    Can you tell me
    what is the Difference Between Unique Index vs Unique Constraint.http://www.jlcomp.demon.co.uk/faq/uk_idx_con.html
    and
    Difference Between Unique Index and bitmap index.The documentation is your friend:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/schema.htm#CNCPT1157
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/schema.htm#sthref1008
    Regards,
    Rob.

  • How can I set a variable number of values in a SQL IN clause?

    Hi,
    How can I set a variable number of values in a SQL IN clause without having to change the text of the SQL statement each time?
    I read the link http://radio.weblogs.com/0118231/2003/06/18.html. as steve wrote.
    SELECT *
    FROM EMP
    WHERE ENAME IN (?)
    But we need the steps not to create type in the system and would there be any other solution if we would like to use variable number of values in a SQL IN clause ?
    We are using JDeveloper 10.1.3.2 with Oracle Database 10.1.3.2
    Thanks
    Raj

    Hi,
    can you please explain why the solution from steve is not the right solution for you.
    regards
    Peter

  • Generate a SQL "IN" clause using ALDSP

    Problem Summary
    ALDSP: Generate a SQL "IN" clause
    Problem Description
    I would like to know if there is a possibility of generating an SQL "IN" clause using ALDSP.
    I would need the XQuery construct to create an SQLsomething like-
    select * from emp where dept_no in ('101', '201', '301');
    The values for dept_no would be passed at runtime.
    (Or)
    Will be I able to create a physical data service using the SQL - select * from emp where dept_no in ?
    If yes, how do I map the parameter to "?"
    Thanks.

    Mike,
    Thanks for the response. The section that you are taking about is to push joins to DB. Joining tables is not the problem that I am facing.
    I will rephrase the problem.
    I would like to know if there is a possibility of creating a ALDSP physical data service (.ds file) with the SQL as select * from employee where emp_id in ?
    and I should be able to pass multiple employee ids to the "?" parameter. select * from emp where emp_id in ('101', '201', '301');
    There is no fixed number of ids that a user can pass.
    Thanks.

  • SQL IN clause with a Tool variable

     

    We are using using Forte 3.M.2 (just upgraded from 3.G, finally).
    Platform is AIX 4.3. Database is DB2 (UDB) (version 5.2 i think).
    True, I haven't tried my code on any other platform. I think it should work on NT, because one of our other teams members has set up an NT laptop for portable demos. And it has DB2 (NT version i guess) loaded on it.
    Dynamic sql is not really that bad, if you have to go that route to build your list.
    Let me know how it goes.
    Steven Barnes
    Daniel Gonz&aacute;lez de Lucas <danieleam.es> 07/28/00 04:06AM >>>We are getinng some trouble, the DB Manager seems to try to convert
    :OfficeList to a unique integer lets say:
    :OfficeList value is 3,4,7
    so the IN clause
    trying with Oracle 8.1.5 converts 3,4,7 in a unique integer (a extrange
    value because doesn't match with 3,4 nor 7).
    trying with SQL Server 6.5 gives an error converting 3,4,7 to a unique
    tinyint.
    The idea is that with your sintax the DB Manager must split the TextData
    into 3 integer values. I think that it works fine in some DB Managers and
    not in others.
    Which release and vendor of DB Manager you use?
    Which Fort&eacute; release?
    Thank you very much in advance.
    Daniel.
    ----- Original Message -----
    From: "Steve Barnes" <DHS9126dhs.state.il.us>
    To: <danieleam.es>; <kamranaminyahoo.com>
    Sent: Thursday, July 27, 2000 1:55 PM
    Subject: Re: (forte-users) SQL IN clause with a Tool variable
    I needed to have an "IN" clause for some numbers. Here's how I did it:
    GetOffices():TextData method...
    Offices : TextData = new ;
    for (x : integer) in sql select MyIntegerColumn
    from MY_TABLE
    where whatever condition
    on session MyDBSession do
    Offices.Concat(x) ;
    Offices.Concat(',') ;
    end for ;
    return (Offices.CopyRange(0,Offices.ActualSize -1)) ; // get rid of lastcomma
    in actual sql.....
    OfficeList : TextData ;
    OfficeList = GetOffices() ;
    sql select * from MyTable where MyField in (:OfficeList)
    on session MyDBSession ;
    Works very well.
    Steven Barnes
    Daniel Gonz&aacute;lez de Lucas <danieleam.es> 07/27/00 05:32AM >>>Hello,
    To do a select we have two options:
    select * from MyTable
    where MyField in ('a','b','c')
    we would like to do the same but using a fort&eacute; variable in the IN clause.
    select * from MyTable
    where MyField in (:ToolVar)
    What should we do and what kind of variable or array of variables shouldwe use in ToolVar to do the same than in first option?
    >
    Has anybody done this without a dynamic query?
    Best regards
    Daniel
    For the archives, go to: http://lists.xpedior.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com

Maybe you are looking for

  • Change Msg partner in support desk message

    Hi, I want to change the msg processor in support desk message from webdynpro. Which RFC Function module will be helpful ? Note : with the following function module we already tried , it is not changing msg processor in solution manager Sup dsk. crm_

  • Photoshop CS6 doesn't recognize my NVIDIA GeForce GTX 675M GPU?

    I just bought a brand new Alienware M17x R4 with Windows 8 Pro x64 and Photoshop CS6 won't recognize my NVIDIA GeForce GTX 675M GPU? I've already updated Windows 8, Photoshop and the Nvidia graphics driver. Any ideas?  I spent so much on a nice graph

  • Sender JDBC adapter SELECT / UPDATE issue - updates more rows than selected

    Hi, We have configured a Sender JDBC Adapter to poll records from an Oracle table based on a flag field and then update the flag for the selected records. When tested in DEV and QA environments (where test data comes in intermittently and not in huge

  • Tinnitus - ringing in ears

    I developed Tinnitus immediately after falling asleep listening to music using the stock ear buds. Fortunately I was laying on my side therefore listened with just one ear, so I still have one healthy ear left. I did NOT have the volume up loud...I w

  • COGI error reprocessing logic

    Hi experts, I need to implement customized COGI  error reprocessing logic <i>(errors related to automatic batch, valuation type, and posting date redetermination). </i> Could you please let me know if there are any existing FMs/BADI/BAPI where I can