SPONSORS:






User Tag List

Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Jan 2002
    Location
    Nuremberg, Germany
    Posts
    77
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reading a database & using arrays in records

    Suppose I have a database table with 10 columns of string values, say A1,...,A5,B1,...,B5. I'd like to read the table entries into a 4test structure like this:

    type TABLE_AS_ARRAYS is record
    Array[5] of String A_Values
    Array[5] of String B_Values

    A direct DB_FetchNext into this structure won't work because SilkTest expects an array when it fills A_Values, not a singular String like A1.

    Browsing through this forum I found many similar discussions, but not exactly the one I'm after. First, it seems a good idea to read the table entries into a LIST OF STRING (then of length 10). But then, you'd have to seperate this list into sublists of length 5, afterwards assigning them to the structure as follows:

    TABLE_AS_ARRAYS MyArrays
    MyArrays.A_Values = SubList1
    MyArrays.B_Values = SubList2.

    This works, but is a downer somehow (clearly, my real structure is much more complicated and so there arises huge effort for a seemingly "simple" task). My question to you is: Does anybody know a more elegant way of filling the structure as desired?

    Thanks in advance, cb

  2. #2
    Senior Member
    Join Date
    Aug 1999
    Location
    Cambridge, UK
    Posts
    470
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Reading a database & using arrays in records

    If your priority is having a 4test structure such that reading database data into the structure is easy, then just go for a record type with ten string fields.
    If having the record type with the two arrays of five string fields is important to you, then you will have to manually translate the data received back from the database record (as a list of anytype or whatever) into the format you want. But writing a reusable function to do this won't take very long, and doesn't sound like that much effort really.

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

  3. #3
    Member
    Join Date
    Jan 2002
    Location
    Nuremberg, Germany
    Posts
    77
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Reading a database & using arrays in records

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by vincebowdren:
    If having the record type with the two arrays of five string fields is important to you, (...)<HR></BLOCKQUOTE>

    Yes it is. I used to have a record type with simply ten strings before that and enjoyed transferring stuff from the database by a simple FetchNext command... Writing the function you mentioned (which I'd say is the same kind of solution I tried to sketch in my post) isn't difficult nor complicated but can lead to an increasing need of synchronizing code after database changes because there might be much more hardcoded target structure pouring in. (It was somehow funny to learn that there are several 4test commands to avoid this like TypeOf, reference (@) etc, but they can only be used if the structure is already filled - but that's what I intend to do. )

    Anyway, thanks a lot for your reply!

  4. #4
    Member
    Join Date
    Jan 2002
    Location
    Nuremberg, Germany
    Posts
    77
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Reading a database & using arrays in records

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by jamesso:
    Why are you using ARRAYS instead of LISTS? There are some rare occaisions where I use them, but I find the LIST datatype to be much more flexible.....
    <HR></BLOCKQUOTE>

    I totally agree, but in this special case we found arrays to be the more natural choice - one of these "rare occasions".

  5. #5
    Super Member
    Join Date
    Jul 2001
    Location
    Earth
    Posts
    1,882
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Reading a database & using arrays in records

    Why are you using ARRAYS instead of LISTS? There are some rare occaisions where I use them, but I find the LIST datatype to be much more flexible.....

    ------------------
    James Soderborg
    http://www.ameliortech.com
    jamesso@ameliortech.com

 

 

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 05:32 PM.

Copyright BetaSoft Inc.