Forum Discussion
tristaanogre
Esteemed Contributor
Actually, as a matter of fact, you can. I have a script extension I've developed that will do that. Basically, if you can write what you want as Transact-SQL, you should be able to execute it using that extension.
If you don't want to use the extension, check out https://support.smartbear.com/testcomplete/docs/testing-with/advanced/working-with-external-data-sources/databases/using-ado-and-bde-objects/index.html. The examples that are included have hardcoded strings as the SQL query. Replace those strings with a parameter from the function and you should be able to send any SQL query you want to to the function.
mspatel
8 years agoContributor
Hi ,
Thanks a lot. Do you happened to have code using all these function calls ?
- tristaanogre8 years agoEsteemed Contributor
Here's an example:
//The following function can be included in any project but it only ever needs to be run the first time to set up the desired settings function SQLOptions(){ SQLUtilities.SetSQLType = 'MSSQL'; //Can be either MSSQL or MYSQL_351 SQLUtilities.SetSQLSecurityType = 'INTEGRATED'; //Can be either INTEGRATED or PROMPT } //Now, if I want to run an SQL query against my database where I log the street address for all addresses in Pennsylvania, USA function getPAStreetAddresses() { var mySQLQuery; var myRecords; SQLUtilities.DatabaseName = 'MyDatabase'; SQLUtilities.SQLServerName = 'MyServer'; SQLUtilities.SQLUserName = 'myusername'; //This is not necessary since I'm using integrated security. Provided in example to allow for editing and adaptation SQLUtilities.SQLPassWord = 'mypassword'; //This is not necessary since I'm using integrated security. Provided in example to allow for editing and adaptation mySQLQuery = SQLUtilities.NewSQLQuery('SELECT * FROM ADDRESSES WHERE STATE = :STATE and COUNTRY = :COUNTRY', {STATE: 'PA', COUNTRY: 'USA'}, false); mySQLQuery.open(); myRecords = mySQLQuery.execute(); while (!myRecords.EOF) { Log.Message('Street Address: ' + myRecords.Fields.Item('STREETADDRESS').Value); myRecords.MoveNext(); } mySQLQuery.closeAndNull; }
Related Content
- 4 years ago
- 2 years ago
Recent Discussions
- 18 hours ago
- 19 hours ago
- 5 days ago