Ask a Question

Can we edit SQL query on DBTables in running time

tuanvinh1008
Contributor

Can we edit SQL query on DBTables in running time

Hi all,

In the DBTables, we can customize the SQL query at the Design but how about if I want to modify the query in running time? because my scenario there are some field will be generated after do some steps.

 

Thanks,

Vinh

4 REPLIES 4
vinniew
Staff

Hi @tuanvinh1008 

 

In TestComplete, I dont think you can modify the query at run time. 

 

Happy to get another members response on that as I am not 100% certain.

 

If needed, you could perhaps import dB libraries and maybe import a script to do this.  

 

However, the query should still work no? 

 

I mean your not creating new tables or columns every time you run a test or are you? 

 

KR

Vinnie

@vinniew Thanks for your reply

mcbane
Occasional Contributor

If you're wanting the same thing I needed--YES!

 

In JavaScript, I have variables setup as generic SQL queries. For example, to run a query against a specific account, I use a text variable with a value like:

 

select *

from table

where account = 12345670

 

Before I execute the query, I run a replace command to set it to the actual account I need for that particular run:

 

Query = ProjectSuite.Variables.SQLQueryVariable.replace(new RegExp("12345670","g"),"8675309");
RecSet = AConnection.Execute_(Query);

 

TestComplete replaces 12345670 with the account number I need, and then executes the query.

 

I hope this helps!

Tommy

sonya_m
SmartBear Alumni (Retired)

Thanks everyone for trying to help!

 

@tuanvinh1008 did you manage to solve this? Looks like mcbane has an idea of what could work.


Sonya Mihaljova
Community and Education Specialist

cancel
Showing results for 
Search instead for 
Did you mean: