Nvl logical equivalent

Hi,
I've got something like that in my query:
SELECT *
  FROM (SELECT   *
            FROM zzz_firmy nad
           WHERE NOT EXISTS (
                    SELECT 1
                      FROM zzz_firmy nzm
                     WHERE nzm.frm_nzm_id = nad.frm_nzm_id
                       AND NVL (nad.frm_audyt_dm, nad.frm_audyt_dt) >
                                      NVL (nzm.frm_audyt_dm, nzm.frm_audyt_dt))
             AND frm_audyt_st = '1'
             AND frm_nazwa LIKE :1
        ORDER BY NVL (frm_audyt_dm, frm_audyt_dt) DESC)
WHERE ROWNUM < 2;
Plan   
SELECT STATEMENT  CHOOSE Cost: 5,999,041  Bytes: 2,181  Cardinality: 1         
8 COUNT STOPKEY       
  7 VIEW XXXADMIN.    Cost: 5,999,041  Bytes: 39,992,997  Cardinality: 18,337        
   6 SORT ORDER BY STOPKEY      Cost: 39,516  Bytes: 4,180,836  Cardinality: 18,337    
    5 FILTER   
     2 TABLE ACCESS BY INDEX ROWID XXX.zzz_FIRMY       Cost: 38,884  Bytes: 4,180,836  Cardinality: 18,337    
      1 INDEX RANGE SCAN NON-UNIQUE XXX.NBI_FRM_NAZWA        Cost: 562  Cardinality: 72,982   
     4 TABLE ACCESS BY INDEX ROWID XXX.zzz_FIRMY       Cost: 325  Bytes: 720  Cardinality: 45         
      3 INDEX RANGE SCAN NON-UNIQUE XXX.NBI_FRM_FRM_NZM_FK        Cost: 6  Cardinality: 896   
How to improved that ?
Morover , what is logical equivalence of :
NVL (nad.frm_audyt_dm, nad.frm_audyt_dt) > NVL (nzm.frm_audyt_dm, nzm.frm_audyt_dt))
i think thats the problem indekses are not used.
Regards.
HR                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

user10388717 wrote:
Plan
SELECT STATEMENT CHOOSE Cost: 5,999,041 Bytes: 2,181 Cardinality: 1
8 COUNT STOPKEY
7 VIEW XXXADMIN. Cost: 5,999,041 Bytes: 39,992,997 Cardinality: 18,337
6 SORT ORDER BY STOPKEY Cost: 39,516 Bytes: 4,180,836 Cardinality: 18,337
5 FILTER
2 TABLE ACCESS BY INDEX ROWID XXX.zzz_FIRMY Cost: 38,884 Bytes: 4,180,836 Cardinality: 18,337
1 INDEX RANGE SCAN NON-UNIQUE XXX.NBI_FRM_NAZWA Cost: 562 Cardinality: 72,982
4 TABLE ACCESS BY INDEX ROWID XXX.zzz_FIRMY Cost: 325 Bytes: 720 Cardinality: 45
3 INDEX RANGE SCAN NON-UNIQUE XXX.NBI_FRM_FRM_NZM_FK Cost: 6 Cardinality: 896
i think thats the problem indekses are not used.The plan says indexes are being used. Are the cardinalities right out of each step?

