Hierchical wth null and holes

I am trying to mine the DBA_HIST_ACTIVE_SESS_HISTORY. The column that interrest me are 'sample_time','session_sid','session_serial#', 'blocking_session' and blocking_Session_serial#'.
The purpose is to list per sample time the blocking session tree (and related data here out of scope).
When the blocking last several minutes, all blocked session are sampled and the data is rather relevant
for troubleshooting, thought not absolute. But the data model is not easy for you may have holes.
I have reproduced a simplified version of the data pattern as
it is in DBA_HIST_ACTIVE_SESS_HISTORY and what I want to achieve.
-- grp stands for time_sample and it is the base grouping
-- sid  stands for session
-- bsid stands for blocking session, this is a column of the SID row
--         but reference the same type of object (session).
--         bsid itself may be present (or not) as a row.
-- We don't consider the serial in this simplified model
create table hist_table ( grp varchar2(1) , sid number, bsid number ) ;
insert into hist_table values ( 'A', 10, 100 ) ;
insert into hist_table values ( 'A',  20 , null ) ;
insert into hist_table values ( 'A', 30,  40  ) ;
insert into hist_table values ( 'A', 40,  50  ) ;
insert into hist_table values ('A', 50, null ) ;
insert into hist_table values ( 'B',  10, 100 ) ;
insert into hist_table values ( 'B',20 , null ) ;
SQL> select * from hist_table ;
G        SID       BSID
A         10        100
A         20
A         30         40
A         40         50
A         50
B         10        100
B         20
We want :
grp  Session
  A    10
  A        100
  A    20
  A    30
  A       40
  A         50
  B   10
  B       100
  B   20
-- The difficulty is that blocking session 100 has no dedicated row.
-- Session 20 has no blocking session.
-- Sessions 30,40,50 are all linked in a hierarchic pattern.

