Null And " "

What is the difference between these two lines of codes?
String currentFile = null;
String currentFile = "";
Edited by: AMARSHI on Jul 10, 2008 7:07 AM

The reference variable itself, takes up the same amount of space, of course, as all references are the same size. Now, the object on the heap is a different story. With null there isn't one, of course (or if there is there is only one for the entire VM), and for the second a String object will be created in the String pool (once again, only one for the entire VM that every = "" assignment will use). But really, what difference does it make? If there is a difference, it is on the order of a few bytes (at max) for the entire VM, and if this is a concern, your probably doing something else greviously wrong. This miniscule difference should not concern you.
Edit: And "nulling" variables to "save" memory is also not something you should be concerned with. Either the variable will go out of scope and the object garbage collected anyway, or it's in constant use and so will not be taking up any extraneous heap space. If one of those is not the case, you are, once again, doing something greviously wrong.

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.

  • Form feed, null and StringTokenizer

    is form feed recognized as null when using the StringTokenizer?
    i currently have my StringTokenizer set with a blank space and i am attempting to read until the value is (EOF) null and while it hasMoreTokens. the text file that i am reading from spans across several pages. my code falls out of my loop when it hits the last space on my first page.

    a form feed (\f) is not a null but that shouldn't be stopping the StringTokenizer, I suspect that the manner in which you're reading in the data may be the culprit. Try to use the BufferedReader class to read your file.
    V.V.

Maybe you are looking for

  • I installed a new firmware but now I don´t like

    The matter is that I installed the new firmware which gives you the chance to drag and drop the songs just using Windows but then does not let you use the original program. Well, I tried the Windows drag and drop and it is great if you need it when y

  • Sound in xp using latest boot camp drivers

    Hey all - I have a problem in xp that I am wondering if anyone else has... I cannot get sound out of the "line out" (I have the computer hooked up to speakers). I can only get sound out of the headphone jack - and NEVER get the sound out of the front

  • Safari won't fully load websites

    Safari is having many and varied moments of not fully loading webpages. It is also happening to a lesser degree on other browsers (firefox, camino, shiira). I have tested removing internet plugins, deleting cache, history, duplicate fonts, plist, etc

  • Problems with 1 way audio

    So on and off maybe once or twice a year we have had one way audio issues pop up where incoming callers couldn't hear us but we could hear them. Reboot of the docsis modem for our pri service provider has always resolved this in the past. It started

  • Transformations Export into Excel

    Hi BI Guru`s, Can we export transformations into excel sheet? If it is possible please let me know, how to do it? Thanks in advance, Venkat