Decode in combination with IN-Statement

Hello,
I'm looking for a way to combine DECODE with the IN-Statement in the following manner:
select description of table where type in DECODE(:p1,1,(1,9,100),7,(8,21,110))
:p1 will be replaced by one numeric-value before the statement is evaluated.
The DB (10g) says that a right parantesis is missing.
Any ideas for an elegant solution?
With regards
Carsten

SQL> create table t (type,other_column)
  2  as
  3   select level
  4        , lpad('*',100,'*')
  5     from dual
  6  connect by level <= 110
  7    union all
  8   select null
  9        , null
10     from dual
11  /
Table created.
SQL> create index i1 on t(type)
  2  /
Index created.
SQL> exec dbms_stats.gather_table_stats(user,'t',cascade=>true)
PL/SQL procedure successfully completed.
SQL> var p1 number
SQL> exec :p1 := 1
PL/SQL procedure successfully completed.
SQL> select /*+ gather_plan_statistics */
  2         type
  3       , other_column
  4    from t
  5   where (   :p1 = 1
  6         and type in (1,9,100)
  7         )
  8      or (   :p1 = 7
  9         and type in (8,21,110)
10         )
11  /
                                  TYPE
OTHER_COLUMN
                                     1
                                     9
                                   100
3 rows selected.
SQL> select * from table(dbms_xplan.display_cursor(null,null,'allstats last'))
  2  /
PLAN_TABLE_OUTPUT
SQL_ID  fx8dqasdpfcpu, child number 0
select /*+ gather_plan_statistics */        type      , other_column   from t  where (
:p1 = 1        and type in (1,9,100)        )     or (   :p1 = 7        and type in
(8,21,110)        )
Plan hash value: 2620590112
| Id  | Operation                      | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
|   1 |  CONCATENATION                 |      |      1 |        |      3 |00:00:00.01 |       8 |
|*  2 |   FILTER                       |      |      1 |        |      0 |00:00:00.01 |       0 |
|   3 |    INLIST ITERATOR             |      |      0 |        |      0 |00:00:00.01 |       0 |
|   4 |     TABLE ACCESS BY INDEX ROWID| T    |      0 |      3 |      0 |00:00:00.01 |       0 |
|*  5 |      INDEX RANGE SCAN          | I1   |      0 |      3 |      0 |00:00:00.01 |       0 |
|*  6 |   FILTER                       |      |      1 |        |      3 |00:00:00.01 |       8 |
|   7 |    INLIST ITERATOR             |      |      1 |        |      3 |00:00:00.01 |       8 |
|*  8 |     TABLE ACCESS BY INDEX ROWID| T    |      3 |      3 |      3 |00:00:00.01 |       8 |
|*  9 |      INDEX RANGE SCAN          | I1   |      3 |      3 |      3 |00:00:00.01 |       5 |
Predicate Information (identified by operation id):
   2 - filter(:P1=7)
   5 - access(("TYPE"=8 OR "TYPE"=21 OR "TYPE"=110))
   6 - filter(:P1=1)
   8 - filter((LNNVL(:P1=7) OR (LNNVL("TYPE"=8) AND LNNVL("TYPE"=21) AND
              LNNVL("TYPE"=110))))
   9 - access(("TYPE"=1 OR "TYPE"=9 OR "TYPE"=100))
32 rows selected.
SQL> exec :p1 := 7
PL/SQL procedure successfully completed.
SQL> select /*+ gather_plan_statistics */
  2         type
  3       , other_column
  4    from t
  5   where (   :p1 = 1
  6         and type in (1,9,100)
  7         )
  8      or (   :p1 = 7
  9         and type in (8,21,110)
10         )
11  /
                                  TYPE
OTHER_COLUMN
                                     8
                                    21
                                   110
3 rows selected.
SQL> select * from table(dbms_xplan.display_cursor(null,null,'allstats last'))
  2  /