Here is my work derieved on above answers. thanks to all who devoted time and helped me.
Bernard Polarski
http://www.smenu.org
set lines 190 page 82
col user_id head 'Usr|id' format 999
col event head 'Event' format a30
col usr_sqlid format a35
col fsid for a14 head 'Sid'
col sid_sql for a35 head 'Session sql text'
col bser for 99999 head 'Block|sess|serl#'
col ser for 99999 head 'Serl#'
col file# for 999 head 'Fl#'
col block# for 9999999 head 'block#'
col obj# for 999999 head 'obj#'
col sample_time for a8 head 'Time'
break on instance_number on sample_time on report
col wait_time for 9990.00 head 'Prev |wait| time(s)' justify c
prompt  Prev wait : any value > 0 means SQL currently running on CPU, numeric refer to wait(secs) before this run
prompt
with fview as (
    select
           blocking_session as session_id, blocking_SESSION_SERIAL# as SESSION_SERIAL# ,
           -1 as blocking_session, -1 as blocking_SESSION_SERIAL#,
           null sql_id, null event , sample_time, null obj# , null file# ,
           null block# ,  null wait_time, null user_id, null  instance_number
    from DBA_HIST_ACTIVE_SESS_HISTORY a
         where  1=1  and snap_id = '5884'   and dbid= '810902110'  and blocking_session is not null
            and not exists (select null
                                   from DBA_HIST_ACTIVE_SESS_HISTORY
                             where
                                    session_id=a.blocking_session
                              and   session_serial#=a.blocking_session_serial#  and snap_id = '5884'   and dbid= '810902110'
                              and   snap_id=a.snap_id
                              and   dbid=a.dbid
   union
   select
         session_id, SESSION_SERIAL#, blocking_session, blocking_session_serial#,
         sql_id, event, sample_time,  CURRENT_OBJ# obj#, CURRENT_FILE# file#,
         CURRENT_BLOCK# block#,  wait_time/100 wait_time, user_id, instance_number
   from DBA_HIST_ACTIVE_SESS_HISTORY a
        where 1=1  and snap_id = '5884'   and dbid= '810902110'
select
       a.instance_number, to_char(a.sample_time,'HH24:MI:SS') sample_time,
       lpad(' ', 2*level)||session_id  fsid,
       SESSION_SERIAL# ser, user_id, a.sql_id,
       decode(a.wait_time,0,' -wait-', to_char(wait_time,'99990.00')) wait_time,
       event  , a.file#, a.obj#, block#, substr(t.sql_text,1,35) sid_sql --,  blocking_session
from   ( select
                  instance_number, sample_time,
                  session_id, SESSION_SERIAL# , sql_id, event,  obj#, file#, block#,
                  wait_time, user_id, blocking_session, blocking_SESSION_SERIAL#
           from fview a
           start with not exists (select 1
                                  from
                                     fview b
                                  where
                                          b.sample_time            = a.sample_time
                                     and  b.blocking_session       = a.session_id
                                     and  blocking_session_serial# = a.SESSION_SERIAL# )
          connect by prior  sample_time              = sample_time
                      and   prior  blocking_session         = session_id
                      and   prior  blocking_SESSION_SERIAL# = SESSION_SERIAL#
          )a,
          dba_hist_sqltext t
    where
          t.sql_id (+) = a.sql_id
          connect by nocycle
                           prior session_id = blocking_session
                         and   prior session_serial# = blocking_session_serial#
                         and  sample_time= prior sample_time
                                                         Prev
In                                  Usr                 wait
st  Time     Sid             Serl#   id SQL_ID         time(s)  Event                           Fl#    obj#   block# Session sql text
  2 09:00:01   1478          45824   48 fph5dfjrr6spu      2.78                                  58   77692   150780 SELECT  bf.bf_id, bf.status, bs.sho
               1482          34169   48 6gpfyfz414w80      2.44                                  53   78348   713894 select field1 from ( SELECT field1
  1 09:00:03   1519          12157   93 96swh01bpcv54  -wait-   gc cr multi block request        58   77692    13920 SELECT COUNT (O.BF_ID) FROM IBS6_EB
               1515          29566    0                -wait-   log switch/archive                0      -1        0
  2 09:00:11   1482          34169   48 4ks1swd743v6h  -wait-   db file sequential read          52   77987   294036 INSERT into SUMMTRANSACTIONLVL(SUMM
  1 09:00:13   1549          25308    0 fjtb8ybf2g817  -wait-   control file sequential read      0      -1        0 select nvl(max(cpmid),0) from x$kcc
               1600          15870   48 07x2k1s911cs1      2.69                                  52   78010   837991 SELECT  bf.bf_id, bf.status, bs.sho
    09:00:23   1519          12157   93 96swh01bpcv54  -wait-   gc cr multi block request        52   77692   165451 SELECT COUNT (O.BF_ID) FROM IBS6_EB
               1550          18167   48 69u51auyg39c0      0.01                                  44   77975    14854 select count(1) from r4rrequest r,
  2 09:00:31   1518          30594    0                -wait-   db file sequential read           0      -1        0
  1 09:00:33   1563           7961    0                -wait-   enq: WF - contention              0      -1        0
  2 09:01:11   1478          45824   48 0wva63ycbrqxn      0.02                                   0      -1        0 SELECT cp.counterparty_id, cp.updat
  1 09:01:14   1584          55897   48 dj4vc1pdbvy98  -wait-   db file sequential read          49   78106   224094 select unique eb1.bankcustomer_id,
               1655              1    0                29279.20                                   0      -1        0
  2 09:01:31   1604           3421   48 cdg898bazxj0t      0.01                                  47   77994   154271    SELECT unique ucp.USERCONTRACTPROF
    09:01:42   1508          28278   48 fgacpsh4cctb0  -wait-   gc current block busy            49   78367   258887 INSERT into USERMESSAGE(USERMESSAGE
               1480          14992   48 25wncxupku5ty      0.01                                   5   78021    28828 SELECT        aubu.ebuser_id  FROM
                 1617        62553   48 0g7y44z6btjh0  -wait-   enq: TX - row lock contention     5   78021    28828 update usermessagepkiuser set useri
                 1615        18792   48 0g7y44z6btjh0  -wait-   enq: TX - row lock contention     5   78021    28828 update usermessagepkiuser set useri
                 1613         6428   48 0g7y44z6btjh0  -wait-   enq: TX - row lock contention     5   78021    28828 update usermessagepkiuser set useri
                 1609        18013   48 0g7y44z6btjh0  -wait-   enq: TX - row lock contention     5   78021    28828 update usermessagepkiuser set useri
                 1579        37687   48 0g7y44z6btjh0  -wait-   enq: TX - row lock contention     5   78021    28828 update usermessagepkiuser set useri
                 1572         4128   48 0g7y44z6btjh0  -wait-   enq: TX - row lock contention     5   78021    28828 update usermessagepkiuser set useri
                 1520        59235   48 0g7y44z6btjh0  -wait-   enq: TX - row lock contention     5   78021    28828 update usermessagepkiuser set useri
                 1501        20868   48 0g7y44z6btjh0  -wait-   enq: TX - row lock contention     5   78021    28828 update usermessagepkiuser set useri
                 1478        45824   48 0g7y44z6btjh0  -wait-   enq: TX - row lock contention     5   78021    28828 update usermessagepkiuser set useri
                 1482        34169   48 0g7y44z6btjh0  -wait-   enq: TX - row lock contention     5   78021    28828 update usermessagepkiuser set useri
                 1507         4886   48 0g7y44z6btjh0  -wait-   enq: TX - row lock contention     5   78021    28828 update usermessagepkiuser set useri
                 1566        39358   48 0g7y44z6btjh0  -wait-   enq: TX - row lock contention     5   78021    28828 update usermessagepkiuser set useri
                 1578        20585   48 0g7y44z6btjh0  -wait-   enq: TX - row lock contention     5   78021    28828 update usermessagepkiuser set useri
                 1597        48687   48 0g7y44z6btjh0  -wait-   enq: TX - row lock contention     5   78021    28828 update usermessagepkiuser set useri
                 1603        48768   48 0g7y44z6btjh0  -wait-   enq: TX - row lock contention     5   78021    28828 update usermessagepkiuser set useri
                 1604         3421   48 0g7y44z6btjh0  -wait-   enq: TX - row lock contention     5   78021    28828 update usermessagepkiuser set useri

Similar Messages

  • Using NULL and NOT NULL in prompted filters

    Dear all,
    While trying to grap the concept of prompted filters in sap bo web intelligence, I had a question whether why we cannot use NULL and NOT NULL while creating a prompted filters in our report.

    HI,
    'Is Null' and 'Not Null' are the predefined functions in webi which only eliminate the null values or considering only null values.
    'Is Null' and 'Not Null' are itself predefined functions that why you are not getting  prompts.
    Null values are standard across the databases so this is defined  as a function in webi to specific eliminate the null values.
    If something is not standard then there is option in the webi to use different operator with static values or with prompts.
    More more information on Null see the Null wiki page.
    Null (SQL) - Wikipedia, the free encyclopedia
    Amit

  • Not null and enable or disable  column in tabular form

    Hi,
    Using apex version 4.1 and working on tabular form.
    ACT_COA_SEGMENT_MAS is Master table
    and
    ACT_SEGMENT_VALUES_MAS is detail table
    I have entered 8 rows in master table and PARENT_SEGMENT_ID is column in master table which is null able. If i specified PARENT_SEGMENT_ID with value in master table then in detail table there is column PARENT_ID that should not be null and enable.
    How i can enable or disable column when in master table PARENT_SEGMENT_ID column is null then in detail table PARENT_ID column should disable and vice versa.
    I have created tabular form on Detail table. before insert into the tabular form Check in master table in first entry if PARENT_SEGMENT_ID is not null in first row of master table then in tabular form PARENT_ID should enable and not null able in corresponding to this first row id's lines in tabular form.
    Same should check for second row in master table if PARENT_SEGMENT_ID is not null then entered rows with PARENT_ID into tabular form corresponding to 2nd id in master table should not nullable and column should enable in tabular form.
    Thanks & Regards
    Vedant
    Edited by: Vedant on Jan 9, 2013 9:12 PM

    Vedant,
    You need to create you own manual tabular form and not use the wizard.
    Using APEX_ITEM api you should be build you own form and you will be able to control how you wan to display the rows. (See Link [Apex Item Help|http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35127/apex_item.htm#CACEEEJE] )
    select case when PRIMARY_TABLE_COLUMN is null then APEX_ITEM.DISPLAY_AND_SAVE(3 , DETAIL_COLUMN ) else APEX_ITEM.TEXT(2,detail_column) end "ALIAS" from detail table
    Hope that help.
    Vivek

  • Connection ==null and Connection is closed, difference

    Hi experts,
    I wonder what are the differences between "Connection==null" and "Connection is closed"?
    I closed a connection on one JSP page after a bean has retrieved data. Then, on the same page I call another bean to connect to the database. Because the Connection object has been created earlier, therefore Connection is not NULL, but it is closed. So, the second bean has to initiate another connection(if I knew how to test the "closed" status)
    Is it true that if the Connection is closed, then it should become null?
    I think I must have make quite a few mistakes in above statement:). Please help. Thanks a lot.

    connection.isClosed() will tell you if the connection object is closed or not. If it is closed, then the connection object can be dropped because you will not be able to create any new statements from that connection object. Just recreate another connection to use when this occurs.

  • Is null and regular value in where ($variable)

    is there any polibility to create select depend on value in where ?
    select count(x) where y = $variablebut if variable is NULLit doesn't work cause must be IS NULL or IS NOT
    select count(x) where y is $variableIs there any posibility to make it working with null and regular variable?

    try:
    select count(x) from <yourtable> where nvl(y,<not_possible_value>) = nvl($variable,<not_possible_value>);where <not_possible_value> is a value that is not possible for column y.
    E.g. if y always is a positive number you could use the value -1.

  • Avoiding null and duplicate values using model clause

    Hi,
    I am trying to use model clause to get comma seperated list of data : following is the scenario:
    testuser>select * from test1;
    ID VALUE
    1 Value1
    2 Value2
    3 Value3
    4 Value4
    5 Value4
    6
    7 value5
    8
    8 rows selected.
    the query I have is:
    testuser>with src as (
    2 select distinct id,value
    3 from test1
    4 ),
    5 t as (
    6 select distinct substr(value,2) value
    7 from src
    8 model
    9 ignore nav
    10 dimension by (id)
    11 measures (cast(value as varchar2(100)) value)
    12 rules
    13 (
    14 value[any] order by id =
    15 value[cv()-1] || ',' || value[cv()]
    16 )
    17 )
    18 select max(value) oneline
    19 from t;
    ONELINE
    Value1,Value2,Value3,Value4,Value4,,value5,
    what I find is that this query has duplicate value and null (',,') coming in as data has null and duplicate value. Is there a way i can avoid the null and the duplicate values in the query output?
    thanks,
    Edited by: orausern on Feb 19, 2010 5:05 AM

    Hi,
    Try this code.
    with
    t as ( select substr(value,2)value,ind
            from test1
            model
            ignore nav
            dimension by (id)
            measures (cast(value as varchar2(100)) value, 0 ind)
            rules
            ( ind[any]=  instr(value[cv()-1],value[cv()]),
            value[any] order by id = value[cv()-1] || CASE WHEN value[cv()] IS NOT NULL
                                               and ind[cv()]=0     THEN ',' || value[cv()] END      
    select max(value) oneline
    from t;
    SQL> select * from test1;
            ID VALUE
             1 Value1
             2 Value2
             3 Value3
             4 Value4
             5 Value4
             6
             7 value5
             8
    8 ligne(s) sélectionnée(s).
    SQL> with
      2   t as ( select substr(value,2)value,ind
      3          from test1
      4          model
      5          ignore nav
      6          dimension by (id)
      7          measures (cast(value as varchar2(100)) value, 0 ind)
      8          rules
      9          ( ind[any]=  instr(value[cv()-1],value[cv()]),
    10          value[any] order by id = value[cv()-1] || CASE WHEN value[cv()] IS NOT NULL
    11                                             and ind[cv()]=0     THEN ',' || value[cv()] END 
    12          )
    13        )
    14   select max(value) oneline
    15   from t;
    ONELINE
    Value1,Value2,Value3,Value4,value5
    SQL>

  • Replacing NULL and EmptyString('') with "Unknown" in SSRS parameter dropdown

    All,
    What I want to do is, in the SSRS parameter drop down, instead of showing NULL and Blank values(), i want to categorize them as "Unknown", so, if the user selects "Unknown" from the SSRS drop down parameter, he should be able to see all
    the records that have NULL values or empty strings in that particular column in the result set.
    Can you tell me, how should I handle it in my main stored proc as well as in the dataset?
    Right now, i have something like this:
    Where
    (t1.name in (select value from dbo.Split(@TName,',')) OR @TName IN ('All'))
    -- Where t1.Name has empty strings and NULL values. Both of these values should be categorized under "Unknown"
    -- How would the dataset query look like? Right now I have this query for populating the drop down for that parameter:
    Select All
    UNION
    Select Distinct Name
    Order BY 1

    Hello,
    Please refer to the following stored procedure:
    SELECT
    CASE WHEN TName IS NULL OR TName = ''
    THEN 'Unknown' ELSE TName END AS TName
    From DemoTable
    Then, use following query code to get the parameter values:
    SELECT Distinct
    CASE WHEN TName IS NULL OR TName = '' THEN 'Unknown'
    ELSE TName END AS TName
    FROM DemoTable
    Regards,
    Alisa Tang
    Alisa Tang
    TechNet Community Support

  • NULL and Space value in ABAP

    Hi All,
           I like to know, is it NULL and Space value is same in ABAP, if it is not how to check null value.
    Thank you.
    Senthil

    everything is correct though some answers are not correct.
    A Database NULL value represents a field that has never been stored to database - this saving space, potentially.
    Usually all SAP tables are stored with all fields, empty fields are stored with their initial value.
    But: If a new table append is created and the newly-added fields do not have the 'initial value' marked in table definition, Oracle will just set NULL values for them.
    as mentioned: There is no NULL value to be stored in an ABAP field. The IS NULL comparison is valid only for WHERE clause in SELECT statement. WHERE field = space is different from WHERE field IS NULL. That's why you should check for both specially for appended table fields.
    If a record is selected (fulfilling another WHERE condition) into an internal table or work area, NULL values are convertted to their initial values anyway.
    Hope that sheds some light on the subject!
    regards,
    Clemens

  • NULL and SPACE

    Hello Gurus:
    I have had to use BOTH 'null' and 'space' (ofcourse I tried 'initial' too...) when selecting data from PRPS table, otherwise all the required records were not fetched. I had to do this on two different occassions. The first is a SAP provided field and the other is customer's enhancement. I have cut-paste the two code blocks. Any ideas why?
    Thanks in advance,
    Sard.
    ***********(1)**************
    select posid objnr func_area zzfunct from prps into
                    corresponding fields of table it_wbs
                              where func_area is null or
                                    func_area eq space.
    ************(2)**************
    select prps-pspnr prps-posid prps-post1
       into (wa_test1-pspnr, wa_test1-posid, wa_test1-post1,
       from prps
      where prps-posid in s_wbs and
            ...                 and
           ( prps-zzmlind is null or prps-zzmlind eq space ).
    append wa_test1 to it_test1.
    clear wa_test1.
    endselect.

    Hello Richard,
    the Requirement to check for NULL corresponds to the definition of the database (field) within the DDIC. Check the flag initialize (it has also some documentation).
    This flag is intended to be used if the definition of the db table is changed at SAP while the table already is used at customer side.
    After deploying the corresponding patch or upgrade such a changed definition may result into the need to convert all entries. For tables with many entries this would result into inacceptable downtime. So such changes are done without the initialiazation/conversion of existing entries.
    The tradeoff is the syntax you noticed.
    Kind regards
    Klaus

  • NULL and dynamic SQL

    If table testrh2 has the following columns and data
    col1 --> NULL
    col2 --> 2
    and table testrh has the following columsn and data
    col1 --> NULL
    How could I write a dynamic SQL statement to join on the nulls? I've written the following block as a starting point.
    declare
    cursor c1 is select col1 from isis.testrh;
    lval varchar2(1000);
    lval2 varchar2(1000);
    begin
    for r1 in c1 loop
    lval := 'select col2 from isis.testrh2 where col1 = '||r1.col1;
    execute immediate lval into lval2;
    dbms_output.put_line(lval2);
    end loop;
    end;

    You can't compare null values with '=' in Oracle SQL.
    Null can only be compared with <column> is null .
    You can see it when you try these two queries:
    select * from dual where null is null;  -- you will see one row
    select * from dual where null=null;  -- you will see no rowsThat's why you have to write something like
    (<column1>=<column1>   or   (<column1> is null and <column2> is null))This should also work with null:
    decode(<column1>,<column2>,1,0)=1By the way, why do you use dynamic sql?
    lval := 'select col2 from isis.testrh2 where col1 = '||r1.col1;
    I think you could replace your two lines ( lval:= ... AND execute immediate) by this:
    begin
      select col2
      into lval
      from isis.testrh2
      where decode(col1,r1.col1,1,0)=1;
      dbms_output.put_line('lval='||lval);
    exception
    when no_data_found then
      dbms_output.put_line('no data found'); -- or whatever you want
    end;Edited by: hartmutm on 02.10.2010 23:54

  • Null and empty string not being the same in object?

    Hello,
    I know that null and empty string are interpreted the same in oracle.
    However I discovered the strange behaviour concerning user defined objects:
    create or replace
    TYPE object AS OBJECT (
    value VARCHAR2(2000)
    declare
    xml xmltype;
    obj object;
    begin
    obj := object('abcd');
    xml := xmltype(obj);
    dbms_output.put_line(xml.getStringVal());
    obj.value := '';
    xml := xmltype(obj);
    dbms_output.put_line(xml.getStringVal());
    obj.value := null;
    xml := xmltype(obj);
    dbms_output.put_line(xml.getStringVal());
    end;
    When creating xml from object, all not-null fields are transformed into xml tag.
    I supposed that obj.value being either '' or null will lead to the same result.
    However this is output from Oracle 9i:
    <OBJECT_ID><VALUE>abcd</VALUE></OBJECT_ID>
    <OBJECT_ID><VALUE></VALUE></OBJECT_ID>
    <OBJECT_ID/>
    Oracle 10g behaves as expected:
    <OBJECT><VALUE>abcd</VALUE></OBJECT>
    <OBJECT/>
    <OBJECT/>
    However Oracle 9i behaviour leads me to the conclusion that oracle
    must somehow distinguish between empty string and null in user defined objects...
    Can someone clarify this behaviour?
    Thus is it possible to test if object's field is empty or null?

    However Oracle 9i behaviour leads me to the conclusion that oracle
    must somehow distinguish between empty string and null in user defined objects...
    Can someone clarify this behaviour?
    Thus is it possible to test if object's field is empty or null?A lot of "fixes" were done, relating to XML in 10g and the XML functionality of 9i was known to be buggy.
    I think you can safely assume that null and empty strings are treated the same by Oracle regardless. If you're using anything less than 10g, it's not supported any more anyway, so upgrade. Don't rely on any assumptions that may appear due to bugs.

  • Null and no data in field value

    I transferring sql from MS Access to Oracle 9i.
    In Access I have this
    select * from tableOne where firstname <> ''
    and firstname & '' = ''The firstname field can be edited where it could have data and the data could be deleted so I am trying to select records where firstname is not null and it has no data in it.

    I transferring sql from MS Access to Oracle 9i.
    In Access I have this
    select * from tableOne where firstname <> ''
    and firstname & '' = ''
    select * from tableOne where firstname IS NULL;
    - or -
    select * from tableOne where firstname IS NOT NULL;
    as appropriate.
    In Oracle there is no difference betwen being NULL and having data of length '0'

  • Null and Empty Values

    Hi All,
    Is there a parameter which allows me to translate automatically the instruction
    select * from table_a where col_a = ''
    in
    select * from table_a where col_a is null
    Thanks

    Not in Oracle, no. col_a = NULL and col_a IS NULL are logically distinct clauses. If you are dealing with NULL's, you absolutely must use three-valued logic in your statements.
    Depending on what you are doing, you may be able to throw an NVL on col_a to ensure a non-NULL value is returned.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Difference between Null and null?

    What is the difference between null and NULL?
    When is each used?
    Thanks,

    veryConfused wrote:
    There is a null in java, but no NULL. null means no value. However, when assigning value, the following is different:Although the empty String has no special role. Null means, the referential type is not assigned (doesn't refer) to a specific object. The empty String is just another object though, so seeing it or pointing it out as something special when it actually isn't at all (no more special than new Integer(0) or new Object[0]) just adds to the confusion.

  • Difference in Null and Empty String

    Hi,
    I have been wondering about the difference between Null and Empty String in Java. So I wrote a small program like this:
    public class CompareEmptyAndNullString {
         public static void main(String args[]) {
              String sNull = null;
              String sEmpty = "";
              try {
                   if (sNull.equalsIgnoreCase(sEmpty)) {
                        System.out.println("Null and Empty Strings are Equal");
                   } else {
                        System.out.println("Null and Empty Strings are Equal");
              } catch (Exception e) {
                   e.printStackTrace();
    This program throws Exception: java.lang.NullPointerException
         at practice.programs.CompareEmptyAndNullString.main(CompareEmptyAndNullString.java:10)
    Now if I change the IF Clause to if (sEmpty.equalsIgnoreCase(sNull)) then the Program outputs this: Null and Empty Strings are Equal
    Can anyone explain why this would happen ?
    Thanks in Advance !!

    JavaProwler wrote:
    Saish,
    Whether you do any of the following code, the JUnit Test always passes: I mean he NOT Sign doesnt make a difference ...
    assert (! "".equals(null));
    assert ("".equals(null));
    You probably have assertions turned off. Note the the assert keyword has nothing to do with JUnit tests.
    I think that older versions of JUnit, before assert was a language keyword (which started in 1.4 or 1.5), had a method called assert. Thus, if you have old-style JUnit tests, they might still compile, but the behavior is completely different from what it was in JUnit, and has nothing to do with JUnit at all.
    If you turn assertions on (-ea flag in the JVM command line, I think), the second one will throw AssertionError.

Maybe you are looking for

  • Profit center in material master is not in MARC table

    Hi All, We have maintained profit center in Material master costing 1 screen but when I am checking it in MARC table I am not able to see profit center in MARC Table. Please tell me in which table this profit center data will sit. Thanks in advance.

  • Broadcast web template by e-mail : user authorization issue

    Dear all, Here is my concern: I have created a variant to broadcast a web template as a PDF file by e-mail using authorization settings of the receivers and e-mail adress associated to his BW user id. To achieve this I have to create the user in the

  • Transferring contacts to iphone 4

    How do you transfer sim card contacts from an old phone to i phone 4 when the sim card sizes are different?

  • Partners or not tiggered in sales order header

    When iam changing the ship to party from inital one this ZK and ZR is not triggered in order at parters at header. i need this ZR and ZK to be triggred in partner(sales order). which user exit i have to check it for sales order in se37 Regards, kisho

  • Approve step in workflow

    Hi Folks, Can someone explain how the Approve step is used in case a record is not approved ? example. Start->Process->Approve -> syndicate                         -> reject-> send notification. -Vinay