SPONSORS:






User Tag List

Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Apr 2000
    Location
    Cupertino,CA,95014
    Posts
    10
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to hadle null returned from DB_FETCHNEXT

    User Edward Dias (dsd_hca@hotmail.com) posted:


    Hi group,

    I'm working on this method that will query a database for some values, if those values are not found i will call another method to populate with the needed records. I am using DB_FETCHNEXT in my query, when the records are found it the databse it works great, but if no records are found I'm not able to go any further... here's a sample of my code maybe someone has a better idea on how to procced when i get no records returned from the db query. TIA


    [-] Check_Database()
    [ ]
    [ ] BOOLEAN bSuccess = TRUE
    [ ]
    [ ] STRING sOrderNo1 // use to store the found record
    [ ]
    [ ] HANDLE hDataBase = DB_Connect ()
    [ ]
    [ ]
    [-] do
    [ ]
    [ ] STRING sSqlSelect1 = "SELECT column FROM table WHERE column = '{iMyInteger}'"
    [ ]
    [ ] HANDLE hBuffer = DB_ExecuteSql (hDataBase, sSqlSelect1)
    [ ]
    [-] while (DB_FetchNext (hBuffer, sOrderNo1))
    [ ]
    [-] if sOrderNo1 != NULL
    [ ] // Cool
    [ ]
    [-] if sOrderNo1 == NULL
    [ ] // Call Populate()
    [ ]
    [ ]
    [ ] DB_FinishSql (hBuffer)
    [ ] DB_Disconnect (hDataBase)
    [ ]
    [-] except
    [ ] LogError("Exception on Check_Database()")
    [ ] ExceptPrint()
    [ ] DB_Disconnect (hDataBase)
    [ ] return FALSE
    [ ]
    [ ]
    [ ] return bSuccess
    [ ] <br clear=all><hr>Get your FREE download of MSN Explorer at http://explorer.msn.com
    </p>


    [Non-text portions of this message have been removed]


    Post message: silktest@yahoogroups.com
    Subscribe: silktest-subscribe@yahoogroups.com
    Unsubscribe: silktest-unsubscribe@yahoogroups.com
    List owner: silktest-owner@yahoogroups.com
    URL to this page: http://groups.yahoo.com/group/silktest


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



  2. #2
    Member
    Join Date
    Jun 2000
    Location
    Derby, UK
    Posts
    37
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to hadle null returned from DB_FETCHNEXT

    Your While statement will terminate when there are no records to return so the code within is never exececuted when youve no more data.
    Wouldnt you be more interested in count the number of records you have rather than interating thru them?
    Change the SQL you send then to something like:
    SELECT Count(*) FROM table WHERE column = '{iMyInteger}'"

    Which should return one value equal to the number of entries matching the query.


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

  3. #3
    Junior Member
    Join Date
    Apr 2000
    Location
    Cupertino,CA,95014
    Posts
    10
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to hadle null returned from DB_FETCHNEXT

    User Edward Dias (dsd_hca@hotmail.com) posted:

    Hi,

    My situation is this, before i start all my tests i want to look into the database and see if there is valid data to test, i dont want to delete the data after every test beacuse i have so many tests that use the same data, the ideal secnario is to create a method that will look for this data and place that at the beginning of every testcase, so i the databse query finds this data my testcase then would start, but if no data is found i have created another method that would generate the test data, my problem is that when no data is found the sOrderNo1 remains empty and does not proceed to call the populate method. I hope i have made this more clear

    TIA


    [ ] HANDLE hBuffer = DB_ExecuteSql (hDataBase, sSqlSelect1)
    [ ]
    [-] while (DB_FetchNext (hBuffer, sOrderNo1))
    [ ]
    [-] if sOrderNo1 != NULL // if data found, do nothing
    [ ] // Cool
    [ ]
    [-] if sOrderNo1 == NULL // if no data found, run Populate()
    [ ] // Call Populate()

    ----- Original Message -----
    From: Costigan, Polly
    Sent: Tuesday, May 01, 2001 9:58 AM
    To: 'Edward Dias'
    Subject: RE: [silktest] How to hadle null returned from DB_FETCHNEXT


    I'm not sure I totally understand what you're trying to do. You say that "but if no records are found I'm not able to go any further" - what does "go any further" mean? What is it that you want to do when "no records are found"?
    And what does it mean when the fetched record is NULL? I'm not familiar with NULL as the return value. Does this mean that something went wrong with your AUT because a NULL record got added and that's why you call the Populate function?


    -----Original Message-----
    From: Edward Dias [mailto:dsd_hca@hotmail.com]
    Sent: Monday, April 30, 2001 5:41 PM
    To: SilkTestGroup
    Subject: [silktest] How to hadle null returned from DB_FETCHNEXT
    Hi group,
    I'm working on this method that will query a database for some values, if those values are not found i will call another method to populate with the needed records. I am using DB_FETCHNEXT in my query, when the records are found it the databse it works great, but if no records are found I'm not able to go any further... here's a sample of my code maybe someone has a better idea on how to procced when i get no records returned from the db query. TIA


    [-] Check_Database()
    [ ]
    [ ] BOOLEAN bSuccess = TRUE
    [ ]
    [ ] STRING sOrderNo1 // use to store the found record
    [ ]
    [ ] HANDLE hDataBase = DB_Connect ()
    [ ]
    [ ]
    [-] do
    [ ]
    [ ] STRING sSqlSelect1 = "SELECT column FROM table WHERE column = '{iMyInteger}'"
    [ ]
    [ ] HANDLE hBuffer = DB_ExecuteSql (hDataBase, sSqlSelect1)
    [ ]
    [-] while (DB_FetchNext (hBuffer, sOrderNo1))
    [ ]
    [-] if sOrderNo1 != NULL
    [ ] // Cool
    [ ]
    [-] if sOrderNo1 == NULL
    [ ] // Call Populate()
    [ ]
    [ ]
    [ ] DB_FinishSql (hBuffer)
    [ ] DB_Disconnect (hDataBase)
    [ ]
    [-] except
    [ ] LogError("Exception on Check_Database()")
    [ ] ExceptPrint()
    [ ] DB_Disconnect (hDataBase)
    [ ] return FALSE
    [ ]
    [ ]
    [ ] return bSuccess
    [ ] <br clear=all><hr>Get your FREE download of MSN Explorer at http://explorer.msn.com
    </p>


    [Non-text portions of this message have been removed]


    Post message: silktest@yahoogroups.com
    Subscribe: silktest-subscribe@yahoogroups.com
    Unsubscribe: silktest-unsubscribe@yahoogroups.com
    List owner: silktest-owner@yahoogroups.com
    URL to this page: http://groups.yahoo.com/group/silktest

    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ <br clear=all><hr>Get your FREE download of MSN Explorer at http://explorer.msn.com
    </p>


    [Non-text portions of this message have been removed]


    Post message: silktest@yahoogroups.com
    Subscribe: silktest-subscribe@yahoogroups.com
    Unsubscribe: silktest-unsubscribe@yahoogroups.com
    List owner: silktest-owner@yahoogroups.com
    URL to this page: http://groups.yahoo.com/group/silktest


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



  4. #4
    Vic
    Vic is offline
    Junior Member
    Join Date
    Apr 2001
    Location
    San Francisco, CA 9416
    Posts
    17
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to hadle null returned from DB_FETCHNEXT

    I'm sure the problem is with NULL value. In Silk Scripts NULL is not a STRING. Your database query (i assume is returning a string), if not you may want to EXPLICITLY convert it to a STRING.
    You then want to change your code to:

    ...... ! == "NULL".

    i think this may work.

    -Vic

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

  5. #5
    Vic
    Vic is offline
    Junior Member
    Join Date
    Apr 2001
    Location
    San Francisco, CA 9416
    Posts
    17
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to hadle null returned from DB_FETCHNEXT

    Sorry i mean:

    [-] if sOrderNo1 == "NULL"
    [ ] // Call Populate()


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

 

 

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 02:26 AM.

Copyright BetaSoft Inc.