Converting null and blank to NA in a column of a database table

Hi
This is a simple thing but is giving me a hard time. I need to change the values coming as null or blank to NA . The values comes in a flat file as a source and I need to laod it convertign to NA in database. I wrote the expression as
ISNULL([NPS Rating]) ? "NA" : [NPS Rating] in a derived column  and checked the box " retain null values from source as null values in data flow:
However it is not working instead giving the error as : Truncation may occur due to inserting data from dataflow column from  column name" with a length of ...........
Can any help me to sort out this problem. Am I writing the correct expression?
Thank you so much for your help in advance.
Kind regards
Rama

In your conditional result force it to the same length and type and make sure it is long enough, e.g.
ISNULL([NPS Rating])==TRUE ? (DT_WSTR,256)"NA" : (DT_WSTR, 256)[NPS
Rating]
and if the data comes from a flat file, the test will most likely need to test for zero length string too, or trim spaces and then test for zero length.
LEN(TRIM([NPS Rating])) == 0 || ISNULL...
Jan D'Hondt - SQL server BI development

Similar Messages

  • Popup Key LOV, NULL and "Invalid numeric value undefined for column"

    Hello.
    I've created an item based on database column of NUMBER type and set the following properties:
    Display As = Popup Key LOV (Displays description, returns key value)
    List of values definition=select 'display_value' d, 1 r from dual
    Null display value=%
    Null return value=
    Display Null=Yes
    When I select "%" in the LOV and try to apply changes to database I get error:
    ORA-20001: Error in DML: p_rowid=1781, p_alt_rowid=N1, p_rowid2=, p_alt_rowid2=. ORA-20001: Invalid numeric value undefined for column N2
    Error Unable to process row of table TTT.
    If I set Display As = Select List, all works fine. But I need Popup Key LOV.
    Could anybody help me?
    I use Application Express 2.2.1.00.04

    Hi all,
    I did my homework and solved this issue. First I would like to thank Patrick Wolf for the invaluable help he gives out on thread Re: Null value handling in LOVs The code presented here is just a minor edit to his code, but an essential one when dealing with Popup Key LOV items.
    Here's what I did:
    1. Create an Application Process.
    Name: RemoveNulls
    Sequence: 0
    Point: On Submit: After Page Submission - Before Computations and Validations
    Process Text:
    BEGIN
        FOR rItem IN
          ( SELECT ITEM_NAME
              FROM APEX_APPLICATION_PAGE_ITEMS
             WHERE APPLICATION_ID   = TO_NUMBER(:APP_ID)
               AND PAGE_ID          IN (TO_NUMBER(:APP_PAGE_ID), 0)
               AND LOV_DISPLAY_NULL = 'Yes'
               AND LOV_DEFINITION   IS NOT NULL
               AND LOV_NULL_VALUE   IS NULL
        LOOP
            IF (V(rItem.ITEM_NAME) = '%null' || '%' OR V(rItem.ITEM_NAME) = 'undefined')
            THEN
                Apex_Util.set_session_state(rItem.ITEM_NAME, NULL);
            END IF;
        END LOOP;
    END;Error Message: #SQLERRM#Condition: None
    2. You should be able to submit a Popup Key LOV with a NULL value now.
    Once again, THANKS, Patrick! You rock! I'm seriously thinking of trying ApexLib now :)
    Georger

  • 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

  • Validation for text field: Null and contains no spaces

    Currently on APEX 3.2
    I want to check 1 text field and 2 text areas to ensure they are not null and blank (hitting the space bar in the field) before submitting the page. How do I do both validations for on each field?

    I created a validation with a type of 'Function Returning Boolean' and using the following code in the expression:
    IF( TRIM( :P1_Text_Field) IS NULL
    Or LTRIM( :P1_Text_Field ) != :P1_Text_Field )
    THEN
    RETURN false;
    ELSE
    RETURN true;
    END IF;
    Edited by: Jeremy_F on Apr 12, 2012 8:15 AM

  • Difference between NULL and INITIAL

    Hi All,
           I just wanted to know that if we have a statement such as 'IF VBAP-KWMENG IS INITIAL' or 'IF VBAP-KWMENG IS NULL' what is teh exact difference and where are they used. Is it that null is used for CHARACTER fields?
    TIA

    Hi,
    An <b>Initial Value</b> is set for all the predefined data types
    fo ex: type    Initial value
            b        0
            c        " "
            i        0
    so when an object is created,the start value explicitly given by you is taken by that else initial value is taken.
    <b>NULL Value</b> is Initial value of an empty column in a row of a database table.Null values can be processing using Native SQL statements, but they have no equivalent as the content of data objects in ABAP. Only the WHERE addition enables a special condition IS NULL for null values. Changing Open SQLstatements (INSERT, UPDATE, MODIFY) generally do not create null values, provided that you are not processing a view that does not comprise all columns of a database table. However, depending on the database system, you can also display empty strings as null values. Null values can still arise in database tables if the new columns are appended to filled tables. When reading with the Open SQL statement SELECT , null values can be created by aggregate functions or an outer join, but they are converted to initial values of the correct type when passed to data objects.
    Please reward points if you feel it helps you
    Thanks,
    Sowjanya

  • Difference betwen Null item,Blank item ,item is zero and empty item

    Please describe the difference betwen :
    null item
    empty item
    blank item
    and zero item
    And how can we test each one?
    How to test if the value of an item say Px_y is null or
    blank
    empty
    zero
    Regards

    Please describe the difference betwen :
    null item
    empty item
    blank item
    and zero item
    And how can we test each one?
    How to test if the value of an item say Px_y is null or
    blank
    empty
    zero
    Regards

  • 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

  • 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.

  • MS ACCESS, NULL, and '%'

    I am using a prepared statement to query my access database which contains personal data first name, last name, address, city, state, etc.... I allow the user to search the database by any of these fields (or any combination of them) by making the default values for any empty fields '%'. Here's my select statement.
    stmt =conn.prepareStatement("SELECT * FROM Data1 WHERE first_name LIKE ? AND last_name LIKE ? AND city LIKE ? ....");
    stmt.setString(1, firstNameField.getText()+"%");
    stmt.setString(2, lastNameField.getText()+"%");
    stmt.setString(3, cityField.getText()+"%");
    This worked but didn't return a record if ANY of their values are NULL. So I changed my select statement to allow for NULL values.
    stmt =conn.prepareStatement("SELECT * FROM Data1 WHERE (first_name LIKE ? OR first_name IS NULL) AND (last_name LIKE ? OR last_name IS NULL) AND (city LIKE ? OR city IS NULL) ....");
    stmt.setString(1, firstNameField.getText()+"%");
    stmt.setString(2, lastNameField.getText()+"%");
    stmt.setString(3, cityField.getText()+"%");
    This fixed that problem, but now it ALWAYS returns the records with NULL fields. I want it to only match NULL fields if the coressponding JTextField is left blank. Can anyone tell me a good way to do this?

    How can I create it dynamically and still keep the
    speed of a prepared statement??Unless you are doing block inserts in a loop you are probably not going to see any speed improvement anyways.
    But as I said you can simply create all the combinations and then use an array to keep track of them.

  • Difference between NULL and ''

    Hi All,
    Is the below right?
    NULL is not stored as a value in a field. Its an internal bit that is set to indicate that the value is unknown.
    Blank is stored as a value in the field. Because of that we can perform all kinds of comparisons with blank value, while we cant do the same with NULLs
    Regards,
    aak

    user605246 wrote:
    Hi All,
    Is the below right?
    NULL is not stored as a value in a field. Its an internal bit that is set to indicate that the value is unknown.
    Blank is stored as a value in the field. Because of that we can perform all kinds of comparisons with blank value, while we cant do the same with NULLs
    Regards,
    aakYou are corerct in that NULL is not stored as a value in a field, but sorta/kinda wrong that it is an internal bit set to indicate that the value is unknown.
    If the NULL column(s) is/are the last column(s) in the table, then null values are not stored at all. The basic structure of a row stored on disk is (highly simplified)
    col1length|col1data|col2length|col2data|col3length|col3dataSo, given a row with col1 = 'ABC', col2 = 'Hello' and col3 null what is stored is:
    3|ABC|5|HelloHowever, if col2 is null and col 3 = 'Hello' then what is stored is:
    3|ABC|0|5|HelloSo the length byte is set to 0 to indicate that the column is null. Although the actual storage mechanisims for other data types differ from varchar2 example above, the 0 valeu i nthe length byte always indocates a null, and trailing null columns take 0 bytes of storage.
    John

  • Discoverer report showing null instead blank

    hi,
    I am running report from discoverer and it is showing null instead blank, do I need to check some thing in pref.txt file in oracle 9i
    regards
    kumar

    hi,
    I am running report from discoverer and it is showing null instead blank, do I need to check some thing in pref.txt file in oracle 9i
    regards
    kumar

  • 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

  • Oracle evolution suggestion : NULL and Index

    Hello,
    As you know in most of case NULL values are not indexed and then not searchable using index.
    Then when you do where MyField is null, you have the risk of doing a full table scan
    However most of people don't know that, and then doesn't care of this possible issue and of possible solution (bitmap or including a not null column)
    SQL Server, MySQL and probably some others DB don't have the same behavior as they indexes NULL
    I know this caveat can be used to have partial indexing by nulling non interesting values and then can't be removed
    Then I would suggest to enhance the create index command to allow to index also null with something like that
    Create index MyIndex on MyTable(MyColumn including nulls )
    As you make this change, perhaps it would be geat to change the behavior documented bellow as it looks more as an old heritage too by adding keyword like "allow null duplicate" and "constraint on null duplicate"
    Ascending unique indexes allow multiple NULL values. However, in descending unique indexes, multiple NULL values are treated as duplicate values and therefore are not permitted.
    Laurent

    Hello,
    Thanks, for the links it cover mains solutions to index null values, there's also the usage of bitmap index.
    All of them are not very intuitive for an non expert.
    But the purpose of my message was mainly to higlight this complexity for a quite basic stuff, as I think that the default solution should be to index nulls and eventually allow to do not index them.
    As I said this is the behavior on sql server and mysql. That why i suggest to enhance index behavior to allow to index nulls easily and not by using stange tips like indexing a blank space or a not null column.
    This solutions are from my viewpoint workaround, helpfull workaround but still workaround, Oracle database team have the power to change this root cause without breaking ascending compatibility, here is the sense of my message, just hopping they can hear me...
    Laurent

  • Difference between MySQL null and JAVA null

    When I create a new record in my MySQL db and some of the values are not intered, MySQL thinks of them as null. Java makes an error when the variable is used. But when I set the values to ' ' (blank) java sees it as null and makes no error.
    Is there a way around that??????
    BR Soren

    "" and null is totally different thing.
    you can try checking for null instead of "".

Maybe you are looking for

  • External time machine drive no longer being automatically recognized

    Recently my RMBP has stopped recognizing my external time machine drive. When ever I connect my 1 TB WD drive to my mac, it shows up on my desktop as usually but will not get recognized by time machine. I used to be able to connect the drive, have it

  • No 1680x1050 Resolution for External Monitor?

    Hello, forum friends! So after getting a very nice 22"-ish Envision Monitor connected via VGA to my 2011 Macbook Pro, it appears that there is no option for the monitor's recommended resolution, which is 1680x1050! The highest level resolution is 160

  • Can't get the Switch Device Wizard to work - HELP:

    currently using version 4.3.0.17 of the Blackberry desktop manager and version 4.2 of the Palm desktop.  When I try to use the Switch device wizard, I get to the screen where it asks me to select the software, either the Palm Treo or the Windows Mobi

  • Want to display the contents of a text file in a jsp

    hi i am new to jsp, i want to display the contents of a text file in a jsp file ,whenever jsp file is loaded from browser. -thanx

  • File-Transport over WebService

    Hi, it is possible to transport div. kinds of files (txt, pdf etc.) over an WebService (for example as attachement)? Thanks in advance Frank