PLAN_TABLE_OUTPUT
SQL_ID  fx8dqasdpfcpu, child number 0
select /*+ gather_plan_statistics */        type      , other_column   from t  where (
:p1 = 1        and type in (1,9,100)        )     or (   :p1 = 7        and type in
(8,21,110)        )
Plan hash value: 2620590112
| Id  | Operation                      | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
|   1 |  CONCATENATION                 |      |      1 |        |      3 |00:00:00.01 |       7 |
|*  2 |   FILTER                       |      |      1 |        |      3 |00:00:00.01 |       7 |
|   3 |    INLIST ITERATOR             |      |      1 |        |      3 |00:00:00.01 |       7 |
|   4 |     TABLE ACCESS BY INDEX ROWID| T    |      3 |      3 |      3 |00:00:00.01 |       7 |
|*  5 |      INDEX RANGE SCAN          | I1   |      3 |      3 |      3 |00:00:00.01 |       4 |
|*  6 |   FILTER                       |      |      1 |        |      0 |00:00:00.01 |       0 |
|   7 |    INLIST ITERATOR             |      |      0 |        |      0 |00:00:00.01 |       0 |
|*  8 |     TABLE ACCESS BY INDEX ROWID| T    |      0 |      3 |      0 |00:00:00.01 |       0 |
|*  9 |      INDEX RANGE SCAN          | I1   |      0 |      3 |      0 |00:00:00.01 |       0 |
Predicate Information (identified by operation id):
   2 - filter(:P1=7)
   5 - access(("TYPE"=8 OR "TYPE"=21 OR "TYPE"=110))
   6 - filter(:P1=1)
   8 - filter((LNNVL(:P1=7) OR (LNNVL("TYPE"=8) AND LNNVL("TYPE"=21) AND
              LNNVL("TYPE"=110))))
   9 - access(("TYPE"=1 OR "TYPE"=9 OR "TYPE"=100))
32 rows selected.So you can use the query without the gather_plan_statistics hint.
Regards,
Rob.

