Query with nulls and multiple columns

I need help with structuring a query. I have the following table:
REGION |     AREA
1     | A
1     |      B
1     |      C
1     |      D
1     |      (null)
(null)     | A
(null)     |      B
(null)     |      C
(null)     |      A
2     |      A
2     |      (null)
I need to get the results:
REGION |     AREA
1     |      (null)
(null)     | A
(null)     |      B
(null)     |      C
2     |      (null)
So really - all the regions that have a null "AREA" and all the Areas with a null "REGION" that are unique. I can do this with two separate statements but I'd like to be able to do it in one query if possible.

user9179751 wrote:
I need help with structuring a query. I have the following table:
REGION |     AREA
1     | A
1     |      B
1     |      C
1     |      D
1     |      (null)
(null)     | A
(null)     |      B
(null)     |      C
(null)     |      A
2     |      A
2     |      (null)
I need to get the results:
REGION |     AREA
1     |      (null)
(null)     | A
(null)     |      B
(null)     |      C
2     |      (null)
So really - all the regions that have a null "AREA" and all the Areas with a null "REGION" that are unique. I can do this with two separate statements but I'd like to be able to do it in one query if possible.SELECT REGION, AREA FROM TABLE1 WHERE REGION IS NULL OR AREA IS NULL;

Similar Messages

  • CAML Query with 10 AND conditions

    Hello,
    I need some help with a CAML query. This particular query needs to have 10 AND conditions. Quite frankly, with all the nesting it is driving me a little nuts:
    What I have is:
    <Query>
    <Where>
    <And>
    <And>
    <And>
    <And>
    <And>
    <And>
    <And>
    <And>
    <And>
    <Eq><FieldRef Name='Column1' LookupId='TRUE' /><Value Type='Text'>10341</Value></Eq>
    <Eq><FieldRef Name='Column2' LookupId='TRUE' /><Value Type='Text'>9539</Value></Eq>
    </And>
    <Eq><FieldRef Name='Column3' LookupId='TRUE' /><Value Type='Text'>183</Value></Eq>
    </And>
    <Eq><FieldRef Name='Column4' LookupId='TRUE' /><Value Type='Text'>35</Value></Eq>
    </And>
    <IsNull><FieldRef Name='Column5' /></IsNull>
    </And>
    <Eq><FieldRef Name='Column6' LookupId='TRUE' /><Value Type='Text'>4387</Value></Eq>
    </And>
    <Eq><FieldRef Name='Column7' LookupId='TRUE' /><Value Type='Text'>4204</Value></Eq>
    </And>
    <Eq><FieldRef Name='Column8' LookupId='TRUE' /><Value Type='Text'>36</Value></Eq>
    </And>
    <Eq><FieldRef Name='Column9' LookupId='TRUE' /><Value Type='Text'>213</Value></Eq>
    </And>
    <IsNull><FieldRef Name='Column10' /></IsNull>
    </And>
    </Where>
    </Query>
    I have added this into my ItemAdding Event Receiver as it will basically do a check for duplicate items based on the 10 columns. 
    If anyone can help guide me in this, it would be much appreciated. I have been using a CAML Query Builder to help.

    http://webcache.googleusercontent.com/search?q=cache:xji7jOxa5_EJ:aasai-sharepoint.blogspot.com/2013/02/caml-query-with-multiple-conditions.html+&cd=3&hl=en&ct=clnk&gl=in
    http://stackoverflow.com/questions/6203821/caml-query-with-nested-ands-and-ors-for-multiple-fields
    Since you are not allowed to put more than two conditions in one condition group (And | Or) you have to create an extra nested group (MSDN). The expression
    A AND B AND C looks like this:
    <And>
    A
    <And>
    B
    C
    </And>
    </And>
    Your SQL like sample translated to CAML (hopefully with matching XML tags ;) ):
    <Where>
    <And>
    <Or>
    <Eq>
    <FieldRef Name='FirstName' />
    <Value Type='Text'>John</Value>
    </Eq>
    <Or>
    <Eq>
    <FieldRef Name='LastName' />
    <Value Type='Text'>John</Value>
    </Eq>
    <Eq>
    <FieldRef Name='Profile' />
    <Value Type='Text'>John</Value>
    </Eq>
    </Or>
    </Or>
    <And>
    <Or>
    <Eq>
    <FieldRef Name='FirstName' />
    <Value Type='Text'>Doe</Value>
    </Eq>
    <Or>
    <Eq>
    <FieldRef Name='LastName' />
    <Value Type='Text'>Doe</Value>
    </Eq>
    <Eq>
    <FieldRef Name='Profile' />
    <Value Type='Text'>Doe</Value>
    </Eq>
    </Or>
    If this helped you resolve your issue, please mark it Answered

  • Sql query with conditions and calculations???

    Hi,
    how I can build a query with conditions and calculations?
    E.g. I've got this table
    Start          | End     |     Working Place     |     Mandatory
    01-JAN-13 | 11-JAN-13 |     Office           |          1
    14-JAN-13 | 25-JAN-13 |     Home Office      |     0
    04-MRZ-13| 15-MRZ-13 |     Office           |          0
    11-FEB-13 | 22-FEB-13 |     Office           |          1
    Now if column working place=Office and column mandatory=0
    the new column "price" has to calculate: (End-Start)* $25.00
    and if working place=Office and column mandatory=1
    the "price" column has to calculate: (End-Start)* $20.60
    else $0.00
    I tried it with the case statement but I didn't know how
    to calculate my values and display it to the virtual column "price".
    Something like
    case
    when Working_Place = 'Office' and Mandatory=1
         then ...
    else '0.00'
    end as PRICE
    Or is it not possible?
    Edited by: DB2000 on 12.03.2013 05:09

    Use CASE:
    select  start_dt,
            end_dt,
            working_place,
            mandatory,
            case
              when working_place = 'Office' and mandatory = 0 then (end_dt - start_dt) * 25
              when working_place = 'Office' and mandatory = 1 then (end_dt - start_dt) * 20.60
              else 0
            end price
      from  tbl
    START_DT  END_DT    WORKING_PLA  MANDATORY      PRICE
    01-JAN-13 11-JAN-13 Office               1        206
    14-JAN-13 25-JAN-13 Home Office          0          0
    04-MAR-13 15-MAR-13 Office               0        275
    11-FEB-13 22-FEB-13 Office               1      226.6
    SQL> SY.

  • Wrong result for query with like and %

    I have a strange problem with query with like and %.
    When I run this script:
    ALTER SESSION SET NLS_SORT = 'BINARY_CI';
    ALTER SESSION SET NLS_COMP = 'LINGUISTIC';
    -- SELECT * FROM NLS_SESSION_PARAMETERS;
    -- drop table test1;
    CREATE TABLE TEST1(K1 NVARCHAR2(80));
    INSERT INTO TEST1 VALUES ('gsdk');
    INSERT INTO TEST1 VALUES ('ąxyz');
    INSERT INTO TEST1 VALUES ('ŁFa');
    INSERT INTO TEST1 VALUES ('ła');
    INSERT INTO TEST1 VALUES ('Śab');
    INSERT INTO TEST1 VALUES ('Śrrrb');
    commit;
    select * from TEST1 where k1 like N'Ł%';
    I get this:
    K1
    ŁFa
    ła
    Śab <- WRONG
    Śrrrb <- WRONG
    4 rows selected
    When i change datatype to varchar2 this code work correct.
    Is this a bug or what ?
    The execution plan:
    PLAN_TABLE_OUTPUT
    SQL_ID d3d64aupz4bb5, child number 2
    select * from TEST1 where k1 like N'Ł%'
    Plan hash value: 4122059633
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | | | 2 (100)| |
    |* 1 | TABLE ACCESS FULL| TEST1 | 1 | 82 | 2 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    1 - filter((NLSSORT("K1",'nls_sort=''BINARY_CI''')>=HEXTORAW('014200'
    ) AND NLSSORT("K1",'nls_sort=''BINARY_CI''')<HEXTORAW('01610100') ))
    Note
    - dynamic sampling used for this statement (level=2)

    DATABASE NLS CONFIGURATION:
    NLS_CHARACTERSET AL32UTF8
    NLS_NCHAR_CHARACTERSET     AL16UTF16
    NLS_COMP     BINARY
    NLS_SORT     BINARY
    Oracle version 11.2.0.2.0

  • Need complex query  with joins and AGGREGATE  functions.

    Hello Everyone ;
    Good Morning to all ;
    I have 3 tables with 2 lakhs record. I need to check query performance.. How CBO rewrites my query in materialized view ?
    I want to make complex join with AGGREGATE FUNCTION.
    my table details
    SQL> select from tab;*
    TNAME TABTYPE CLUSTERID
    DEPT TABLE
    PAYROLL TABLE
    EMP TABLE
    SQL> desc emp
    Name
    EID
    ENAME
    EDOB
    EGENDER
    EQUAL
    EGRADUATION
    EDESIGNATION
    ELEVEL
    EDOMAIN_ID
    EMOB_NO
    SQL> desc dept
    Name
    EID
    DNAME
    DMANAGER
    DCONTACT_NO
    DPROJ_NAME
    SQL> desc payroll
    Name
    EID
    PF_NO
    SAL_ACC_NO
    SALARY
    BONUS
    I want to make  complex query  with joins and AGGREGATE  functions.
    Dept names are : IT , ITES , Accounts , Mgmt , Hr
    GRADUATIONS are : Engineering , Arts , Accounts , business_applications
    I want to select records who are working in IT and ITES and graduation should be "Engineering"
    salary > 20000 and < = 22800 and bonus > 1000 and <= 1999 with count for males and females Separately ;
    Please help me to make a such complex query with joins ..
    Thanks in advance ..
    Edited by: 969352 on May 25, 2013 11:34 AM

    969352 wrote:
    why do you avoid providing requested & NEEDED details?I do NOT understand what do you expect ?
    My Goal is :
    1. When executing my own query i need to check expalin plan.please proceed to do so
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_9010.htm#SQLRF01601
    2. IF i enable query rewrite option .. i want to check explain plan ( how optimizer rewrites my query ) ? please proceed to do so
    http://docs.oracle.com/cd/E11882_01/server.112/e16638/ex_plan.htm#PFGRF009
    3. My only aim is QUERY PERFORMANCE with QUERY REWRITE clause in materialized view.It is an admirable goal.
    Best Wishes on your quest for performance improvements.

  • The issue with using the multiple columns sub-query in WHERE clause

    Hi All,
    my database version is 10.2.
    the problem i am trying to deal with is that when I use multiple column sub-query in the WHERE clause of the SELECT statement, the actual row number returned from the sub-query is different from the whole statement.
    And what I found is that, whenever there is NULL in any of those columns returned from the SUB-QUERY, the outer query will just return NULL for that whole row.
    Here is an example:
    select empno, ename, job, mgr, hiredate, sal, deptno from EMP
    intersect
    select empno, ename, job,  mgr, hiredate, sal, deptno from t;
    7782     CLARK     MANAGER     7839     09-JUN-81     2450     10
    7839     KING     PRESIDENT  NULL  17-NOV-81     5000     10
    7934     MILLER     CLERK     7782     23-JAN-82     1300     10
    select * from EMP where (EMPNO, ENAME, job, MGR, HIREDATE, SAL, DEPTNO) in (
    select empno, ename, job, mgr, hiredate, sal, deptno from EMP
    intersect
    select empno, ename, job,  mgr, hiredate, sal, deptno from t);
    7782     CLARK     MANAGER     7839     09-JUN-81     2450          10     
    7934     MILLER     CLERK     7782     23-JAN-82     1300          10     If I specifically deal with the NULL situations for the columns which might return NULL, I can get the result right.
    select * from EMP where (EMPNO, ENAME, job, NVL(MGR,-1), HIREDATE, SAL, DEPTNO) in (
    select empno, ename, job, nvl(mgr,-1), hiredate, sal, deptno from EMP
    intersect
    select empno, ename, job,  nvl(mgr,-1), hiredate, sal, deptno from t);
    7782     CLARK     MANAGER     7839     09-JUN-81     2450          10     
    7839     KING     PRESIDENT  null   17-NOV-81     5000          10     
    7934     MILLER     CLERK     7782     23-JAN-82     1300          10     the problem is that, I feel this is a very lame way of handling it.
    So, I wonder or am asking if there is any better or standard way to do it?
    any help would be highly appreciated.
    Thanks

    Hi,
    As you discovered, INTERSECT treats NULL as a value, but IN does not.
    What you did with NVL is one way to handle the situation. If there was a chance that any of the columns could be NULL, then you might prefer something like this:
    select      *
    from      EMP
    where      ( EMPNO      || '~' ||
           ENAME      || '~' ||
           job           || '~' ||
           MGR           || '~' ||
           TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')
                    || '~' ||
           SAL           || '~' ||
           DEPTNO
         ) in (
              select  EMPNO      || '~' ||
                     ENAME      || '~' ||
                   job     || '~' ||
                   MGR     || '~' ||
                   TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')               
                        || '~' ||
                   SAL      || '~' ||
                   DEPTNO
              from     emp
             intersect
              select  EMPNO      || '~' ||
                     ENAME      || '~' ||
                   job     || '~' ||
                   MGR     || '~' ||
                   TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')               
                        || '~' ||
                   SAL      || '~' ||
                   DEPTNO
              from      t
             );This assumes that you can identify some string (I used '~') that never occurs in the strings in these tables.
    This is implicitly converting the NUMBERs. That's usually not a good thing to do. but explicitly converting them would make this even more tedious.
    You should explicitly convert any DATEs to strings, however. Depending on your default format, and your data, you might get away with implicit conversions even for DATEs, but don't bet on it.
    If you had to do this often, you might consider writing a user-defined function:
    delimited_string (empno, ename, job, mgr, hiredate, sal, deptno) would return a string like
    '7839~KING~PRESIDENT~~17-NOV-1981~5000~10'
    This will make the coding easier, but beware: it will make the execution slower.

  • How to write the below query with parameter and is null

    Hi, I need to retrive the data if the parameter is passed on the field, else retrive all records whose field is null
    Example
    CREATE TABLE DEPT
           (DEPTNO NUMBER(2),
            DNAME VARCHAR2(14),
            LOC VARCHAR2(13) );
    INSERT INTO DEPT VALUES (10, 'ACCOUNTING', 'NEW YORK');
    INSERT INTO DEPT VALUES (20, 'RESEARCH',   'DALLAS');
    insert into dept values (30, 'SALES',      'CHICAGO');
    INSERT INTO DEPT VALUES (40, 'OPERATIONS', 'BOSTON');
    alter table dept add(object_id number);
    insert into dept values (50, 'OPERATIONS', 'BOSTON',1);
    insert into dept values (60, 'OPERATIONS', 'BOSTON',1);
    INSERT INTO DEPT VALUES (70, 'OPERATIONS', 'BOSTON',2);
    select * from dept where object_id =:p_object_id
    If i pass the object_id as 1 , it shloud retrive the values of dept with object_id 1, but if i dont pass the object_id, it should retrive all the records whose object_id is null
    IF 1 is passed, as object id , it should retrive, 50, 60, if 1 is not passed as object_id it should retive 10,20,30,40
    It works fine for me seperately as,
    select * from dept where object_id =:p_object_id -- 1
    select * from dept where object_id is null;
    Is this possible to do in single query.
    Thanks

    SELECT *
    FROM dept
    WHERE object_id = :p_object_id
    OR (object_id is null and :p_object_id is null)
    is one approach.  It's a bit verbose but the meaning is clear.  If you can identify a value that would never appear in the data (-1 for example)
    WHERE nvl( object_id, -1 ) = nvl(p_object_id, -1 );
    Justin

  • Creating table with null and not null values.

    I have to create a table with 5 Null nd 5 Not Null fields.My questionis which fields are place first?Not or Not Null and why???

    What you mean is: the person who asked you the question thought the order of columns was important, and wanted to see if you agreed. Or maybe they were just asking the question to see whether you thought it was important (as a test of your understanding of the database).
    When I started out in Oracle I was told that it was good practice to have the mandatory columns first and then the optional columns. But if you do some research you find this: the impact of column ordering on space management is: empty nullable columns at the end of the table take up zero bytes whereas empty nullable columns at the middle of the table take up one byte each. I think if that saving really is important to you you need to spring for an additional hard drive.
    Besides, even if you do organise your columns as you suggest, what happens when you add an eleventh NOT NULL column to your table? It gets tacked on to the end of your table. Your whole neat organisation is blown.
    What does still matter is the positioning of large VARCHAR2 columns: they should be the last columns on your table in case they create chaining. Then any query that doesn't need the large columns can be satisfied without reading the chained block, something that can't be guaranteed if you've got columns after a VARCHAR2(4000) column. This doesn't apply to CLOBs, etc. which are stored separately anyway.
    Cheers, APC

  • Need help in optimizing the query with joins and group by clause

    I am having problem in executing the query below.. it is taking lot of time. To simplify, I have added the two tables FILE_STATUS = stores the file load details and COMM table that is actual business commission table showing records successfully processed and which records were transmitted to other system. Records with status = T is trasnmitted to other system and traansactions with P is pending.
    CREATE TABLE FILE_STATUS
    (FILE_ID VARCHAR2(14),
    FILE_NAME VARCHAR2(20),
    CARR_CD VARCHAR2(5),
    TOT_REC NUMBER,
    TOT_SUCC NUMBER);
    CREATE TABLE COMM
    (SRC_FILE_ID VARCHAR2(14),
    REC_ID NUMBER,
    STATUS CHAR(1));
    INSERT INTO FILE_STATUS VALUES ('12345678', 'CM_LIBM.TXT', 'LIBM', 5, 4);
    INSERT INTO FILE_STATUS VALUES ('12345679', 'CM_HIPNT.TXT', 'HIPNT', 4, 0);
    INSERT INTO COMM VALUES ('12345678', 1, 'T');
    INSERT INTO COMM VALUES ('12345678', 3, 'T');
    INSERT INTO COMM VALUES ('12345678', 4, 'P');
    INSERT INTO COMM VALUES ('12345678', 5, 'P');
    COMMIT;Here is the query that I wrote to give me the details of the file that has been loaded into the system. It reads the file status and commission table to show file name, total records loaded, total records successfully loaded to the commission table and number of records that has been finally transmitted (status=T) to other systems.
    SELECT
        FS.CARR_CD
        ,FS.FILE_NAME
        ,FS.FILE_ID
        ,FS.TOT_REC
        ,FS.TOT_SUCC
        ,NVL(C.TOT_TRANS, 0) TOT_TRANS
    FROM FILE_STATUS FS
    LEFT JOIN
        SELECT SRC_FILE_ID, COUNT(*) TOT_TRANS
        FROM COMM
        WHERE STATUS = 'T'
        GROUP BY SRC_FILE_ID
    ) C ON C.SRC_FILE_ID = FS.FILE_ID
    WHERE FILE_ID = '12345678';In production this query has more joins and is taking lot of time to process.. the main culprit for me is the join on COMM table to get the count of number of transactions transmitted. Please can you give me tips to optimize this query to get results faster? Do I need to remove group and use partition or something else. Please help!

    I get 2 rows if I use my query with your new criteria. Did you commit the record if you are using a second connection to query? Did you remove the criteria for file_id?
    select carr_cd, file_name, file_id, tot_rec, tot_succ, tot_trans
      from (select fs.carr_cd,
                   fs.file_name,
                   fs.file_id,
                   fs.tot_rec,
                   fs.tot_succ,
                   count(case
                            when c.status = 'T' then
                             1
                            else
                             null
                          end) over(partition by c.src_file_id) tot_trans,
                   row_number() over(partition by c.src_file_id order by null) rn
              from file_status fs
              left join comm c
                on c.src_file_id = fs.file_id
             where carr_cd = 'LIBM')
    where rn = 1;
    CARR_CD FILE_NAME            FILE_ID           TOT_REC   TOT_SUCC  TOT_TRANS
    LIBM    CM_LIBM.TXT          12345678                5          4          2
    LIBM    CM_LIBM.TXT          12345677               10          0          0Using RANK can potentially produce multiple rows to be returned though your data may prevent this. ROW_NUMBER will always prevent duplicates. The ordering of the analytical function is irrelevant in your query if you use ROW_NUMBER. You can remove the outermost query and inspect the data returned by the inner query;
    select fs.carr_cd,
           fs.file_name,
           fs.file_id,
           fs.tot_rec,
           fs.tot_succ,
           count(case
                    when c.status = 'T' then
                     1
                    else
                     null
                  end) over(partition by c.src_file_id) tot_trans,
           row_number() over(partition by c.src_file_id order by null) rn
    from file_status fs
    left join comm c
    on c.src_file_id = fs.file_id
    where carr_cd = 'LIBM';
    CARR_CD FILE_NAME            FILE_ID           TOT_REC   TOT_SUCC  TOT_TRANS         RN
    LIBM    CM_LIBM.TXT          12345678                5          4          2          1
    LIBM    CM_LIBM.TXT          12345678                5          4          2          2
    LIBM    CM_LIBM.TXT          12345678                5          4          2          3
    LIBM    CM_LIBM.TXT          12345678                5          4          2          4
    LIBM    CM_LIBM.TXT          12345677               10          0          0          1

  • Problem with JDBC and VARCHAR-Columns

    Hi,
    i have a problem handling VARCHAR-Columns via JDBC.
    I.e. by using the JDBC-components of <SunONE Community Edition Update 1> any attempt to store any other then numeric values (like "0", "01", "999" etc.) in a column of type VARCHAR results in an error.
    After entering the string "test" in a JTextArea or JTextField (which is linked by its document to the  VARCHAR-column) i will receive:
    "java.lang.NumberFormatException: For input string: "st"/For input string: "st". I also tried the javax.sql. rowSet methods like updateString() with the same result.
    Are there any knwon issues corresponding to this behaviour?
    <b>Configuration details:</b>
    <i>JDBC-Driver:</i>
    package com.sap.dbtech.jdbc, MaxDB JDBC Driver, MySQL MaxDB, 7.5.1 Build 000-000-002-750 on Java 1.4.2
    <i>Database-version:</i>
    7.5.00.16 on WindowsXP Pro SP1
    <i>JRE:</i>
    1.4.1_02
    The <i>trace-file</i> only show this statements:
    [email protected] (UPDATE NOTARZTEINSATZPROTOKOLL_1 SET NEUROLOGISCHER_ERSTBEFUND = ? WHERE NAP_ID = ? AND EP_ID = ? AND BEMERKUNG IS NULL AND SOZ_ID IS NULL AND PSYZ_ID IS NULL AND ERSTBEFUND_ZEITPUNKT IS NULL AND GCSAO_ID_EB IS NULL AND GCSBVR_ID_EB IS NULL AND GCSBMR_ID_ARMLINKS_EB IS NULL AND GCSBMR_ID_ARMRECHTS_EB IS NULL AND GCSBMR_ID_BEINLINKS_EB IS NULL AND GCSBMR_ID_BEINRECHTS_EB IS NULL AND BWSL_ID_EB IS NULL AND EXTB_ID_ARMLINKS_EB IS NULL AND EXTB_ID_ARMRECHTS_EB IS NULL AND EXTB_ID_BEINLINKS_EB IS NULL AND EXTB_ID_BEINRECHTS_EB IS NULL AND PUPW_ID_LINKS_EB IS NULL AND PUPW_ID_RECHTS_EB IS NULL AND EJN_ID_FEHLTLICHTR_LI_EB IS NULL AND EJN_ID_FEHLTLICHTR_RE_EB IS NULL AND EJN_ID_MENINGISMUS_EB IS NULL AND NEUROLOGISCHER_ERSTBEFUND IS NULL AND TEMPERATUR_EB IS NULL AND RR_SYSTOLISCH_EB IS NULL AND RR_DIASTOLISCH_EB IS NULL AND HERZFREQUENZ_EB IS NULL AND EJN_ID_HF_REGELM_EB IS NULL AND BLUTZUCKER_EB IS NULL AND ATEMFREQUENZ_EB IS NULL AND SPO2_EB IS NULL AND CO2_EB IS NULL AND SCHM_ID_EB IS NULL AND ERH_ID_COR_EB IS NULL AND EELS_ID_COR_EB IS NULL AND EJN_ID_EKG_EMENTKOPPEL_EB IS NULL AND EERBST_ID_COR_EB IS NULL AND EHA_ID_COR_EB IS NULL AND ESVES_ID_COR_EB IS NULL AND EVES_ID_COR_EB IS NULL AND EKG_BEMERKUNG_EB IS NULL AND ATRH_ID_EB IS NULL AND EJN_ID_ZYANOSE_EB IS NULL AND EJN_ID_SPASTIK_EB IS NULL AND EJN_ID_RASSELGER_EB IS NULL AND EJN_ID_STRIDOR_EB IS NULL AND EJN_ID_VERLEGATEMW_EB IS NULL AND BEAM_ID_UEBERNAHME IS NULL AND ATMUNG_FREITEXT_EB IS NULL AND VERLM_ID IS NULL AND SCHWV_ID_SCHAEDELHIRN IS NULL AND SCHWV_ID_GESICHT IS NULL AND SCHWV_ID_HWS IS NULL AND SCHWV_ID_THORAX IS NULL AND SCHWV_ID_ABDOMEN IS NULL AND SCHWV_ID_BWSLWS IS NULL AND SCHWV_ID_BECKEN IS NULL AND SCHWV_ID_OEXTREMITAET IS NULL AND SCHWV_ID_UEXTREMITAET IS NULL AND SCHWV_ID_WEICHTEILE IS NULL AND VBRT_ID IS NULL AND TRT_ID IS NULL AND UHG_ID IS NULL AND SICHTK_ID IS NULL AND UNFALLZEITPUNKT IS NULL AND SAPS_2 IS NULL AND TISS_28 IS NULL AND NACA_ID IS NULL AND ZBV IS NULL )
    => com.sap.dbtech.jdbc.CallableStatementSapDB@11daf60
    <at this position the trace-file ends?!; "NEUROLOGISCHER_ERSTBEFUND ist defined as
    "NEUROLOGISCHER_ERSTBEFUND" Varchar (1000) ASCII; i also encountered this problem while handling shorter VARCHAR-columns with JComboBox-components...>
    Any information would be very helpfully!!!
    Greetings,
    Arnd
    Message was edited by: Arnd Benninghoff
    Message was edited by: Arnd Benninghoff

    Hi Arnd,
    if I understand right you are trying to insert/update value into a Varchar(1000) column. And if you set a non numeric value you get an exception "java.lang.NumberFormatException", Right?
    Of course this should work with MaxDB. The exception you get doesn't come from MaxDB's JDBC driver. The driver will only throw exceptions that are derived from java.sql.Exception.
    So, I guess the error comes from a layer above the JDBC layer, possibly from the JDBC-components of <SunONE Community Edition Update 1>. This would also explain why you don't see any exception in the JDBC trace.
    Did you have defined any constraints for the input field (JTextArea or JTextField)?
    Hope that helps.
    regards,
    Marco

  • Query with distinct and without it

    Hello all,
    I have a query to select some rows. like this..actually I want to show the recrods without any duplicates in voucher number and voucher type
    select distinct voucher_no ,t.voucher_type
    from gen_led_voucher_row_tab t
    where t.company = 'IPWL'
    and ((((t.debet_amount is null) and (t.currency_debet_amount IS NOT NULL and t.currency_debet_amount != 0 )))
    or ((t.credit_amount is null) and (t.currency_credit_amount IS NOT NULL and t.currency_credit_amount != 0)))But someone asked from me to show some other columns in the output..so now I can't use that query..so how I show those other fields without getting duplicates in voucher_no and voucher_type. Please let me know..
    Now I have to show something like this
    select distinct voucher_no ,t.voucher_type ,t.voucher_date,t.credit_amount,t.debet_amount,t.currency_credit_amount,t.currency_debet_amount
    from gen_led_voucher_row_tab t
    where t.company = 'IPWL'
    and ((((t.debet_amount is null) and (t.currency_debet_amount IS NOT NULL and t.currency_debet_amount != 0 )))
    or ((t.credit_amount is null) and (t.currency_credit_amount IS NOT NULL and t.currency_credit_amount != 0)))

    Hello all,
    I have a query to select some rows. like
    this..actually I want to show the recrods without any
    duplicates in voucher number and voucher type
    select distinct voucher_no ,t.voucher_type
    from gen_led_voucher_row_tab t
    where t.company = 'IPWL'
    and ((((t.debet_amount is null) and
    (t.currency_debet_amount IS NOT NULL and
    t.currency_debet_amount != 0 )))
    or ((t.credit_amount is null) and
    (t.currency_credit_amount IS NOT NULL and
    t.currency_credit_amount != 0)))But someone asked from me to show some other columns
    in the output..so now I can't use that query..so how
    I show those other fields without getting duplicates
    in voucher_no and voucher_type. Please let me know..
    Now I have to show something like this
    select distinct voucher_no ,t.voucher_type
    ,t.voucher_date,t.credit_amount,t.debet_amount,t.curre
    ncy_credit_amount,t.currency_debet_amount
    from gen_led_voucher_row_tab t
    where t.company = 'IPWL'
    and ((((t.debet_amount is null) and
    (t.currency_debet_amount IS NOT NULL and
    t.currency_debet_amount != 0 )))
    or ((t.credit_amount is null) and
    (t.currency_credit_amount IS NOT NULL and
    t.currency_credit_amount != 0)))
    You can try something like this
    select * from gen_led_voucher_row_tab t where voucher number in
    (select distinct voucher_no ,t.voucher_type
    from gen_led_voucher_row_tab t
    where t.company = 'IPWL'
    and ((((t.debet_amount is null) and
    (t.currency_debet_amount IS NOT NULL and
    t.currency_debet_amount != 0 )))
    or ((t.credit_amount is null) and
    (t.currency_credit_amount IS NOT NULL and
    t.currency_credit_amount != 0))))

  • Tuning SQL query with SDO and Contains?

    I'trying to optimize a query
    with a sdo_filter and an intermedia_contains
    on a 3.000.000 records table,
    the query look like this
    SELECT COUNT(*) FROM professionnel WHERE mdsys.sdo_filter(professionnel.coor_cart,mdsys.sdo_geometry(2003, null, null,mdsys.sdo_elem_info_array(1,1003,4),mdsys.sdo_ordinate_array(809990,2087279,778784,2087279,794387,2102882)),'querytype=window') = 'TRUE' AND professionnel.code_rubr ='12 3 30' AND CONTAINS(professionnel.Ctx,'PLOMBERIE within Nom and ( RUE within Adresse1 )',1)>0
    and it takes 15s on a bi 750 pentium III with
    1.5Go of memory running under 8.1.6 linux.
    What can i do to improve this query time?
    null

    Hi Vincent,
    We have patches for Oracle 8.1.6 Spatial
    on NT and Solaris.
    These patches include bug fixes and
    performance enhancements.
    We are in the process of making these patches
    avaialble in a permanent place, but until then, I will temporarily put the patches on:
    ftp://oracle-ftp.oracle.com/
    Log in as anonymous and use your email for
    password.
    The patches are in /tmp/outgoing in:
    NT816-000706.zip - NT patch
    libordsdo.tar - Solaris patch
    I recommend doing some analysis on
    individual pieces of the query.
    i.e. time the following:
    1)
    SELECT COUNT(*)
    FROM professionnel
    WHERE mdsys.sdo_filter(
    professionnel.coor_cart,
    mdsys.sdo_geometry(
    2003, null, null,
    mdsys.sdo_elem_info_array(1,1003,4),
    mdsys.sdo_ordinate_array(
    809990,2087279,
    778784,2087279,
    794387,2102882)),
    'querytype=window') = 'TRUE';
    2)
    SELECT COUNT(*)
    FROM professionnel
    WHERE CONTAINS(professionnel.Ctx,
    'PLOMBERIE within Nom and ( RUE within Adresse1)',1) >0;
    You might want to try reorganizing the entire
    query as follows (no promises).
    If you contact me directly, I can try to
    help to further tune the SQL.
    Hope this helps. Thanks.
    Dan
    select count(*)
    FROM
    (SELECT /*+ no_merge */ rowid
    FROM professionnel
    WHERE mdsys.sdo_filter(
    professionnel.coor_cart,
    mdsys.sdo_geometry(
    2003, null, null,
    mdsys.sdo_elem_info_array(1,1003,4),
    mdsys.sdo_ordinate_array(809990,2087279,
    778784,2087279,
    794387,2102882)),
    'querytype=window') = 'TRUE'
    ) a,
    (SELECT /*+ no_merge */ rowid
    FROM professionnel
    WHERE CONTAINS(professionnel.Ctx,
    'PLOMBERIE within Nom and
    ( RUE within Adresse1)',1) >0
    ) b
    where a.rowid = b.rowid
    and professionnel.code_rubr ='12 3 30';
    **NOTE** Try this with no index on code_rubr
    null

  • More Fun with NULLs and Empty Strings

    Greetings,
    I ran across this behavior recently and thought I'd share with the forum. I'm running 10.2.0.2. Note the difference in behavior between passing and explicit NULL in the parameter vice passing an empty string (''):
    CREATE OR REPLACE PROCEDURE NULL_ES_TEST(PARAM1 IN VARCHAR2) IS
    VAR1 CHAR(1);
    BEGIN
    IF PARAM1 IS NULL THEN
    DBMS_OUTPUT.PUT_LINE('PARAM1 IS NULL');
    END IF;
    VAR1 := PARAM1;
    IF VAR1 IS NULL THEN
    DBMS_OUTPUT.PUT_LINE('VAR1 IS NULL');
    ELSE
    DBMS_OUTPUT.PUT_LINE('VAR1 IS NOT NULL');
    END IF;
    DBMS_OUTPUT.PUT_LINE('THE LENGTH OF VAR1 IS '||TO_CHAR(LENGTH(VAR1)));
    END NULL_ES_TEST;
    EXEC NULL_ES_TEST(PARAM1 => '');
    PARAM1 IS NULL
    VAR1 IS NOT NULL
    THE LENGTH OF VAR1 IS 1
    (var1 now holds a single space)
    EXEC NULL_ES_TEST(PARAM1 => NULL);
    PARAM1 IS NULL
    VAR1 IS NULL
    THE LENGTH OF VAR1 IS
    Any Comments or Insights are welcome.
    Sincerely,
    Dale Ward

    Well somethings not as expected (tested on 10.2.0.3)
    Even if you default the parameter to '', it treats null and '' differently.
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE OR REPLACE PROCEDURE NULL_ES_TEST(PARAM1 IN VARCHAR2 := '') IS
      2    VAR1 CHAR(1);
      3  BEGIN
      4    IF PARAM1 IS NULL THEN
      5      DBMS_OUTPUT.PUT_LINE('PARAM1 IS NULL');
      6    END IF;
      7    VAR1 := PARAM1;
      8    IF VAR1 IS NULL THEN
      9      DBMS_OUTPUT.PUT_LINE('VAR1 IS NULL');
    10    ELSE
    11      DBMS_OUTPUT.PUT_LINE('VAR1 IS NOT NULL');
    12    END IF;
    13    DBMS_OUTPUT.PUT_LINE('THE LENGTH OF VAR1 IS '||TO_CHAR(LENGTH(VAR1)));
    14* END NULL_ES_TEST;
    SQL> /
    Procedure created.
    SQL> exec null_es_test(null);
    PARAM1 IS NULL
    VAR1 IS NULL
    THE LENGTH OF VAR1 IS
    PL/SQL procedure successfully completed.
    SQL> exec null_es_test('');
    PARAM1 IS NULL
    VAR1 IS NOT NULL
    THE LENGTH OF VAR1 IS 1
    PL/SQL procedure successfully completed.
    SQL>

  • Union two tables with diffrent count of fields with null and float value

    Hello,
    i want to union two tables, first one with 3 fields and second one with 4 fields (diffrent count of fields).
    I can add null value at end of first select but it does not work with float values in second table. Value form second table is convert to integer.
    For example:
    select null v1 from sessions
    union
    select 0.05 v1 from sessions
    result is set of null and 0 value.
    As workaround i can type:
    select null+0.0 v1 from sessions
    union
    select 0.05 v1 from sessions
    or simple change select's order.
    Is any better/proper way to do this? Can I somehow set float field type in first select?
    Best regards,
    Lukasz.
    WIN XP, MAXDB 7.6.03

    Hi Lukasz,
    in a UNION statement the first statement defines the structure (number, names and types of fields) of the resultset.
    Therefore you have to define a FLOAT field in the first SELECT statement in order to avoid conversion to VARCHAR.
    Be aware that NULL and 0.0 are not the same thus NULL+0.0 does not equal NULL.
    In fact NULL cannot equal to any number or character value at all.
    BTW: you may want to use UNION ALL to avoid the search and removal of duplicates - looks like your datasets won't contain duplicates anyhow...
    Regards,
    Lars

  • FI Customer Account Statement with Debit and Credit Columns

    Hi SAP Expert,
    We are using form (developed from T-code: SE71) to send customer account statment for only open items this is working fine.
    Now My wants customer account statement for all transactions but with debit and credit in a separate columns. is there any way we fulfill these kind of request?
    if any particular logic then let me know please.
    thanks in advance
    b/r
    prashant rane

    Dear Vivek,
    You logic is helpful can I apply this in SE71 form development?
    Below is my customer layout format
    Document # | Document Date | Reference | Debit Amt | Credit Amt |
    In bottom toal Debit / credit balance figure
    can I use any code/login is SE71 form or I will need to create any development report which involves user exit?
    I am looking for SE71 optios first
    thanks in advance
    Prashant Rane

Maybe you are looking for

  • Windows Xp not recognizing Ipod

    I tried to install my new Ipod Nano but it didn't work : during the installation, the first time I connected My Ipod, windows warned me not to intsall it. I Try to start again, but nothing happened, except the little noise, telling me a new usb is co

  • I just got a new laptop and I got rid of my old one and iTunes won't transfer my apps on my iPod 4g how i get my apps to show on my laptop?

    I just got a new laptop and my new one says i cant have my ipod synced to another account and it wants to erase all my apps

  • Tolerance error..

    Hi , Created Purchase order with account assignment V , having the total Qty 1 and Value of 624475 Vendor is send multiple invoice like below Invoice No                    Amount 1                              124175 2                               1

  • Remove (or adjust) iPhoto Book Binding Gutter

    Howdy All, I am trying to print some of my own iPhoto books (on a Canon Pixma ip4200 with duplex printing). Unfortunately, iPhoto (I believe) seems to be putting a binding gutter on the left side (appropriate for an Apple print job). Whereas my print

  • Feedback on new "Interactive Label" Widget

    Hi, I have mentioned in another thread that I was working on a widget and that I would like to have the community feedback on its usefulness. So, here it is. I call the widget an "Interactive Label". It's primary use is to identify areas on an image