Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How do I dynamically create tables in a database to hold testcase information?

How do I dynamically create tables in a database to hold testcase information?

Problem:

How do I dynamically create tables in a database to hold testcase information?

Resolution:

QUESTION
----------------------------------

How do I dynamically create tables in a database to hold testcase information?

ANSWER
----------------------------------

Firstly you will have to create a database and connect to it using DSN (Database Source Name).
See resolution 21590

The attached testcase uses the function ResultDB( ) to create and insert fields in a specified table.
You will have to create a record to store your testcase information and specify a table name to store
the records in. (one defined record per specified table)

Example Record:

[-] type RESULTS is record
    [ ] STRING sTestString
    [ ] STRING sActualString
    [ ] STRING sPass
    [ ] Integer iNumber


Example function call:



The first time you call ResultDB( )

  • Your specified table and structure will be created (the fields of the table will be text)
  • Fields created in table are field1, field2, field3...
  • Your record will be added to the specified table.


The second time you call ResultDB( )

  • The function will check if a table exists(if it does not it will be created)
  • Your record will be added to the specified table.


Advantages:

  • Tables can be created dynamically to store testcase information
  • You can create records to store different information for each testcase


To run the following working example;

Download the two files below and then make sure to set up a DSN called "MyDataSource" pointing to the
db1.mdb file before running the testcase.

Example Database:  db1.mdb
Example SilkTest 7.5 Script:  Add_Results_to_DB_Table.t



Related documents:


Old KB# 21207

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:17
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.