Forum Discussion

santineu's avatar
santineu
Occasional Contributor
13 years ago

Adding DBTable’s Data

Hi,



When I do custom query in the DBTables, it will return me some records.

Is it possible for me to add new record instead of modifying the existing record?

Thank you.

8 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    I'm not entirely sure what you're asking.  Essentially, the DBTables objects are designed to be "snapshots" of the state of a database based upon either the whole table or on a custom query.  If you need to change the data in a DBTable object, I think you can edit individual fields but I'm not sure if you can add records.



    Could you describe what you're trying to achieve by doing this edit?


  • santineu's avatar
    santineu
    Occasional Contributor

    Hi,



    Actually we would like to reduce the time of doing 'snapshots' for every scenario.

    In the attached screenshot; we use the custom query to select 'LeaveDate' and 'LeaveAmount' columns from TblLeaveEmployee table which returns no record; therefore we would like to add 'LeaveDate' and 'LeaveAmount' values

    Is it possible to do so? Please refer to the attached file for more details.

    Thank you

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    There currently is no way to add rows into a DBTables item, at least not that I could find.



    A method we used in the past, though, is to not use DBTables but to create an object using the ADODB objects where we would query the table, dump it to a CSV file and then do a comparison of CSV to CSV.  You can then easily add rows to the CSV file to update your different scenarios without having to re-query the tables.
  • VLapidus's avatar
    VLapidus
    Frequent Contributor
    Santi, please tell us whether suggestions above are suitable or describe your task in detail
  • santineu's avatar
    santineu
    Occasional Contributor
    I'll have to try that method first to see whether it's a good alternative way.

    Will be back~



    Thanks Robert!!!



  • santineu's avatar
    santineu
    Occasional Contributor
    I'll have to try that method first to see whether it's a good alternative way.

    Will be back~



    Thanks Robert!!!




  • Hello Santi,





    Robert is right, there is no way to add rows to a DBTable element.





    You can also try creating a table variable that contains some baseline data, getting data from your database via ADO and then, comparing the retrieved values with those stored in the table variable. The Iterator.Value help topic contains an example that shows how to iterate through the table variable rows. Instead of posting a message to the log (the 'Log.Message(...)' line), you can use the if...then statement to compare the values with the ones retrieved from a database by using the example in the Using ADO Components help topic.