In Datastage C++ varchar is Null, how to handle gracefully?

This is a discussion on In Datastage C++ varchar is Null, how to handle gracefully? within the C++ Programming forums, part of the General Programming Boards category; Hi, I am trying to execute the C++ program from the DataStage client. I was getting the following error message. ...

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    6

    In Datastage C++ varchar is Null, how to handle gracefully?

    Hi,

    I am trying to execute the C++ program from the DataStage client. I was getting the following error message.

    buildop_200,8: Fatal Error: Null value on the accessor interfacing to field "field1".

    Looks like it was receiving the Null values in the coulmn 'field1' from the input file. Even though i am handling the NULL check in my buildop c++ code, it’s still failing when i am running this buildop (C++ code) through the DataStage job.
    How to handle NULL values (if column value [c++ varchar/string] is null) gracefully in the Datastage?
    This is what I am currently handling in the code….
    Code:
    if (in0.field1[1] == 0 || in0.field1[1] == '\0' || in.field1[1] == ' ') /*** NULL check ****/
    { 
    //C++ logic
    }
    else
    {
    if ((in0.field1[1] == 'N') && (in0.field2.substring(1, 2) == in0.Orig_Code))
    {
    //C++ logic
    }
    // More C++ logic, if statements
    }
    Could you please help me with this problem? I apprecite your help in this regard.

    Thanks,

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    2,358
    Quote Originally Posted by tjr28 View Post
    Code:
    if (in0.field1[1] == 0 || in0.field1[1] == '\0' || in.field1[1] == ' ') /*** NULL check ****/
    this doesn't look like checking for null to me. it should probably be
    Code:
    if (in0.field1)

  3. #3
    Registered User
    Join Date
    Apr 2012
    Posts
    6
    Thanks for the reply. i tried with your way and still it is giving me the same error message
    buildop_200,8 Fatal Error: Null value on the accessor interfacing to field "field1"

    node_node7: Player 14 terminated unexpectedly.

    main_program: APT_PMsectionLeader(7, node7), player 14 - Unexpected exit status 1.

    buffer(12),6: Failure during execution of operator logic.

  4. #4
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Are you serious or is this a bad joke?

    What is DataStage? At least post a link to its documentation.

    How is in0 declared? How is it being assigned?

    Why do you think testing the 2nd element of in0.field for ascii-zero or space is a "NULL check"? Does it say that in the documentation?

    What does buildop_200,8 mean? What does any of the stuff you posted in post#3 mean???
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  5. #5
    Registered User
    Join Date
    Apr 2012
    Posts
    6
    Datastage means an ETL tool, i am trying to execute the C++ program (call Buildop) using Datastage job which uses the proper table definitions and the input files. to access any column in the input file (CSV) we use in0.column_name (in0.field1 or in0.field2 etc)

  6. #6
    Registered User
    Join Date
    Apr 2012
    Posts
    6
    the type of the field1 is "string" (sql type is varchar), it accepts 1 charecter
    i tried to do the NULL check this way, but still receiving the same error message
    1 if (in0.field1), buildop_200,3: Fatal Error: Null value on the accessor interfacing to field "field1".


  7. #7
    Registered User
    Join Date
    Apr 2012
    Posts
    6
    the type of the field1 is "string" (sql type is varchar), it accepts 1 charecter
    i tried to do the NULL check this way, but still receiving the same error message
    1 if (in0.field1), buildop_200,3: Fatal Error: Null value on the accessor interfacing to field "field1".

  8. #8
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,229
    O_o

    SQL is a great standard, but as with every other standard a lot of implementations are flaky.

    I've seen "Null" as the integer literal `0', the string literal `"NULL"', the string `""\0', and even `-1'.

    How does the database represent a "Null" and how does it pass that into C++? (oogabooga asked this earlier after a fashion.)

    That's really the only important question here.

    Soma

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Which is a better practice? (Global handle or finding handle)
    By C_Sparky in forum Windows Programming
    Replies: 4
    Last Post: 12-31-2010, 06:32 PM
  2. Replies: 2
    Last Post: 12-21-2009, 07:29 PM
  3. Exiting socket gracefully
    By vkaushal21 in forum Linux Programming
    Replies: 3
    Last Post: 09-09-2009, 11:06 AM
  4. Best method to (gracefully) quit another application
    By Nyda in forum Windows Programming
    Replies: 4
    Last Post: 05-12-2009, 01:34 PM
  5. accept(ListenSocket, NULL, NULL); cause program to hang?
    By draggy in forum Networking/Device Communication
    Replies: 11
    Last Post: 06-16-2006, 03:40 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21