SPONSORS:






User Tag List

Results 1 to 9 of 9
  1. #1
    Junior Member
    Join Date
    Feb 2002
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with NULL database values

    I am experiencing some problems trying to manipulate NULL database values. What I wanted to do was retrieve a value from the database and if the value was NULL, assign a string such as "NULL" to the variable. This way I could print out the results of what I retrieved without the script erroring out with a "variable was not set" message.

    Does anyone know how to get around this problem? Thanks



    ------------------
    SmooveT
    SmooveT

  2. #2
    Member
    Join Date
    Jan 2003
    Location
    Caribou, ME, USA
    Posts
    38
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Problem with NULL database values

    To get ONLY null values, try a SQL query like this...

    Of course, you'll have to substitute real values for "Column", "Table", and "Field"

    The code I think you're looking for looks something like this...

    This isn't a complete code snippet, but I'm betting you'll get the gist of the solution. If you'd like a more complete example (or if I missed the target completely) just let me know.

    ------------------
    Greg
    ATX II, LLC
    You wrote what in 4Test?!?

    [This message has been edited by gmajor (edited 03-06-2003).]
    Greg
    ATX II, LLC
    You wrote [i]what</I] in 4Test?!?

  3. #3
    Member
    Join Date
    Jan 2003
    Location
    Caribou, ME, USA
    Posts
    38
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Problem with NULL database values

    There's also this rather nasty solution...

    Bear in mind that this probably NOT a good idea in, well... almost any scenario I can possibly imagine. &lt;g&gt;

    ------------------
    Greg
    ATX II, LLC
    You wrote what in 4Test?!?
    Greg
    ATX II, LLC
    You wrote [i]what</I] in 4Test?!?

  4. #4
    Senior Member
    Join Date
    Aug 2001
    Location
    Manchester, NH
    Posts
    121
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Problem with NULL database values

    or you could use ISNULL(column, 'NULL') in the select, to replace the NULL values before they are returned.

    ------------------
    Adam Kuczkowski
    akuczkowski@frametech.com

  5. #5
    Member
    Join Date
    Jun 2001
    Location
    Bedford, MA, USA
    Posts
    85
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Problem with NULL database values

    In your SQL, use a translation function for any column that could return a null. These examples convert null into the string 'NULL'.

    For Oracle:
    &lt;code&gt;
    select columnA, columnB, NVL(columnC, 'NULL') from sometable
    &lt;/code&gt;

    For DB2:
    &lt;code&gt;
    select columnA, columnB, COALESCE(columnC, 'NULL') from sometable
    &lt;/code&gt;

    ------------------

  6. #6
    Junior Member
    Join Date
    Feb 2002
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Problem with NULL database values

    Thanks for all the help. It looks like NVL was the best way to go with this one.

    ------------------
    SmooveT
    SmooveT

  7. #7
    Senior Member
    Join Date
    Jun 2000
    Location
    Hartford, CT, USA
    Posts
    163
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Problem with NULL database values

    A bit of confusion here(for me):
    1. Was substitution of NULL value to 'NULL' done through SilkTest Code or outside, directly through Net8 Agent?
    2. I didn't see the NVL solution above. Can U elaborate how U finally did it?



    ------------------
    Jaimini Bhatt
    jaiminita@hotmail.com
    jaiminita@yahoo.com
    Jaimini Bhatt

  8. #8
    Member
    Join Date
    Jun 2001
    Location
    Bedford, MA, USA
    Posts
    85
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Problem with NULL database values

    The substitution is done through SQL, not SilkTest. (There are ways to do it with SilkTest code but they are much harder).

    Each database vendor supports different functions in their brand of SQL. NVL is an Oracle function which translates a returned NULL into anything you want.

    I'll repeat the examples:

    For Oracle:
    select columnA, columnB, NVL(columnC, 'NULL') from sometable

    For DB2:
    select columnA, columnB, COALESCE(columnC, 'NULL') from sometable

    Hope this helps!
    - Jim




    ------------------

  9. #9
    Member
    Join Date
    Jun 2001
    Location
    Bedford, MA, USA
    Posts
    85
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Problem with NULL database values

    Of course you do want to use SilkTest to issue the SQL!

    ------------------

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 08:55 AM.

Copyright BetaSoft Inc.