Similar Messages

  • Logical equivalence of 2 queries

    Hi All,
    I dont know whether this is right question but I am not sure so putting it here.
    I have one query which I am trying to tune which I felt is doing unnecessary fetches and additional joins not required ( here I do nt know the backgrnd of this query like purpose etc. still given for tuning)
    Hence I rewritten same query which I feel is logical equivalent of the original query. Thus need your guidance.
    This is original query:
    WITH
    fi as (select feed_book_status.COB_DATE,
                feed_book_status.FEED_INSTANCE_ID,BOOK_ID , feed_id
                from feed_book_status, feed_instance
                where feed_book_status.cob_date = v_cob_date
                and feed_book_status.FEED_INSTANCE_ID=feed_instance.FEED_INSTANCE_ID
                AND FEED_BOOK_STATUS.COB_DATE= FEED_INSTANCE.COB_DATE
    p as (select book_id, feed_instance_id, position_id from position where feed_instance_id in
           (select feed_instance_id from fi)),
    s as (select book_id, position_id, feed_instance_id, type_id from sensitivity where feed_instance_id in
         (select feed_instance_id from fi))
    select
      fi.cob_date, fi.feed_id, p.book_id, s.type_id, count(s.book_id) Cnt
    from  fi
          inner join p  on p.feed_instance_id = fi.feed_instance_id and fi.book_id = p.book_id
          inner join s on p.feed_instance_id = s.feed_instance_id and p.position_id = s.position_id
    group by fi.cob_date, fi.feed_id, p.book_id, s.type_id;Execution plan
    | Id  | Operation                      | Name                        | Rows  | Bytes |TempSpc| Cost (%CPU)| Pstart| Pstop |
    |   0 | SELECT STATEMENT               |                             | 40730 |  4613K|       | 65255  (17)|       |       |
    |   1 |  TEMP TABLE TRANSFORMATION     |                             |       |       |       |            |       |       |
    |   2 |   LOAD AS SELECT               | SENSITIVITY                 |       |       |       |            |       |       |
    |*  3 |    HASH JOIN                   |                             |   240 |  9600 |       |    32   (7)|       |       |
    |   4 |     TABLE ACCESS BY INDEX ROWID| FEED_INSTANCE               |   238 |  4284 |       |    12   (0)|       |       |
    |*  5 |      INDEX RANGE SCAN          | IDX_FEED_INSTANCE_CD_MR     |   238 |       |       |     3   (0)|       |       |
    |*  6 |     INDEX RANGE SCAN           | IDX_FBS_CD_FII_BI           |  2981 | 65582 |       |    19   (6)|       |       |
    |   7 |   HASH GROUP BY                |                             | 40730 |  4613K|   138M| 65223  (17)|       |       |
    |*  8 |    HASH JOIN                   |                             |  1073K|   118M|  9848K| 57613  (18)|       |       |
    |*  9 |     HASH JOIN                  |                             |   113K|  8515K|       | 14875  (13)|       |       |
    |  10 |      VIEW                      |                             |   240 |  6720 |       |     2   (0)|       |       |
    |  11 |       TABLE ACCESS FULL        | SYS_TEMP_0FD9D6813_D59D2159 |   240 |  6720 |       |     2   (0)|       |       |
    |* 12 |      HASH JOIN                 |                             |  3854K|   180M|       | 14555  (11)|       |       |
    |  13 |       MERGE JOIN CARTESIAN     |                             |   240 |  2400 |       |   496   (3)|       |       |
    |  14 |        VIEW                    | VW_NSO_2                    |   240 |  1200 |       |     2   (0)|       |       |
    |  15 |         HASH UNIQUE            |                             |   240 |  3120 |       |            |       |       |
    |  16 |          VIEW                  |                             |   240 |  3120 |       |     2   (0)|       |       |
    |  17 |           TABLE ACCESS FULL    | SYS_TEMP_0FD9D6813_D59D2159 |   240 |  6720 |       |     2   (0)|       |       |
    |  18 |        BUFFER SORT             |                             |   240 |  1200 |       |     2 (-240|       |       |
    |  19 |         VIEW                   | VW_NSO_1                    |   240 |  1200 |       |     2   (0)|       |       |
    |  20 |          HASH UNIQUE           |                             |   240 |  3120 |       |            |       |       |
    |  21 |           VIEW                 |                             |   240 |  3120 |       |     2   (0)|       |       |
    |  22 |            TABLE ACCESS FULL   | SYS_TEMP_0FD9D6813_D59D2159 |   240 |  6720 |       |     2   (0)|       |       |
    |  23 |       PARTITION RANGE ALL      |                             |  3854K|   143M|       | 13741   (9)|     1 |   130 |
    |  24 |        TABLE ACCESS FULL       | POSITION                    |  3854K|   143M|       | 13741   (9)|     1 |   130 |
    |  25 |     PARTITION RANGE ALL        |                             |    18M|   691M|       | 21789  (22)|     1 |   130 |
    |  26 |      TABLE ACCESS FULL         | SENSITIVITY                 |    18M|   691M|       | 21789  (22)|     1 |   130 |
    Predicate Information (identified by operation id):
       3 - access("FEED_BOOK_STATUS"."FEED_INSTANCE_ID"="FEED_INSTANCE"."FEED_INSTANCE_ID" AND
                  "FEED_BOOK_STATUS"."COB_DATE"="FEED_INSTANCE"."COB_DATE")
       5 - access("FEED_INSTANCE"."COB_DATE"=TO_DATE(' 2010-10-12 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
       6 - access("FEED_BOOK_STATUS"."COB_DATE"=TO_DATE(' 2010-10-12 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
       8 - access("FEED_INSTANCE_ID"="FEED_INSTANCE_ID" AND "POSITION_ID"="POSITION_ID" AND
                  "FEED_INSTANCE_ID"="$nso_col_1")
       9 - access("FEED_INSTANCE_ID"="FI"."FEED_INSTANCE_ID" AND "FI"."BOOK_ID"="BOOK_ID")
      12 - access("FEED_INSTANCE_ID"="$nso_col_1")This one new query
    WITH
    fi as (select feed_book_status.COB_DATE,
                feed_book_status.FEED_INSTANCE_ID,BOOK_ID , feed_id
                from feed_book_status, feed_instance
                where feed_book_status.cob_date = '12-Oct-2010'
                and feed_book_status.FEED_INSTANCE_ID=feed_instance.FEED_INSTANCE_ID
                AND FEED_BOOK_STATUS.COB_DATE= FEED_INSTANCE.COB_DATE
    select  fi.cob_date, fi.feed_id, p.book_id, s.type_id, count(s.book_id) Cnt
    from  fi, position p, sensitivity s
    where p.feed_instance_id = fi.feed_instance_id
    and p.book_id= fi.book_id
    and p.feed_instance_id = s.feed_instance_id
    and p.position_id = s.position_id
    group by fi.cob_date, fi.feed_id, p.book_id, s.type_idExecution plan
    | Id  | Operation                              | Name                     | Rows  | Bytes | Cost (%CPU)| Pstart| Pstop |
    |   0 | SELECT STATEMENT                       |                          |   157 | 18526 |  1380  (14)|       |       |
    |   1 |  HASH GROUP BY                         |                          |   157 | 18526 |  1380  (14)|       |       |
    |*  2 |   TABLE ACCESS BY LOCAL INDEX ROWID    | SENSITIVITY              |  2276 | 88764 |     6   (0)|       |       |
    |   3 |    NESTED LOOPS                        |                          |   255K|    28M|  1209   (2)|       |       |
    |   4 |     NESTED LOOPS                       |                          |   112 |  8848 |   533   (3)|       |       |
    |*  5 |      HASH JOIN                         |                          |   240 |  9600 |    32   (7)|       |       |
    |   6 |       TABLE ACCESS BY INDEX ROWID      | FEED_INSTANCE            |   238 |  4284 |    12   (0)|       |       |
    |*  7 |        INDEX RANGE SCAN                | IDX_FEED_INSTANCE_CD_MR  |   238 |       |     3   (0)|       |       |
    |*  8 |       INDEX RANGE SCAN                 | IDX_FBS_CD_FII_BI        |  2981 | 65582 |    19   (6)|       |       |
    |   9 |      PARTITION RANGE ITERATOR          |                          |     1 |    39 |    14   (0)|   KEY |   KEY |
    |  10 |       TABLE ACCESS BY LOCAL INDEX ROWID| POSITION                 |     1 |    39 |    14   (0)|   KEY |   KEY |
    |* 11 |        INDEX RANGE SCAN                | IDX_RISK_POSITION_FII_BI |   172 |       |     2   (0)|   KEY |   KEY |
    |  12 |     PARTITION RANGE ITERATOR           |                          |     5 |       |     2   (0)|   KEY |   KEY |
    |* 13 |      INDEX RANGE SCAN                  | IDX_SENSITIVITY_RPI      |     5 |       |     2   (0)|   KEY |   KEY |
    Predicate Information (identified by operation id):
       2 - filter("P"."FEED_INSTANCE_ID"="S"."FEED_INSTANCE_ID")
       5 - access("FEED_BOOK_STATUS"."FEED_INSTANCE_ID"="FEED_INSTANCE"."FEED_INSTANCE_ID" AND
                  "FEED_BOOK_STATUS"."COB_DATE"="FEED_INSTANCE"."COB_DATE")
       7 - access("FEED_INSTANCE"."COB_DATE"=TO_DATE(' 2010-10-12 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
       8 - access("FEED_BOOK_STATUS"."COB_DATE"=TO_DATE(' 2010-10-12 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
      11 - access("P"."FEED_INSTANCE_ID"="FEED_BOOK_STATUS"."FEED_INSTANCE_ID" AND "P"."BOOK_ID"="BOOK_ID")
      13 - access("P"."POSITION_ID"="S"."POSITION_ID")This is Oracle version 10.2.
    Rgds,
    Aashish

    Aashish S. wrote:
    This is original query:
    WITH
    fi as (select feed_book_status.COB_DATE,
    feed_book_status.FEED_INSTANCE_ID,BOOK_ID , feed_id
    from feed_book_status, feed_instance
    where feed_book_status.cob_date = v_cob_date
    and feed_book_status.FEED_INSTANCE_ID=feed_instance.FEED_INSTANCE_ID
    AND FEED_BOOK_STATUS.COB_DATE= FEED_INSTANCE.COB_DATE
    p as (select book_id, feed_instance_id, position_id from position where feed_instance_id in
    (select feed_instance_id from fi)),
    s as (select book_id, position_id, feed_instance_id, type_id from sensitivity where feed_instance_id in
    (select feed_instance_id from fi))
    select
    fi.cob_date, fi.feed_id, p.book_id, s.type_id, count(s.book_id) Cnt
    from  fi
    inner join p  on p.feed_instance_id = fi.feed_instance_id and fi.book_id = p.book_id
    inner join s on p.feed_instance_id = s.feed_instance_id and p.position_id = s.position_id
    group by fi.cob_date, fi.feed_id, p.book_id, s.type_id;This one new query
    WITH
    fi as (select feed_book_status.COB_DATE,
    feed_book_status.FEED_INSTANCE_ID,BOOK_ID , feed_id
    from feed_book_status, feed_instance
    where feed_book_status.cob_date = '12-Oct-2010'
    and feed_book_status.FEED_INSTANCE_ID=feed_instance.FEED_INSTANCE_ID
    AND FEED_BOOK_STATUS.COB_DATE= FEED_INSTANCE.COB_DATE
    select  fi.cob_date, fi.feed_id, p.book_id, s.type_id, count(s.book_id) Cnt
    from  fi, position p, sensitivity s
    where p.feed_instance_id = fi.feed_instance_id
    and p.book_id= fi.book_id
    and p.feed_instance_id = s.feed_instance_id
    and p.position_id = s.position_id
    group by fi.cob_date, fi.feed_id, p.book_id, s.type_idExecution plan
    The two queries don't seem to be equivalent - take subquery P as an example:
    because of the IN subquery, every row in POSITION can appear no more than once in P, but when you turn the subquery into a join each row in POSITION may appear many times because there may be many row in FI with the same feed_instance_id.
    Part of you performance problem may relate to the fact that the optimizer suffers from a few defects when optimising code that uses subquery factoring ( http://jonathanlewis.wordpress.com/2010/09/13/subquery-factoring-4/ ) ; it also has problems with ANSI SQL.
    For testing purposes, I would try the following:
    Step 1 - copy the P and S subqueries inline and see how the plan changes. (My guess would be that Oracle would still do a temp table transformation and create a result set for for FI and use it three times - but it's possible that it would do something a little more sensible with POSITION and SENSITIVITY
    Step 2 - as step 1, but add the /*+ inline */ hint to the definition of FI to force Oracle to copy the code in-line rather than creating a temp table (assuming this hasn't happened in step 1)
    Step 3 - copy the FI code inline three times.
    Step 4a - assuming the rewrite performs well, document it, consider whether you want to make it look prettier and more understandable.
    Step 4b - assuming the rewrite doesn't perform weel, start thinking about logical equivalence. Watch out particularly for the implied "select distinct" from IN subqueries, and check what uniqueness constraints you have on the data. (It's possible that your rewrite is actually equivalent because of uniqueness constraints on the data that you havevn't told us about).
    Regards
    Jonathan Lewis

  • Logical Comparisons Of Wrappers

    Ok super easy question...so easy that it's not documented anywhere that I have searched so far...
    Is it proper to compare wrappers with logical operators (i.e. ==, !=)?
    Technically a wrapper is an object, so therefore the == operator would compare the memory address of the two objects to give you a boolean expression result. Meaning, this result is probably not the 'logically equivalent' result you were looking for. However, is it proper to compare a wrapper to a literal using these operators? For example...
    Integer i = new Integer(7);
    if (i == 7) {}or...
    if (i != 7) {}Is the wrapper implicitly cast? I have heard of something called autoboxing which says this might be the case, where the conversion from wrapper to primitive and vice versa is automated. Or, do I need to explicitly grab the int value from the wrapper for the comparison as such...
    if (i.intValue() == 7)or...
    if (i.intValue != 7)I have seen code in both forms in working applications. So which is correct, or more correct as the case may be? Is this something that is version specific? One question turned into many, sorry about that, but thanx for your responses. :D
    ~ Jester's Chef

    If you are using Java5.0 then you can use "if (i == 7)" because the compiler will handle getting the int vaule from i. (ie autoboxing)
    If you are using a version before Java5.0 you have to retrieve the int value from the Integer object and then do the comparison like "if (i.intValue() == 7)"
    So the answer depends on which version of Java you are using.

  • Hash Join Anti NA

    Another simple day at the office.....
    What was the case.
    A colleague approached me telling that he had two similar queries. One of them returning data, the other not.
    The "simplified" version of the two queries looked like:
    SELECT col1
      FROM tab1
    WHERE col1 NOT IN (SELECT col1 FROM tab2);This query returned no data, however he -and later on I also- was sure that there was a mismatch in the data, which should have returned rows.
    This was also proven/shown by the second query:
    SELECT col1
      FROM tab1
    WHERE NOT EXISTS
              (SELECT col1
                 FROM tab2
                WHERE tab1.col1 = tab2.col1);This query returned the expected difference. And this query does in fact the same as the first query!!
    Even when we hardcoded an extra WHERE clause, the result was the same. No rows for:
    SELECT *
      FROM tab1
    WHERE  tab1.col1 NOT IN (SELECT col1 FROM tab2)
           AND tab1.col1 = 'car';and the correct rows for:
    SELECT *
      FROM tab1
    WHERE     NOT EXISTS
                  (SELECT 1
                     FROM tab2
                    WHERE tab1.col1 = tab2.col1)
           AND tab1.col1 = 'car';After an hour searching, trying to reproduce the issue, I almost was about to give up and send it to Oracle Support qualifying it as a bug.
    However, there was one difference that I saw, that could be the cause of the problem.
    Allthough the statements are almost the same, the execution plan showed a slight difference. The execution plan for the NOT IN query looked like:
    Plan
    SELECT STATEMENT ALL_ROWS Cost: 5 Bytes: 808 Cardinality: 2
    3 HASH JOIN ANTI NA Cost: 5 Bytes: 808 Cardinality: 2
    1 TABLE ACCESS FULL TABLE PIM_KRG.TAB1 Cost: 2 Bytes: 606 Cardinality: 3
    2 TABLE ACCESS FULL TABLE PIM_KRG.TAB2 Cost: 2 Bytes: 404 Cardinality: 2 Whereas the execution plan of the query with the NOT EXISTS looked like:
    Plan
    SELECT STATEMENT ALL_ROWS Cost: 5 Bytes: 808 Cardinality: 2
    3 HASH JOIN ANTI Cost: 5 Bytes: 808 Cardinality: 2
    1 TABLE ACCESS FULL TABLE PIM_KRG.TAB1 Cost: 2 Bytes: 606 Cardinality: 3
    2 TABLE ACCESS FULL TABLE PIM_KRG.TAB2 Cost: 2 Bytes: 404 Cardinality: 2 See the difference?
    Not knowing what a "HASH JOIN ANTI NA" exactly was, I entered it as a search command into the knowledge base of My Oracle Support. Besides a couple of patch-set lists, I also found Document 1082123.1, which explains all about the HASH JOIN ANTI NULL_AWARE.
    In this document the behaviour we saw is explained, with the most important remark being:
    *'If t2.n2 contains NULLs,do not return any t1 rows and terminate'*
    And then it suddenly hit me as I was unable to reproduce the case using my own created test tables.
    In our case, it meant that if tab2.col1 would have contained any rows with a NULL value, the join between those two tables could not be made based on a "NOT IN" clause.
    The query would terminate without giving any results !!!
    And that is exactly what we saw.
    The query with the NOT EXISTS doesn't use a NULL_AWARE ANTI JOIN and therefore does return the results
    Also the mentioned workaround:
    alter session set "_optimizer_null_aware_antijoin" = false;seems not to work. Allthought the execution plan changes to:
    Plan
    SELECT STATEMENT ALL_ROWS Cost: 4 Bytes: 202 Cardinality: 1
    3 FILTER
    1 TABLE ACCESS FULL TABLE PIM_KRG.TAB1 Cost: 2 Bytes: 606 Cardinality: 3
    2 TABLE ACCESS FULL TABLE PIM_KRG.TAB2 Cost: 2 Bytes: 404 Cardinality: 2 it still returns no rows !!
    And Now??
    Since there is a document explaining the behaviour, I'm doubting if we can classify this as a bug. But in my opinion, if developers do not know about this strange behaviour, they will easily call it a bug.
    The "problem" is easily solved ( or worked around ) using the NOT EXISTS solution, or using NVL with the JOINed columns. However I would expect the optimizer to sort these things out himself.
    For anyone who wants to reproduce/investigate this case, I have listed my test-code.
    The database version we used was 11.1.0.7 on Windows 2008 R2. I'm sure the OS doesn't matter here.
    -- Create two tables, make sure they allow NULL values
    CREATE TABLE tab1 (col1 VARCHAR2 (100) NULL);
    CREATE TABLE tab2 (col1 VARCHAR2 (100) NULL);
    INSERT INTO tab1
    VALUES ('bike');
    INSERT INTO tab1
    VALUES ('car');
    INSERT INTO tab1
    VALUES (NULL);
    INSERT INTO tab2
    VALUES ('bike');
    INSERT INTO tab2
    VALUES (NULL);
    COMMIT;
    -- This query returns No results
    SELECT col1
      FROM tab1
    WHERE col1 NOT IN (SELECT col1 FROM tab2);
    -- This query return results
    SELECT col1
      FROM tab1
    WHERE NOT EXISTS
              (SELECT col1
                 FROM tab2
                WHERE tab1.col1 = tab2.col1);I've also written a blog entry with the above text at http://managingoracle.blogspot.com
    Anyone who has the real explanation for this behaviour as in why the HASH-JOIN ANTI terminates. Please elaborate
    Thanks
    Kind Regards
    FJFranken

    fjfranken wrote:
    SELECT col1
    FROM tab1
    WHERE col1 NOT IN (SELECT col1 FROM tab2);
    SELECT col1
    FROM tab1
    WHERE NOT EXISTS
    (SELECT col1
    FROM tab2
    WHERE tab1.col1 = tab2.col1);
    These two queries are NOT logically equivalent - if there are any rows in tab2 where col1 is null then the first query SHOULD return no rows.
    See http://jonathanlewis.wordpress.com/2007/02/25/not-in/ for an explanation of the difference between NOT EXISTS and NOT IN.
    >
    Anyone who has the real explanation for this behaviour as in why the HASH-JOIN ANTI terminates. Please elaborateThe purpose of the null-aware anti-join is to allow a NOT IN subquery that has to deal with the null problem run as an anti-join; historically it would HAVE to run as a FILTER SUBQUERY.
    Regards
    Jonathan Lewis

  • DECODE vs. CASE problem

    Hi, sorry to post what may end up being a very dumb question here. I'm trying to take a huge, complicated query that runs a ton of DECODE statements and turn it into something readible. However, I'm running in to a strange issue.
    To my mind, when I run the following query, columns A, B, and C should all return exactly the same values:
    SELECT userid,
         DECODE(MAX(last_committed_dt),NULL,MAX(launch_dt)+1,MAX(last_committed_dt))-(MIN(launch_dt)) A,
         NVL(MAX(last_committed_dt), MAX(launch_dt)+1) - MIN(launch_dt) B,
         CASE WHEN MAX(last_committed_dt) IS NOT NULL THEN MAX(last_committed_dt) ELSE MAX(launch_dt)+1 END - MIN(launch_dt) C
    FROM mytable ttJ
         left join mytable2 sa ON (ttJ.user_id = sa.user_id)
         left join mytable3 lh ON (lh.attempt_id = sa.attempt_id)
    GROUP BY user_id
    However, the results of this query show that B and C equal, but neither ties to A:
    USERID     A               B               C
    1134     +00 01:50:50.471849     +00 01:50:50.877240     +00 01:50:50.877240
    6716     +37 00:36:02.605919     +37 00:36:02.994966     +37 00:36:02.994966
    1118     +00 00:22:48.913212     +00 00:22:49.419523     +00 00:22:49.419523
    3111     +53 23:43:03.858221     +53 23:43:04.122084     +53 23:43:04.122084
    Could someone please help me understand the difference?
    Thanks!
    Scott

    To my mind, when I run the following query, columns A, B, and C should all return exactly the same values:Not entirely true:
    It might depend if some datatype conversions are going on. Following example shows that, though logically equivalent, different (datatype-) results are presented:
    SQL>  with t as
    (select to_timestamp('31.01.2007','dd.mm.yyyy') ts from dual)
    select dump(decode(ts,null,ts-1,ts)) t1,
           dump(nvl(ts,ts-1)) t2,
           dump(case when ts is null then ts-1 else ts end) t3
      from t
    T1                                  T2                                                           T3                                     
    Typ=13 Len=7: 215,7,1,31,0,0,0      Typ=187 Len=20: 215,7,1,31,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0   Typ=180 Len=7: 120,107,1,31,1,1,1  In particular notice that decode returns a DATE in contrast to the others where some timestamp variants are returned

  • REG:- SELECT STATEMENT IN IF CONDITION.

    HI FRIENDS,
    CAN V USE SELECT STATEMENT IN IF CONDITION LIKE....
    IF (SELECT COUNT(EMPID) FROM EMPLOPYEE) > 1 THEN
    UPDATE STATEMENT;
    END IF;
    PLEASE HELP.
    --RAJNISH                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Hi,
    1. Hit the Caps Lock key hard in your key board.
    2. Put your code between tags for better readability.
    3. When you have a where clause, why do you want to go for if clause? as in
    [code]
    update <your_table> set <your_col> = <your_new_val>
               where (select count(empid) from employee) > 1
    [/code]
    is logically equivalent to your
    [code]
    if (select count(empid) from employee) > 1 then
    update statement;
    end if;
    [/code]
    -Arun                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • DeMorgan's Theorem

    I couldn't find anything on google that explained DeMorgan''s Theorem clearly enough. Can someone tell me what it is and how it is used in java. Any explaination or links are good.

    if (! (q == null || q.isEmpty())) {
    }is logically equivalent to:
    if (q != null && ! q.isEmpty()) {
    }Moreover, even if your expression has side effects, the two statements still evaluate the same way...

  • How to fix the error CS0246 in VS 2015 preview CTP 6

    Hello,I'm newbie to VS and also c# programming.I wanted to create a Universal app for WINDOWS 10.So,I made a new new project in VS 2015 with windows 10 UAP blank template.I designed my app and when I tried to build it,I got the error CS0246.I don't know
    how to fix this,but for sure i'm expecting a fix for this from you.Here's the script which is automatically generated by VS.
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Runtime.InteropServices.WindowsRuntime;
    using Windows.ApplicationModel;
    using Windows.ApplicationModel.Activation;
    using Windows.Foundation;
    using Windows.Foundation.Collections;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Controls.Primitives;
    using Windows.UI.Xaml.Data;
    using Windows.UI.Xaml.Input;
    using Windows.UI.Xaml.Media;
    using Windows.UI.Xaml.Media.Animation;
    using Windows.UI.Xaml.Navigation;
    // The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=402347&clcid=0x409
    namespace RubixSolveIt
    /// <summary>
    /// Provides application-specific behavior to supplement the default Application class.
    /// </summary>
    public sealed partial class App : Application
    /// <summary>
    /// Allows tracking page views, exceptions and other telemetry through the Microsoft Application Insights service.
    /// </summary>
    public TelemetryClient TelemetryClient = new TelemetryClient();
    /// <summary>
    /// Initializes the singleton application object. This is the first line of authored code
    /// executed, and as such is the logical equivalent of main() or WinMain().
    /// </summary>
    public App()
    this.InitializeComponent();
    this.Suspending += OnSuspending;
    /// <summary>
    /// Invoked when the application is launched normally by the end user. Other entry points
    /// will be used such as when the application is launched to open a specific file.
    /// </summary>
    /// <param name="e">Details about the launch request and process.</param>
    protected override void OnLaunched(LaunchActivatedEventArgs e)
    #if DEBUG
    if (System.Diagnostics.Debugger.IsAttached)
    this.DebugSettings.EnableFrameRateCounter = true;
    #endif
    Frame rootFrame = Window.Current.Content as Frame;
    // Do not repeat app initialization when the Window already has content,
    // just ensure that the window is active
    if (rootFrame == null)
    // Create a Frame to act as the navigation context and navigate to the first page
    rootFrame = new Frame();
    // Set the default language
    rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];
    rootFrame.NavigationFailed += OnNavigationFailed;
    if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
    //TODO: Load state from previously suspended application
    // Place the frame in the current Window
    Window.Current.Content = rootFrame;
    if (rootFrame.Content == null)
    // When the navigation stack isn't restored navigate to the first page,
    // configuring the new page by passing required information as a navigation
    // parameter
    rootFrame.Navigate(typeof(MainPage), e.Arguments);
    // Ensure the current window is active
    Window.Current.Activate();
    /// <summary>
    /// Invoked when Navigation to a certain page fails
    /// </summary>
    /// <param name="sender">The Frame which failed navigation</param>
    /// <param name="e">Details about the navigation failure</param>
    void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
    throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
    /// <summary>
    /// Invoked when application execution is being suspended. Application state is saved
    /// without knowing whether the application will be terminated or resumed with the contents
    /// of memory still intact.
    /// </summary>
    /// <param name="sender">The source of the suspend request.</param>
    /// <param name="e">Details about the suspend request.</param>
    private void OnSuspending(object sender, SuspendingEventArgs e)
    var deferral = e.SuspendingOperation.GetDeferral();
    //TODO: Save application state and stop any background activity
    deferral.Complete();
    please any one help me to fix this and please explain it if you can,because I'm a newbie to C#.Thanks in advance

    Both packets are supplied to get a preview of the packets, they are both not created to start building solutions.
    Any solution given here on your question can lead to misunderstandings in feature. If you have to report a problem, then use the Microsoft Connect side. Be aware it is not to help with problems, but for reporting real not yet mentioned bugs.
    http://connect.microsoft.com/
    Success
    Cor

  • Problem Checking if File Exists When App is Launched

    I'm developing an app which checks a file "lastuser.txt" to determine which database to open, as sometimes people share phones. Anyway, I'm trying to call  TryGetItemAsync() in the OnLaunched() section in App.xaml.cs but I get the message
    "The name 'TryGetItemAsync' does not exist in the current context".  I am new to C# and phone app development. Any help would be greatly appreciated. Below is my code:
    tia
    CS
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using SQLite;
    using System.Runtime.InteropServices.WindowsRuntime;
    using Windows.Storage;
    using System.Threading.Tasks;
    using System.Diagnostics;
    using Windows.ApplicationModel;
    using Windows.ApplicationModel.Activation;
    using Windows.Foundation;
    using Windows.Foundation.Collections;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Controls.Primitives;
    using Windows.UI.Xaml.Data;
    using Windows.UI.Xaml.Input;
    using Windows.UI.Xaml.Media;
    using Windows.UI.Xaml.Media.Animation;
    using Windows.UI.Xaml.Navigation;
    // The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=391641
    namespace BP_Alert
    /// <summary>
    /// Provides application-specific behavior to supplement the default Application class.
    /// </summary>
    public sealed partial class App : Application
    public static string DBPath = string.Empty;
    public static string LastUser = string.Empty;
    public static DateTime Time_Taken { get; set; }
    private TransitionCollection transitions;
    /// <summary>
    /// Initializes the singleton application object. This is the first line of authored code
    /// executed, and as such is the logical equivalent of main() or WinMain().
    /// </summary>
    public App()
    this.InitializeComponent();
    this.Suspending += this.OnSuspending;
    /// <summary>
    /// Invoked when the application is launched normally by the end user. Other entry points
    /// will be used when the application is launched to open a specific file, to display
    /// search results, and so forth.
    /// </summary>
    /// <param name="e">Details about the launch request and process.</param>
    protected async override void OnLaunched(LaunchActivatedEventArgs e)
    #if DEBUG
    if (System.Diagnostics.Debugger.IsAttached)
    this.DebugSettings.EnableFrameRateCounter = true;
    #endif
    Frame rootFrame = Window.Current.Content as Frame;
    // Do not repeat app initialization when the Window already has content,
    // just ensure that the window is active
    if (rootFrame == null)
    // Create a Frame to act as the navigation context and navigate to the first page
    rootFrame = new Frame();
    // TODO: change this value to a cache size that is appropriate for your application
    rootFrame.CacheSize = 1;
    if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
    // TODO: Load state from previously suspended application
    DBPath = Windows.Storage.ApplicationData.Current.LocalFolder.Path;
    LastUser = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path,"LastUser.txt");
    bool result = await TryGetItemAsync(LastUser); <--Error!!!!!!!!!!!!!!!
    // Place the frame in the current Window
    Window.Current.Content = rootFrame;

    It seems that TryGetItemAsync is a method on a StorageFolder, so you will need to do something like:
    myStorageFolder.TryGetItemAsync(LastUser);
    See here:
    https://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.storagefolder.trygetitemasync.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
    If you go to that link and scroll down to the bottom of the page, it says:
    Minimum supported phone
    None supported

  • Removing the CORRECT iTunes files from a hard drive

    Help! Does anyone have any idea how to remove the old iTunes files. I want to delete them to free up space on my computer. I tried to move my library from this computer to a laptop. See below. I went through all the steps to move my iTunes library using my iPod. It didn't work. So now I have 2 versions of my iTunes library. I am afraid to delete the wrong one. I think it's just great(not) that iTunes will tell one how to "do something" but no one at Apple can tell one me how to undo it. This is an excerpt from "How to use your Ipod to move music to a new computer:
    Click OK. Note: Clicking OK will cause iTunes to copy all of your music files to another location on your computer. You will need to manually remove the files from their previous locations if you are concerned about space_. If your computer does not have enough hard-drive space this process will not work correctly. Please speak to your computer manufacturer or Microsoft for more information on how to obtain more space to perform this action.

    I downloaded audio files from a CD to an external
    hard drive. Now I would like to put those files in
    Itunes. I tried click and drag and cut and paste, no
    luck.
    What EXACTLY do you mean by you "downloaded" the files?
    Did you transcode them into a form iTunes knows about? (e.g., MP3)
    If you ripped them to MP3 or other compatible file format you should hust be able to drag and drop them onto the Music portion of your iTunes display. I do this hundreds of times a day - it's the logical equivalent of Add File or Add Folder to Library.

  • Re: (forte-users) Minimal Fusion

    Thomas,
    A response which may contain no answers...and may lead to more questions...
    As a novice fusion user, one of the largest obstacles to using Fusion is the lack of XML API's in an application, be it a customer's in-house or vendor's software product. Corresponding to this is simply the lack of any API's in the application. As Forte (abet Sun, now iPlanet) says in their training manual 'A nontrivial task is to build new adapters for your programs if you wish to enable them to interact using XML documents over HTTP'. This is probably an understatement.
    The question that come to mind is:
    Does the warehouse have published API's their product?
    If not, then, IMHO, you have steep hill to climb, not the least being communication, cooperation, and coordination from the warehouse vendor (another one of those 'nontrivial tasks') in trying to create the required API's
    if so, then it is a matter of building an adapter, in a language that is compatible with the warehouse's API (hopefully C or some derivation of) , that contains (1) a DOM (Document Object Module) to API Translator, (2) an XML Parser (converts XML to DOM and visa-versa) , and (3) a HTTP server (again, another one of those 'nontrivial tasks').
    Forte (abet Sun, now iPlanet) suggests, and I would concur (with reservations), that if you haven't done this before you should probably hire their services from the Forte Integration Services group. Their costs (admittible high) should be offset be the time it would take to develop one on your own. A side benefit is working with them, you learn the process for making other adapters in the future. If Fusion is a marketing success, then the benefits should out weigh the costs.
    The Forte Integration Services group markets, or will market, a Fusion Adapter Designer, some sort of a SDK, which assists in the creation of Adapters. I do not know the availability of that product at this time.
    As to your question "Is it reasonable to consider doing this project under Fusion as a
    getting-feet-wet experience?" If you (or your customer) can afford the costs, and the warehouse has published API's, I would say that you gotta get-your-feet-wet somehow. If the warehouse doesn't have published API's and are not willing to put forth the effort and resources to do so, I would say your chances of success are considerably less.
    In any case, IMHO, it will be a 'non trivial' undertaking.
    -later
    -labeaux
    "Thomas Mercer-Hursh, Ph.D." <thomascintegrity.com> 10/31/00 04:49PM >>>This may be one of those questions which has no answer, but ...
    Our long term plan is to develop XML APIs to each of the modules in our
    suite of non-Forte applications and to integrate these under Fusion, thus
    gaining Conductor management of the inter-module work flows and a cleaner
    loose coupling of the applications along with other benefits such as the
    ease of integration with other packages, a clean way to migrate to Forte
    modules, and an ease of interconnecting "mini-applications" to address
    specific customer needs.
    I have an existing customer who has made a decision to migrate to a third
    party warehouse from an in-house warehouse. I.e., were this transition to
    the new structure complete, this would correspond to unhooking some of our
    modules and replacing these with an adapter to the corresponding modules in
    the third party warehouse.
    In fact, as it looks now, I will need to build the logical equivalent of
    these APIs anyway -- might as well do it in XML, right? And these APIs
    will communicate with a daemon responsible for the message traffic to and
    from. I tried to get this traffic to be XML and to use MQSeries or JMS as
    the transport, but the folks at the warehouse end don't seem to be able to
    handle such things, so I am stuck doing something fairly stupid for the
    actual communication.
    So, the question for those out there who have already paid their Fusion
    dues, is it reasonable to consider doing this project under Fusion as a
    getting-feet-wet experience. There are only half a dozen APIs to do and I
    have to do those anyway and am inclined to make them XML regardless. There
    will be one communication daemon to which all these connect and the
    business processes originally implemented in Conductor will basically be
    just point to point connects, except for routing traffic from the daemon to
    the right API based on message type. That's really all I need it to do,
    i.e., far too simple to actually need Fusion, but a possible opportunity
    to get started and then to expand to other uses.
    Crazy?
    =========================================================================
    Thomas Mercer-Hursh, Ph.D email: thomascintegrity.com
    Computing Integrity, Inc. sales: 510-233-9329
    550 Casey Drive - Cypress Point support: 510-233-9327
    Point Richmond, CA 94801-3751 fax: 510-233-6950
    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

    At 07:55 AM 11/1/00, Labeaux Schiek wrote:
    As a novice fusion user, one of the largest obstacles to using Fusion is
    the lack of XML API's in an application, be it a customer's in-house or
    vendor's software product.In this case, the good news is that one of the applications in question is
    our own, so whipping up an XML API to suit each required transaction on
    that side is no more, probably less, work than importing or exporting a
    flat file or whatever. Moreover, my current expectation of how this
    interaction will work is something like this:
    </pre>
    ---Fusion------
    | |
    WACS<-->WACS_Daemon<----VPN socket
    connection---->IS_Daemon I/S
    </pre>
    I.e., I/S, our application, and the IS_Daemon which handles the connection
    traffic across the internet link are both mine. For I/S, I will create XML
    APIs to suit. For the IS_daemon, I might use the transform facilities to
    convert this XML to the pipe-delimited format they are expected at the
    other end and make the daemon a simple manager of the connection or, the
    daemon could do the conversion, but the former seems like the more
    appropriate approach. The API between the two daemons is something we are
    defining now (unfortunately I lost the argument to make that XML).
    Corresponding to this is simply the lack of any API's in the
    application. As Forte (abet Sun, now iPlanet) says in their training
    manual 'A nontrivial task is to build new adapters for your programs if
    you wish to enable them to interact using XML documents over HTTP'.My neophyte understanding is that, since I am defining the API to I/S in
    the diagram above and I can make this XML, then the adapter issue
    disappears there. I might have to create an adapter for the daemon, but if
    necessary, I could make that the same XML on a pass through and do the
    translation in the daemon.
    If not, then, IMHO, you have steep hill to climb, not the least being
    communication, cooperation, and coordination from the warehouse vendor
    (another one of those 'nontrivial tasks') in trying to create the required
    API'sWe are well through this process anyway. ... which is not to say that it
    has been or will be easy, but it must be done whether I use Fusion or
    not. Given that the vote has gone in favor of simple messages of
    pipe-delimited records, i.e., basically flat file, the technical issues
    there are minimal.
    if so, then it is a matter of building an adapter, in a language that is
    compatible with the warehouse's API (hopefully C or some derivation of) ,
    that contains (1) a DOM (Document Object Module) to API Translator, (2)
    an XML Parser (converts XML to DOM and visa-versa) , and (3) a HTTP server
    (again, another one of those 'nontrivial tasks').I'm not sure I quite understand what you are saying here. The HTTP part
    won't be there since we will apparently be connecting via a VPN sockets
    connection. But, how are you distinguishing DOM and XML since DOM is a
    particular form of XML? The XML API I build for I/S will be DOM compliant.
    Forte (abet Sun, now iPlanet) suggests, and I would concur (with
    reservations), that if you haven't done this before you should probably
    hire their services from the Forte Integration Services group. Their
    costs (admittible high) should be offset be the time it would take to
    develop one on your own. A side benefit is working with them, you learn
    the process for making other adapters in the future. If Fusion is a
    marketing success, then the benefits should out weigh the costs.I am familiar with the "party" line. If I were building a complete
    interface to another major product (I/S is roughly equivalent to JDEC in
    coverage) in the context of an EAI project, I would happily invite them in
    and hope to pick up pointers. Here, though, there are only 8 or 9 total
    transaction types and either all of the interfaces are XML, i.e., no
    adapter required as I understand it, or only the daemon will need an
    adapter and that will be a choice I can make depending on how things
    go. One does wish it were possible to sample a small piece of that
    knowledge store without having to buy the whole thing, though.
    The Forte Integration Services group markets, or will market, a Fusion
    Adapter Designer, some sort of a SDK, which assists in the creation of
    Adapters. I do not know the availability of that product at this time.Last I checked, one couldn't get this without the consulting ... hence the
    last sentence above.
    Thanks for your input.
    =========================================================================
    Thomas Mercer-Hursh, Ph.D email: thomascintegrity.com
    Computing Integrity, Inc. sales: 510-233-9329
    550 Casey Drive - Cypress Point support: 510-233-9327
    Point Richmond, CA 94801-3751 fax: 510-233-6950

  • Transfering files from a hard drive into Itunes

    I downloaded audio files from a CD to an external hard drive. Now I would like to put those files in Itunes. I tried click and drag and cut and paste, no luck.
    Please help
    Thank you in advance
    Faust575

    I downloaded audio files from a CD to an external
    hard drive. Now I would like to put those files in
    Itunes. I tried click and drag and cut and paste, no
    luck.
    What EXACTLY do you mean by you "downloaded" the files?
    Did you transcode them into a form iTunes knows about? (e.g., MP3)
    If you ripped them to MP3 or other compatible file format you should hust be able to drag and drop them onto the Music portion of your iTunes display. I do this hundreds of times a day - it's the logical equivalent of Add File or Add Folder to Library.

  • Field != then Insert Into Other Table

    Hi,
    I cannot figure out how to create a trigger that will insert data based on if a old.field != new.field. If the field was changed in
    one table tbl_test then insert that record into the other table tbl_test_history. This is a little different since I want to insert a record if a update
    took place. The update will still take place in tbl_test but I want a insert to take place in tbl_test_history.
    CREATE OR REPLACE TRIGGER AU_INSERT_TEST_HISTORY
      AFTER UPDATE
      ON TBL_TEST   FOR EACH ROW
    WHEN (
        OLD.Orange != NEW.Orange
    OR OLD.Apple != NEW.Apple
    BEGIN
    INSERT INTO TBL_TEST_HISTORY
    (ORANGE,
      APPLE
      BANANA,
      GRAPE
      select ORANGE,
             APPLE
             BANANA,
             GRAPE
    FROM TBL_TEST, TBL_TEST_HISTORY
      WHERE  TBL_TEST.PK_TEST_ID = TBL_TEST_HISTORY.PK_TEST_ID;
    END AU_INSERT_TEST_HISTORY;
    /I will have a separate trigger that will insert records from tbl_test to tbl_test_history. This trigger compiles with no errors but when I
    create a record in tbl_test I receive an error. I am not sure if the syntax is correct, can anyone help me with this?

    My bad. I put the colon : into the when clause. They weren't there in your code. Usually I use an if condition, which is a little different.
    I added some NVL logic to to consider comparison of NULL values too.
    CREATE OR REPLACE TRIGGER AU_INSERT_TEST_HISTORY
      AFTER UPDATE  ON TBL_TEST  
      FOR EACH ROW
    BEGIN
      if nvl(:old.ORANGE,'xxx') != nvl(:new.ORANGE,'yyy')
         OR nvl(:old.APPLE,'xxx') != nvl(:new.APPLE,'yyy')
      then
        INSERT INTO TBL_TEST_HISTORY
         (ORANGE, APPLE, BANANA, GRAPE)
        values (:new.ORANGE,
                 :new.APPLE,
                 :new.BANANA,
                 :new.GRAPE);
      end if;
    END AU_INSERT_TEST_HISTORY;
    / You can additionally consider to make this trigger an AFTER INSERT OR UPDATE trigger.
    Then you would also put the inserted values from the start into your history table.
    Edited by: Sven W. on Aug 9, 2012 4:14 PM

  • Cast to timestamp

    Hello,
    OBIEE 11.1.1 answers question.
    To recover full date time accuracy from a number of date / time elements I have concatenated up date / time elements to give me a full char version of a timestamp, however when I try to convert it to a timestamp to perform a calculation on it I get a general error, even though when I convert a timestamp to a char I see an identical date / time string in the format dd/mm/yyyy hh:mi:ss i.e. 31/01/2011 15:32:26
    I have also tried switching the char datestring around to yyyymmdd.
    Does anyone know the secret, the code examples from the manuals just do not work for timestamp as they say they should, i.e. you cannot cast a date directly to stamp, but you can cast it via a char to timestamp....
    A simple example of converting a literal to a timestamp (including hours / minutes / seconds) would be ideal here.
    And yes, I know this would be best created in the repository not in analytics.
    many thanks,
    Robert.

    Okay, I have answered my question, the timestamp format seems to be; -
    cast( '31-DEC-01010203' as timestamp)
    Where this would equate to the 31st December 2001 01:02:03 (just after 2 minutes past 1 in the morning).
    But...
    Still my function bombs when I feed concatenated values into it, even though when I look at the results for the filter applied all of them - pre casting to timestamp - conform to my "format mask" above.
    Does this mean that even though all of my values evaluate properly the function is being applied to ALL values before any (independent) filters are applied??
    Is there anyway to gracefully handle these kind of cast errors - the logical equivalent of; -
    on error (cast("my folder"."my character date" as timestamp) then cast('01-DEC-51000001' as timestamp)
    thanks for any pointers on this, appreciated.
    Robert.

  • How to add sql lite winrt

    I am Beginner winrt and sql lite ,  I am creating app that Customer table
    I want how to add data to the Table, edit the data, delete selected data, and delete all
    Please help me Any One
    Here code maybe wrong please right code provide me
    using SQLite;
    namespace MVVM.Models
        public class Customer
            [PrimaryKey, AutoIncrement]
            public int Id { get; set; }
            public string Name { get; set; }
            public string City { get; set; }
            public string Contact { get; set; }
    /////  Relay Command
    /// <summary>
        /// A command whose sole purpose is to relay its functionality
        /// to other objects by invoking delegates.
        /// The default return value for the CanExecute method is 'true'.
        /// <see cref="RaiseCanExecuteChanged"/> needs to be called whenever
        /// <see cref="CanExecute"/> is expected to return a different value.
        /// </summary>
        public class RelayCommand : ICommand
            private readonly Action _execute;
            private readonly Func<bool> _canExecute;
            /// <summary>
            /// Raised when RaiseCanExecuteChanged is called.
            /// </summary>
            public event EventHandler CanExecuteChanged;
            /// <summary>
            /// Creates a new command that can always execute.
            /// </summary>
            /// <param name="execute">The execution logic.</param>
            public RelayCommand(Action execute)
                : this(execute, null)
            /// <summary>
            /// Creates a new command.
            /// </summary>
            /// <param name="execute">The execution logic.</param>
            /// <param name="canExecute">The execution status logic.</param>
            public RelayCommand(Action execute, Func<bool> canExecute)
                if (execute == null)
                    throw new ArgumentNullException("execute");
                _execute = execute;
                _canExecute = canExecute;
            /// <summary>
            /// Determines whether this <see cref="RelayCommand"/> can execute in its current state.
            /// </summary>
            /// <param name="parameter">
            /// Data used by the command. If the command does not require data to be passed, this object can be set to null.
            /// </param>
            /// <returns>true if this command can be executed; otherwise, false.</returns>
            public bool CanExecute(object parameter)
                return _canExecute == null ? true : _canExecute();
            /// <summary>
            /// Executes the <see cref="RelayCommand"/> on the current command target.
            /// </summary>
            /// <param name="parameter">
            /// Data used by the command. If the command does not require data to be passed, this object can be set to null.
            /// </param>
            public void Execute(object parameter)
                _execute();
            /// <summary>
            /// Method used to raise the <see cref="CanExecuteChanged"/> event
            /// to indicate that the return value of the <see cref="CanExecute"/>
            /// method has changed.
            /// </summary>
            public void RaiseCanExecuteChanged()
                var handler = CanExecuteChanged;
                if (handler != null)
                    handler(this, EventArgs.Empty);
    /// ViewModel Base
    class ViewModelBase
            public event PropertyChangedEventHandler PropertyChanged;
            protected virtual void RaisePropertyChanged(string propertyName)
                var handler = this.PropertyChanged;
                if (handler != null)
                    handler(this, new PropertyChangedEventArgs(propertyName));
    ///MainPageViewModel
    class MainPageViewModel : ViewModelBase
            #region Properties
            private int id = 0;
            public int Id
                get
                { return id; }
                set
                    if (id == value)
                    { return; }
                    id = value;
                    RaisePropertyChanged("Id");
            private string name = string.Empty;
            public string Name
                get
                { return name; }
                set
                    if (name == value)
                    { return; }
                    name = value;
                    isDirty = true;
                    RaisePropertyChanged("Name");
            private string city = string.Empty;
            public string City
                get
                { return city; }
                set
                    if (city == value)
                    { return; }
                    city = value;
                    isDirty = true;
                    RaisePropertyChanged("City");
            private string contact = string.Empty;
            public string Contact
                get
                { return contact; }
                set
                    if (contact == value)
                    { return; }
                    contact = value;
                    isDirty = true;
                    RaisePropertyChanged("Contact");
            private bool isDirty = false;
            public bool IsDirty
                get
                    return isDirty;
                set
                    isDirty = value;
                    RaisePropertyChanged("IsDirty");
            #endregion "Properties"
            public ObservableCollection<Customer> _customerlist { get; set; }
     public Person CustomerToAdd { get; set; }
            /// <summary>
            /// Add Customer data to the table
            /// </summary>
            public RelayCommand AddCusomerCommand { get; set; }
            private void addCustomer()
            /// <summary>
            /// Delete Selected Customer data from the table
            /// </summary>
            public RelayCommand DeleteSelectedCustomerCommand { get; set; }
            private void deleteSelectedCustomer()
            /// <summary>
            /// edit Selected Customer data from the table
            /// </summary>
            public RelayCommand EditSelectedCustomerCommand { get; set; }
            private void editSelectedCustomer()
            /// <summary>
            /// Delete All Customer data from the table
            /// </summary>
            public RelayCommand DeleteAllCustomerCommand { get; set; }
            private void deleteAll()
            public MainPageViewModel()
                AddCusomerCommand = new RelayCommand(addCustomer);
                DeleteAllCustomerCommand = new RelayCommand(deleteAll);
                EditSelectedCustomerCommand = new RelayCommand(editSelectedCustomer);
                DeleteSelectedCustomerCommand = new RelayCommand(deleteSelectedCustomer);
    /////////// App.Xaml.Cs
    sealed partial class App : Application
            /// <summary>
            /// Initializes the singleton application object.  This is the first line of authored code
            /// executed, and as such is the logical equivalent of main() or WinMain().
            /// </summary>
            public App()
                this.InitializeComponent();
                this.Suspending += OnSuspending;
            /// <summary>
            /// Invoked when the application is launched normally by the end user.  Other entry points
            /// will be used such as when the application is launched to open a specific file.
            /// </summary>
            /// <param name="e">Details about the launch request and process.</param>
            protected override void OnLaunched(LaunchActivatedEventArgs e)
    #if DEBUG
                if (System.Diagnostics.Debugger.IsAttached)
                    this.DebugSettings.EnableFrameRateCounter = true;
    #endif
                Frame rootFrame = Window.Current.Content as Frame;
                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (rootFrame == null)
                    // Create a Frame to act as the navigation context and navigate to the first page
                    rootFrame = new Frame();
                    // Set the default language
                    rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];
                    rootFrame.NavigationFailed += OnNavigationFailed;
                    if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                        //TODO: Load state from previously suspended application
                    // Place the frame in the current Window
                    Window.Current.Content = rootFrame;
                var dbpath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path,"data.db3");
                using (var db = new SQLite.SQLiteConnection(dbpath))
                    // Create the tables if they don't exist
                    db.CreateTable<Customer>();
                    db.Commit();
                    db.Dispose();
                    db.Close();
                if (rootFrame.Content == null)
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MVVM.Views.Page1), e.Arguments);
                // Ensure the current window is active
                Window.Current.Activate();
            /// <summary>
            /// Invoked when Navigation to a certain page fails
            /// </summary>
            /// <param name="sender">The Frame which failed navigation</param>
            /// <param name="e">Details about the navigation failure</param>
            void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
                throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
            /// <summary>
            /// Invoked when application execution is being suspended.  Application state is saved
            /// without knowing whether the application will be terminated or resumed with the contents
            /// of memory still intact.
            /// </summary>
            /// <param name="sender">The source of the suspend request.</param>
            /// <param name="e">Details about the suspend request.</param>
            private void OnSuspending(object sender, SuspendingEventArgs e)
                var deferral = e.SuspendingOperation.GetDeferral();
                //TODO: Save application state and stop any background activity
                deferral.Complete();
    /// xaml Code
    <Page.DataContext>
            <ViewModels:MainPageViewModel>
            </ViewModels:MainPageViewModel>
        </Page.DataContext>
        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <ListView ItemsSource="{Binding _customerlist}"
                      HorizontalAlignment="Left" Margin="44,65,0,327" Width="456">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Width="400" Background="Chocolate">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Name}" FontSize="30" />
                                <TextBlock Text="," FontSize="30" />
                                <TextBlock Text="{Binding City }" FontSize="30" />
                            </StackPanel>
                            <TextBlock Text="{Binding Contact}" FontSize="30" />
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
            <Button Command="{Binding  AddCustomerCommand}"
              Content="Add person"
              FontSize="40" Margin="588,465,0,230"/>
            <Button Command="{Binding EditSelectedCustomerCommand}"
              Content="Edit"
              FontSize="40" Margin="865,465,0,230"/>
            <Button Command="{Binding DeleteSelectedCustomerCommand}"
                    Content="Delete"
                    FontSize="40" Margin="1037,465,0,230" />
            <Button Command="{Binding DeleteAllCustomerCommand }"
                    Content="Delete All"
                    FontSize="40" Margin="979,619,0,76" />
            <TextBlock Text="Name" FontSize="30" Margin="633,65,598,640" Height="63"/>
            <TextBox DataContext="{Binding PersonToAdd}" Text="{Binding Name, Mode=TwoWay}"
                     FontSize="30" Margin="868,62,80,640"/>
            <TextBlock Text="City " FontSize="30" Margin="633,181,551,524"/>
            <TextBox DataContext="{Binding PersonToAdd}" Text="{Binding City, Mode=TwoWay}"
                     FontSize="30" Margin="868,181,80,525"/>
            <TextBlock Text="Age" FontSize="30" Margin="633,296,536,400"/>
            <TextBox DataContext="{Binding PersonToAdd}" Text="{Binding Contact, Mode=TwoWay}"
                     FontSize="30" Margin="868,296,80,403"/>
        </Grid>

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wpf
    The above fourm use MVVM and they can help you there.

Maybe you are looking for

  • Installing Windows 8 on macbook air

    Hi! I'm planning to buy a macbookair 256 ssd next week for simple photo and video editing (for personal use) and I want to install windows 8 on it because I use coreldraw x7at work. How much partition should I give to Windows? evenif corel is the onl

  • Fastest way to call web service in same ear?

    I have a generic web service handler that I've deployed with a web-services.xml file. I don't have a schema or wsdl. I'm going to have a servlet that will recieve legacy messages (not SOAP format) and build a SOAP message from that. I will then need

  • Stock Transport

    Because when i want transfer stock from unrestricted stock to project stock between two stock in the same company code I must insert in material master in the field SBDKZ the value 2(collective requirement). I can transfer stock without valorize the

  • How to configure additional action

    Hi, How to Configure additional action in a system where only  one action is allowed for an employee in same day in IT0000, and what is the purpose of IT0302. it will be helpful if any one shares the steps. Thank you Srihari

  • ResultSetMetaData -- unsupported methods

    Hi, I'm trying to find out why Oracle does not provide support for some of the methods in ResultSetMetaData. I have tried with various jdbc drivers but no results (even though Oracle says their drivers fully support jdbc). Specifically I'm looking to