Similar Messages

  • Problem with Select Statements

    Hi All,
    I have a performance problem for my report because of the following statements.
    How can i modify the select statements for improving the performance of the report.
    DATA : shkzg1h  LIKE bsad-shkzg,
             shkzg1s  LIKE bsad-shkzg,
             shkzg2h  LIKE bsad-shkzg,
             shkzg2s  LIKE bsad-shkzg,
             shkzg1hu LIKE bsad-shkzg,
             shkzg1su LIKE bsad-shkzg,
             shkzg2hu LIKE bsad-shkzg,
             shkzg2su LIKE bsad-shkzg,
             kopbal1s  LIKE bsad-dmbtr,
             kopbal2s  LIKE bsad-dmbtr,
             kopbal1h  LIKE bsad-dmbtr,
             kopbal2h  LIKE bsad-dmbtr,
             kopbal1su  LIKE bsad-dmbtr,
             kopbal2su  LIKE bsad-dmbtr,
             kopbal1hu  LIKE bsad-dmbtr,
             kopbal2hu  LIKE bsad-dmbtr.
    *These statements are in LOOP.
        SELECT shkzg SUM( dmbtr )
          INTO (shkzg1s , kopbal1s)
          FROM bsid
         WHERE bukrs = ibukrs
           AND kunnr = ktab-kunnr
           AND budat < idate-low
           AND shkzg = 'S'
           AND umskz EQ ''
         GROUP BY shkzg.
        ENDSELECT.
        SELECT shkzg SUM( dmbtr )
          INTO (shkzg1su , kopbal1su)
          FROM bsid
         WHERE bukrs = ibukrs
           AND kunnr = ktab-kunnr
           AND budat < idate-low
           AND shkzg = 'S'
           AND umskz IN zspgl
         GROUP BY shkzg.
        ENDSELECT.
        SELECT shkzg SUM( dmbtr )
          INTO (shkzg1h , kopbal1h)
          FROM bsid
         WHERE bukrs = ibukrs
           AND kunnr = ktab-kunnr
           AND budat < idate-low
           AND shkzg = 'H'
           AND umskz EQ ''
         GROUP BY shkzg.
        ENDSELECT.
        SELECT shkzg SUM( dmbtr )
          INTO (shkzg1hu , kopbal1hu)
          FROM bsid
         WHERE bukrs = ibukrs
           AND kunnr = ktab-kunnr
           AND budat < idate-low
           AND shkzg = 'H'
           AND umskz IN zspgl
         GROUP BY shkzg.
        ENDSELECT.
        SELECT shkzg SUM( dmbtr )
          INTO (shkzg2s , kopbal2s)
          FROM bsad
         WHERE bukrs = ibukrs
           AND kunnr = ktab-kunnr
           AND budat < idate-low
           AND shkzg = 'S'
           AND umskz EQ ''
         GROUP BY shkzg.
        ENDSELECT.
        SELECT shkzg SUM( dmbtr )
          INTO (shkzg2su , kopbal2su)
          FROM bsad
         WHERE bukrs = ibukrs
           AND kunnr = ktab-kunnr
           AND budat < idate-low
           AND shkzg = 'S'
           AND umskz IN zspgl
         GROUP BY shkzg.
        ENDSELECT.
        SELECT shkzg SUM( dmbtr )
          INTO (shkzg2h , kopbal2h)
          FROM bsad
         WHERE bukrs = ibukrs
           AND kunnr = ktab-kunnr
           AND budat < idate-low
           AND shkzg = 'H'
           AND umskz EQ ''
         GROUP BY shkzg.
        ENDSELECT.
        SELECT shkzg SUM( dmbtr )
          INTO (shkzg2hu , kopbal2hu)
          FROM bsad
         WHERE bukrs = ibukrs
           AND kunnr = ktab-kunnr
           AND budat < idate-low
           AND shkzg = 'H'
           AND umskz IN zspgl
         GROUP BY shkzg.
        ENDSELECT.

    >
    Siegfried Boes  wrote:
    > Please stop writing answers if you understrand nothing about database SELECTS!
    > All above recommendations are pure nonsense!
    >
    > As always with such questions, you must do an analysis before you ask! The coding itself is perfectly o.k., a SELECT with an aggregate and a GROUP BY can not be changed into a SELECT SINGLE or whatever.
    >
    > But your SELECTS mustr be supported by indexes!
    >
    > Please run SQL Trace, and tell us the results:
    >
    > I see 8 statements, what is the duration and the number of records coming back for each statement?
    > Maybe only one statement is slow.
    >
    > See
    > SQL trace:
    > /people/siegfried.boes/blog/2007/09/05/the-sql-trace-st05-150-quick-and-easy
    >
    >
    > Siegfried
    Nice point there Siegfried. Instead of giving constructive suggestion, people here give a very bad suggestion on using SELECT SINGLE combined with SUM and GROUP BY.
    I hope the person already look at your reply before he try using select single and wondering why he has error.
    Anyway, the most important thing is how many loop expected for those select statements?
    If you have like thousands of loop, you can expect a poor performance.
    So, you should also look at how many times the select statement is called and not only performance for each select statement when you're doing SQL trace.
    Regards,
    Abraham

  • Hash tables in combination with data references to the line type.

    I'm having an issue with hash tables - in combination with reference variables.
    Consider the following:  (Which is part of a class)  -  it attempts to see if a particular id exists in a table; if not add it; if yes change it.   
      types: BEGIN OF TY_MEASUREMENT,
               perfid      TYPE zgz_perf_metric_id,
               rtime       TYPE zgz_perf_runtime,
               execount    TYPE zgz_perf_execount,
               last_start  TYPE timestampl,
             END OF TY_MEASUREMENT.
    METHOD START.
      DATA:  ls_measurement TYPE REF TO ty_measurement.
      READ TABLE gt_measurements WITH TABLE KEY perfid = i_perfid reference into ls_measurement.
      if sy-subrc <> 0.
        "Didn't find it.
        create data ls_measurement.
        ls_measurement->perfid = i_perfid.
        insert ls_measurement->* into gt_measurements.
      endif.
      GET TIME STAMP FIELD ls_measurements-last_start.
      ls_measurement->execount = ls_measurement->execount + 1.
    ENDMETHOD.
    I get compile errors on the insert statement - either "You cannot use explicit index operations on tables with types HASHED TABLE" or "ANY TABLE".      It is possible that.
    If I don't dereference the type then I get the error  LS_MEASUREMENT cannot be converted to the line type of GT_MEASUREMENTS.
    I'm not looking to solve this with a combination of references and work ares - want a reference solution.   
    Thanks!
    _Ryan
    Moderator message - Moved to the correct forum
    Edited by: Rob Burbank on Apr 22, 2010 4:43 PM

    I think it might work when you change it for
    insert ls_measurement->* into TABLE gt_measurements.
    For hashed table a new line here will be inserted according to given table key.
    Regards
    Marcin

  • Pcard in combination with catalog

    Hi all,
    Is there someone who can explain me the process of Pcard purchases in combination with catalogs? I heard that there will be no request and purchase order in SRM for each purchase. There will be a periodic load from the catalog into SAP that creates a dummy requisition and order for all ordered items in that period. This order will be used to verify the settlement. Is this the correct process?
    If it is the correct process, can this be done with external and internal catalogs?
    Thanks,
    Ed

    Hi
    <b>Please go through the related helpful links -></b>
    <u>P-Card Basics</u> http://help.sap.com/saphelp_srm50/helpdata/en/61/2ff300787411d2b41d006094b92d37/frameset.htm
    http://help.sap.com/saphelp_srm50/helpdata/en/97/b71c4145a6f723e10000000a155106/frameset.htm
    <u>Process flow -></u>
    http://help.sap.com/saphelp_srm50/helpdata/en/61/2ff300787411d2b41d006094b92d37/frameset.htm
    Pcard and Catalogs
    Re: Pcard Statement Processing
    Re: P card- Business process.
    Regards
    - Atul

  • Currency format combined with if else issue

    Hi all,
    Basically, I need to get the value from if else statement, then use currency format to format the currency according to their currency code.
    the following is my if else statement to show the A.PAY_PROMISE_AMT or A.PROMISE_AMT
    <?xdofx:if A.PAY_PROMISE_AMT <> 0 then
    A.PAY_PROMISE_AMT
    else
    A.PROMISE_AMT
    end if?>
    <?format-currency:value_*[this value I want to use is the value from the above if else statement];*currencycode; ‘false’?>
    could anyone help me to combine those two statement to get the result I want?
    Thanks in advance

    >
    I tried your solution, but I got some error.
    >
    some?
    try change
    <>to
    !=in my sample
    what if you try IF without xdofx?
    what will be result?
    say
    <?if:A.PAY_PROMISE_AMT!=0?> <?xdoxslt:set_variable($_XDOCTX, 'LVar', A.PAY_PROMISE_AMT)?> <?end if?>
    <?if:A.PAY_PROMISE_AMT=0?> <?xdoxslt:set_variable($_XDOCTX, 'LVar', A.PROMISE_AMT)?> <?end if?>
    <?format-currency: xdoxslt:get_variable($_XDOCTX, 'LVar');CURRENCY;'true'?>plz see
    Working with xdofx:if and xdoxslt variable error

  • Sequence in combination with function

    Hi,
    I have an issue with a sequence in combination with a function.
    I want to generate some kind of an inventory material report that contains some kind of a material ID (a non-repeating, auto-incrementing number, gaps allowed). However I have to keep track of which material IDs I have used for which inventory material, for traceability reasons. Another important requirement is that whenever the report is run, that the returned material IDs are never repeating. So repeatedly runs for the same inventory material should always return new material ID.
    So I was about to create a simple PL/SQL function where I pass my data from traceability as parameters. Then the function uses internally a sequence (nextval) to generate a new material ID, then stores the new material ID with the related values from the input parameters into a table (autonomous transaction) and returns the new ID.
    This works pretty fine so far.
    Now the tricky part: I want have a SQL statement where I want to return one and the same ID in different columns.
    Let me give an example:
    CREATE SEQUENCE XXX_TEST_SEQ
    MINVALUE 1 MAXVALUE 999999999999999999999999999
    INCREMENT BY 1 START WITH 1
    NOCACHE NOORDER NOCYCLE;
    CREATE PACKAGE XXX_TEST_PKG AUTHID CURRENT_USER AS
    FUNCTION get_id(p_someparameter NUMBER) RETURN NUMBER;
    END XXX_TEST_PKG;
    CREATE PACKAGE BODY XXX_TEST_PKG AS
    FUNCTION get_id(p_someparameter NUMBER) RETURN NUMBER IS
      l_new_id NUMBER;
    BEGIN
      SELECT XXX_TEST_SEQ.NEXTVAL
        INTO l_new_id
        FROM DUAL;
        /* do some more logic, e.g. store the freshly generated ID
            together with the input parameter values in some tracing table */
      RETURN l_new_id;
    END get_id;
    END XXX_TEST_PKG;This is a simplified version of the function for demo.
    Let's use it:
    -- 1) this works as expected:
    select xxx_test_pkg.get_id(1) from dual;
    XXX_TEST_PKG.GET_ID(1)
    1                       
    -- 2) this returns two different numbers:
    select xxx_test_pkg.get_id(1) as id_one
        ,  xxx_test_pkg.get_id(1) as id_two
    from dual;
    ID_ONE                 ID_TWO                
    2                      3                     
    -- 3) This is the problematic case: I want to return the same ID two times:
    select my_id as id
         , my_id as same_id
    from (select xxx_test_pkg.get_id(1) as my_id from dual);
    ID                     SAME_ID               
    4                      5                     
    -- 4) CURVAL on these sequence does not work:
    select my_id as id
         , xxx_test_seq.curval as same_id
    from (select xxx_test_pkg.get_id(1) as my_id from dual);
    SQL Error: ORA-00904: "XXX_TEST_SEQ"."CURVAL": invalid identifier
    -- 5) This gives the output that I need, but why?
    select my_id as id
         , xxx_test_seq.nextval as same_id
    from (select xxx_test_pkg.get_id(1) as my_id from dual);
    ID                     SAME_ID               
    7                      7                      So query 3 is the one that gives me headaches. I need to return one and the same ID in different columns. But this returns just two different IDs. I know that the optimizer will merge the two select statements into one and therefore execute the function twice. Does anybody know how I could avoid this?
    What is a bit strange to me is that query 5 really returns what I need, but at a first glance I would say it should not do so. I would say that using nextval would return me again another sequence number.
    This is confusing... Can anybody explain this and advise how I could build a query were I can get the same ID two times per row?
    I know I can totally get rid of the sequence in my function and use something different, but I was wondering if I can avoid changing my function.
    Thanks,
    David.

    David Weber wrote:
    thanks lot for all the great feedback. That's really helpful. I think I'll go for the NO_MERGE hint. A first test with this looks good.Keep in mind, only undocumented hint MATERIALIZE along with subquery factoring clause WITH (for which this hint was created) will work in real queries:
    SQL> select my_id as id
      2       , my_id as same_id
      3  from (select /*+ NO_MERGE */ xxx_test_pkg.get_id(1) as my_id from dual),emp where rownum < 6;
            ID    SAME_ID
            20         20
            21         21
            21         21
            21         21
            21         21
    SQL> select my_id as id
      2       , my_id as same_id
      3  from (select xxx_test_pkg.get_id(1) as my_id from dual where rownum=1),emp where rownum < 6;
            ID    SAME_ID
            22         22
            23         23
            23         23
            23         23
            23         23
    SQL> select my_id as id
      2       , my_id as same_id
      3  from (select /*+ MATERIALIZE */ xxx_test_pkg.get_id(1) as my_id from dual),emp where rownum < 6;
            ID    SAME_ID
            24         25
            26         27
            28         29
            30         31
            32         33
    SQL> with t as (select /*+ MATERIALIZE */ xxx_test_pkg.get_id(1) as my_id from dual)
      2  select my_id as id
      3       , my_id as same_id
      4  from t,emp where rownum < 6;
            ID    SAME_ID
            34         34
            34         34
            34         34
            34         34
            34         34
    SQL> SY.

  • Problems with Update Statement

    How Can I combine these three statements into one single statement.. Heard that I can use Decode command over here... But dont know whether that was correct or not..
    Appreciate ur help..
    UPDATE LOTIDS_FINAL SET TEAM = 'MLA' WHERE SUBSTR( EXPT,1) = 'A';
    UPDATE LOTIDS_FINAL SET TEAM = 'AMD' WHERE SUBSTR( EXPT,1) = 'D';
    UPDATE LOTIDS_FINAL SET TEAM = 'TMP' WHERE SUBSTR( EXPT,1) = 'G';
    I want these three statements to one statement which can reduce my full table scans from 3 times to 1 time (I think)

    Try this:
    UPDATE LOTIDS_FINAL
    SET TEAM = DECODE (SUBSTR( EXPT,1,1), 'A', 'MLA', 'D', 'AMD', 'G', 'TMP', TEAM)
    WHERE SUBSTR( EXPT,1,1) in ( 'A', 'D', 'G');

  • Help with dynamic statement returning values into collection

    Hi All
    I am trying to use dynamic statement to return values into a collection using the returning clause. However, I get an ORA-00933 error. Here is a simple setup:
    create table t(
        pk number,
        id_batch varchar2(30),
        date_created date,
        constraint t_pk primary key ( pk )
    create or replace type num_ntt is table of number;
    create or replace type vc2_ntt is table of varchar2(30);
    create or replace
    package pkg
    as
      type rec is record(
          pk        num_ntt,    
          id_batch  vc2_ntt
      procedure p(
          p_count in number,
          p_rt    out nocopy rec
    end pkg;
    create or replace
    package body pkg
    as
      procedure p(
          p_count in number,
          p_rt    out nocopy rec
      is
      begin
          execute immediate '
          insert into t
          select level, ''x'' || level, sysdate
          from   dual
          connect by level <= :p_count
          returning pk, id_batch into :pk, :id_batch'
          using p_count returning bulk collect into p_rt.pk, p_rt.id_batch;
      end p;
    end pkg;
    declare
      r  pkg.rec;
    begin
      pkg.p( 5, r );
    end;
    /

    sanjeevchauhan wrote:
    but I am working with dynamic statement and returning multiple fields into a collection.And using an INSERT...SELECT statement combined with a RETURNING INTO clause still does not work. Whether it's dynamic SQL or not: it doesn't work. The link describes a workaround.
    By the way, I don't see why you are using dynamic SQL here. Static SQL will do just fine. And so you can literally copy Adrian's setup.
    Regards,
    Rob.

  • Aggregate-collection-mapping combined with optimistic-locking

    I've tried to set up an aggregate-collection-mapping and everything seems to be okay. But one thing still lacks: use this aggregate-collection in combination with optimistic-locking. Defining to use optimistic-locking (exactly: timestamp locking) doesn't work. The generated sql-statement doesn't have the wanted timestamp field. Any idea is recommend.

    Hi,
    Aggregate collection mappings do support optimistic locking. You MUST map and store the version value in the object, not the cache. Aggregate objects are not cache independently of their parents so cannot store their version value in the cache.
    Make sure that you have:
    - provided a direc-to-field (non-readonly) mapping for the version field
    - define the locking policy to store the version value in the object, not the cache
    Example:
         descriptor.descriptorIsAggregateCollection();
         descriptor.useTimestampLocking("VERSION", false);
         // SECTION: DIRECTTOFIELDMAPPING
         DirectToFieldMapping directtofieldmapping3 = new DirectToFieldMapping();
         directtofieldmapping3.setAttributeName("version");
         directtofieldmapping3.setIsReadOnly(false );
         directtofieldmapping3.setFieldName("VERSION");
         descriptor.addMapping(directtofieldmapping3);

  • Custom JButton with different states, any ideas??

    Hey, hope you guys can help.
    What I want to do is to implement a custom JButton class with different states for the button. The button should have a "pressed" state, where the user has pressed it, and if the action triggered by this pressing gets approved, it should get selected. It will then get a different color and border.
    I will have several buttons of this type in one panel, and they can all have different states at any time.
    I do not want to use JToggleButton, as it is not the user that decides if it should be selected or not, but the logic "behind" (the dataflow).
    So I want like a combination of JButton and JToggleButton...
    How do I do this, any ideas, please?

    I am not to sure if this is the idea you have in mind but...
    This is something i have used before it is a tool bar. the button could be managed by another event it is an event listener at the moment.
    As well as update only a specified button rather than all?
    public class ToolBar extends JToolBar {
        public ToolBar(EventListener el) {
            this.setName("ToolBar");
            String[] imageFiles = { "Left.gif", "Relationgif", "Reload.gif", "TrafficRed.gif", "Home.gif", "Print.gif", "Help.gif" };
            String[] toolbarLabels = { "Entity", "Relationship", "Reload", "Stop", "Home", "Print", "Help" };
            Insets margins = new Insets(3, 3, 3, 3);
            for(int counter = 0; counter < toolbarLabels.length; counter++) {
                ToolBarButton button = new ToolBarButton(imageFiles[counter]);
                button.setToolTipText(toolbarLabels[counter]);
                button.setMargin(margins);
                button.setName(imageFiles[counter]);
                button.setVerticalTextPosition(BOTTOM);
                button.setHorizontalTextPosition(CENTER);
              //  button.setMnemonic(KeyStroke.VK_CAPS_LOCK);
                button.addActionListener(el);
                add(button);
        public void setTextLabels(boolean showLabels) {
            Component c;
            int i = 0;
            while((c = getComponentAtIndex(i++)) != null) {
                ToolBarButton button = (ToolBarButton)c;
                if (showLabels)
                    button.setText(button.getToolTipText());
                else
                    button.setText("");
    //each button on the tool bar is an object of this class
    public class ToolBarButton extends JButton {
        private static final Insets margins = new Insets(3, 3, 3, 3);
        //user selected to view tool bar as image only (default)
        public ToolBarButton(Icon icon) {
            super(icon);
            setMargin(margins);
        //user selected to view tool bar as text only
        public ToolBarButton(String iconName) {
            this(new ImageIcon(iconName));
        //user selected to view tool bar as image and text
        public ToolBarButton(String iconImage, String iconName) {
            this(new ImageIcon(iconImage));
            setText(iconName);
    }

  • Snapshot isolation in combination with service broker

    Hi all,
    I'm currently using the service broker in combination with snapshot isolation on the database.
    The notification request is executed under read commited isolation. The code looks like this:
    SqlDependency dependency = new SqlDependency(command, null, 0);
    dependency.OnChange += eventHandler;
    using (SqlConnection conn = new SqlConnection(connectionString))
    using (SqlTransaction tran = conn.BeginTransaction(IsolationLevel.ReadCommitted))
    command.Transaction = tran;
    command.ExecuteNonQuery();
    tran.Commit();
    The request is successfully created and works fine at the first glance.
    Now here is my problem:
    I created a notification request that should monitor two objects. The query (executed under read committed) looks something like this:
    SELECT Id, DataVersion FROM dbo.MyObjects WHERE Id = 1 OR Id = 2
    Afterwards I delete both objects in separate nested transactions. Both of them are running under snapshot isolation. It looks something like this:
    using (SqlConnection conn1 = new SqlConnection(connectionString))
    conn1.Open();
    using (SqlTransaction tran1 = connection1.BeginTransaction(IsolationLevel.Snapshot))
    using (SqlConnection conn2 = new SqlConnection(connectionString))
    conn2.Open();
    using (SqlTransaction tran2 = conn2.BeginTransaction(IsolationLevel.Snapshot))
    SqlCommand command2 = conn2.CreateCommand();
    command2.Transaction = tran2;
    command2.CommandText = "DELETE FROM MyObjects WHERE Id = 2";
    command2.ExecuteNonQuery();
    tran2.Commit();
    SqlCommand command1 = conn1.CreateCommand();
    command1.CommandText = "DELETE FROM MyObjects WHERE Id = 1";
    command1.Transaction = tran1;
    command1.ExecuteNonQuery();
    tran1.Commit(); //-> Conflict exception
    A conflict exception is raised during the commit of last transaction. The conflict seems to occur in the table "sys.query_notifcations_xxxxxxxxx". This is the exact message:
    An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
    Additional information: Snapshot isolation transaction aborted due to update conflict. You cannot use snapshot isolation to access table 'sys.query_notification_45295271' directly or indirectly in database 'MyDatabase' to update, delete,
    or insert the row that has been modified or deleted by another transaction. Retry the transaction or change the isolation level for the update/delete statement.
    Is there any restriction for the service broker that prohibits the usage of snapshot isolation.
    Thanks in advance.

    No, the error has nothing to do with Service Broker. Or for that matter, query notifications, which is the feature you are actually using. (Query notifications uses Service Broker, but Service Broker != Query notification.)
    You would get the same error if you had a trigger in MyObjects that tried to update the same row for both deletions. A snapshot transaction gives you a consistent view of the database in a certain point in time. Consider this situation:
    Snapshot transaction A that started at time T update a row R at time T2. Snapshot transaction B starts at time T1 updates the same row at time T3. Had they been regular non-snapshot transaction, transaction B would have been blocked already when it tried
    to read R, but snapshot transactions do not get blocked. But if B would be permitted to update R, the update from transaction A would be lost. Assume that the update is an incremental one, for instance updating cash balance for an account. You can see that
    this is not permittable.
    In your case, the row R happens to be a row in an internal table for query notifications, but it is the application design which is the problem. There is no obvious reason to use snapshot isolation in your example since you are only deleting. And there is
    even less reason to have two transactions and connections for the task.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Can Oracle be forced to use the spatial index for sdo_filter in combination with an or clause? Difference between Enterprise and SE?

    We’re seeing the following issue: sql - Can Oracle be forced to use the spatial index for sdo_filter in combination with an or clause? - Stack Overflow (posted by a colleague of mine) and are curious to know if this behaviour is due to a difference between standard and enterprise, or could we doing something else wrong in our DB config.?
    We have also reproduced the issue on the following stacks:
    Oracle SE One 11.2.0.3 (with Spatial enabled)
    Redhat Linux 2.6.32-358.6.2.el6.x86_64 #1 SMP Thu May 16 20:59:36 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
    11.2.0.3.0 Standard Edition and 11.2.0.4.0 Standard Edition (both with Spatial enabled)
    Microsoft Windows Server 2003R2 Standard x64 Edition
    However, the SQL works fine if we try it on Oracle 11.2.0.3.0 *Enterprise* Edition.
    Any help or advice would be much appreciated.
    Kindest Regards,
    Kevin

    In my experience sdo_filter ALWAYS uses the spatial index, so that's not the problem. Since you did not provide the explain plans, we can't say for sure but I think yhu is right: Standard Edition can't use the bitmap operations, and thus it'll take longer to combine the results of the two queries (because the optimizer will surely split this OR up in two parts, then combine them).
    BTW: when asking questions about queries here, it would be nice if you posted the queries here as well, so that we do not have to check another website in order to see what you are doing. Plus it will probably get you more answers, because not everyone can be bothered to click on that link. It would also have been nice if you had posted your own answer on the other post here as well, because my recommendation would have been to use union all - but since you already found that out for yourself my recommendation would have been a little late.

  • Satellite L650: Some combinations with the FN button do not work on W7x64

    Hello,
    System
    <h3>Satellite L650-1KU</h3>Part number
    <h3><span class="partNo">PSK1LE-01700MRU</h3>
    I have install Windows by myself - this laptop haven't any OS from factory.
    Installed Windows 7 x64, all drivers and utilites from Toshiba driver site for windows 7 x64 accessible for my laptop model.
    I have no any unknown devices in Windows Device manager, all drivers installed and all hardware components woks fine i.e. wifi or bluetooth or web camera.
    But I still can't use some of keyboard combinations with Fn button. Not all, just five combinations do not work: Fn+F2 power modes, Fn+F4 hibernate, Fn+1,2 zoom and Fn+F8 wirelles devices.
    From search I have found only mentions about Fn+1,2 zoom - this funtion provide some util named Toshiba Zoom but on download page no any Toshiba Zoom for my laptop model and W7.
    Looks like there must be installed some additional utils from vendor for handling this combinations but I cant find any additional info or soft on driver download page.
    May be there are some utils what shold be located in lists of drivers/soft for 32 bit windows and it will be fine for 64 bit one?
    All combinations which works fine like volume +- Fn+3 Fn+4 or mute Fn+ESC does not shows any popus at moment of pressing, just <span class="short_text"><span class="hps">perform <span class="hps">its <span class="hps">function <span class="hps">without any indication.
    Dear users and support, can you help me what I should install from additional utils to provide support for combinations Fn+F2 power modes, Fn+F4 hibernate Fn+1,2 zoom and Fn+F8 wirelles devices?
    Message was edited by: Gimli_r

    Have you installed the Toshiba Value Added Package?
    Have a look on the Toshiba support/downloads website. Ensure you install the Win7 64bit version of TVAP designed for the L650 series.
    Updating the BIOS may also help.

  • Problem with READ Statement in the field routine of the Transformation

    Hi,
    I have problem with read statement with binary search in the field routine of the transformation.
    read statement is working well when i was checked in the debugging mode, it's not working properly for the bulk load in the background. below are the steps i have implemented in my requirement.
    1. I selected the record from the lookuo DSO into one internal table for all entried in source_packeage.
    2.i have read same internal table in the field routine for each source_package entry and i am setting the flag for that field .
    Code in the start routine
    select source accno end_dt acctp from zcam_o11
    into table it_zcam
    for all entries in source_package
    where source = source_package-source
         and accno = source_package-accno.
    if sy-subrc = 0.
    delete it_zcam where acctp <> 3.
    delete it_zcam where end_dt initial.
    sort it_zcam by surce accno.
    endif.
    field routine code:
    read table it_zcam with key source = source_package-source
                                                 accno  = source_package-accno
                                                 binary search
                                                 transportin no fields.
    if sy-subrc = 0.
    RESULT  = 'Y'.
    else.
    RESULT = 'N'.
    endif.
    this piece of code exist in the other model there its working fine.when comes to my code it's not working properly, but when i debug the transformation it's working fine for those accno.
    the problem is when i do full load the code is not working properly and populating the wrong value in the RESULT field.
    this field i am using in the report filter.
    please let me know if anybody has the soluton or reason for this strage behaviour.
    thanks,
    Rahim.

    i suppose the below is not the actual code. active table of dso would be /bic/azcam_o1100...
    1. is the key of zcam_o11 source and accno ?
    2. you need to get the sortout of if endif (see code below)
    select source accno end_dt acctp from zcam_o11
    into table it_zcam
    for all entries in source_package
    where source = source_package-source
    and accno = source_package-accno.
    if sy-subrc = 0.
    delete it_zcam where acctp 3.
    delete it_zcam where end_dt initial.
    endif.
    sort it_zcam by surce accno.
    field routine code:
    read table it_zcam with key source = source_package-source
    accno = source_package-accno
    binary search
    transportin no fields.
    if sy-subrc = 0.
    RESULT = 'Y'.
    else.
    RESULT = 'N'.
    endif.

  • Some keys don't work in combination with Shift

    Okay  so I have the Pavilion Sleekbook  15-b011nr 
    Serial Number:   [Personal Information Removed]
    Product Number:   C6N92UA
    and today I noticed certain keys don't work in combination with the left Shift for example, Shift+S (both left and right), Shift+M, Shift+Z, Shift +X, Shift+C don't work, shift+F does work but gives me this FV. same with j it gives me JM instead. I installed an updated bios, ran a diagnostic test using F2 and under the compenant test for the keyboard it failed and gave me this
    keyboard test failed
    failure Id # U375BD-6m96P5-MFPX1F-G03B03 
    product id # C6N92Ua#aba
    now while trying to type all this I found other letters now working as well as me not being able to input the semicolon with either shift key. frustrating since I got this laptop in June so it's still under warranty. Has anyone else encountered this problem and if so how do i fix mine? I'm pretty tech savvy so feel free to let me know, or is my only option is a replacement from HP?
    Thanks!

    Hi hzapata, I know that it work fine, after Load preset, but why You lost the default configs?
    Is this my question to Smit.

Maybe you are looking for

  • Error message Hresult:0x8007054f when installing itunes 10.

    I am having trouble installing iTunes version 10. I keep receiving the error message Hresult:0x8007054f and I follow the process it recommends yet I seem to end up going round in circles. I have also read from previous answers to this problem on here

  • Mysterious red LED light inside my G4

    Could someone tell me what the red light means on the inside of my G4? It can't be seen from the outside. I am having a problem with my firewire ports not working. Is this a warning or alert of some kind? Help! I really looked and can't find this inf

  • Installing Boot Camp Update 3.3

    Hi. Currently, I've installed Boot Camp 3.0 on Windows 7 (32-bit) with my Snow Leopard installation disk. Would it be possible to upgrade straight to Boot Camp 3.3, or do I need to install updates 3.1 and 3.2 first? Thanks.

  • Oraview.vrf(0):File_NOT_FOUND

    I am installing oracle 8.0.5 on RH 6.1. I have installed the software without create database. After that I tried to create database through ./orainst, but I got message "oraview.vrf(0):FILE_NOT_FOUND while verifying oaview ( No such file or director

  • Days Before Password Expires

    Hi, Our customer would not like to make their users change ME login password. However, I don't know the valid range of "Days Before Password Expires" in system rule maintenance. Could anybody tell me the current specification? I wonder it maybe possi