SPONSORS:






User Tag List

Results 1 to 5 of 5

Thread: DB_FetcNext

  1. #1
    Junior Member
    Join Date
    Aug 2001
    Location
    United Kingdom
    Posts
    17
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    DB_FetcNext

    Hi,

    I'm using DB_FetchNext to count the number of rows in a table which match particular criteria. I am having a problem where the last row seems to be read twice before the loop breaks.

    Why is this?


    ------------------------------------
    [ ] hstmnt = DB_ExecuteSql (hdbc, "select TEST_CODE from TEST_TABLE where ID = '{sID}' and ID_CODE= '{sID_CODE}'")

    [-] while bFetch == TRUE
    [ ] bFetch = DB_FetchNext (hstmnt, sRET)
    [ ]
    [ ] iDA++
    [ ] print ("######### sRET is ", sRET)
    [ ] print ("### iDA is ", iDA)
    [ ] DB_Disconnect (hdbc)

    == which results in =====================


    [ ] #### hdbc is H1048576
    [ ] ######### sRET is SPID_1
    [ ] ### iDA is 1
    [ ] ######### sRET is SPID_2
    [ ] ### iDA is 2
    [ ] ######### sRET is SPID_3
    [ ] ### iDA is 3
    [ ] ######### sRET is SPID_3
    [ ] ### iDA is 4


    - This is wrong! There are only 3 rows in the table that match but the last one is being returned twice.

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

  2. #2
    Senior Member
    Join Date
    Dec 2000
    Location
    Phoenix, AZ
    Posts
    371
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: DB_FetcNext

    I believe the problem lies in the code. You have while bFetch == TRUE. Well after the third row you received something so bFetch will be TRUE. Since it is TRUE it will have to try again.

    You may want to just try
    while (DB_FetchNext (hstmnt, sRET)) == TRUE

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

  3. #3
    Junior Member
    Join Date
    Aug 2001
    Location
    United Kingdom
    Posts
    17
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: DB_FetcNext

    You're right.
    I'd been fiddling with that so much this morning I'd lost track of what I was actually trying to do.
    You can always see much more clearly after a good lunch.

    Sorry for bothering you unneccesasrily, and thanks.

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

  4. #4
    Senior Member
    Join Date
    Jan 2002
    Location
    Des Moines, Iowa
    Posts
    289
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: DB_FetcNext

    To save a little coding you could.

    Just use the SQL to come up with the count. Then you could run the other select statement if you need the data from the query.

    It would be nice if 4Test could just give you a count. That was one of the very few things that I liked about Winrunner.


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

  5. #5
    Senior Member
    Join Date
    Dec 2000
    Location
    Phoenix, AZ
    Posts
    371
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: DB_FetcNext

    SMAN,
    You are not bothering us. Just give us some feedback when we post a question. Good luck with your future automation nightmares.

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

 

 

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 07:14 PM.

Copyright BetaSoft Inc.