How to pass a key in the query while creating a database check point?

Hi, Would be great if you could let me know how to pass a key in the query while creating a database check point? My key value is stored in a variable in the script.

In short, what I want to know is:

myVar='keyvalue'

select * from myTable where myKey='keyvalue';

Instead of specifying the query like select * from myTable where myKey='keyvalue'; in the database checkpoint, I want to use the variable myVar so that the 'keyvalue' can be dynamically attributed.
Thanks.

Questions by animesh_QTP

Showing Answers 1 - 18 of 18 Answers

I too have the same question. How can we pass a varible while creating a DB checkpoint. Is it even possible ?


I would like to do something like

QTP script
variablename=somevalue

select * from table where col=variablename

instead of doing
select * from table where col=123

Thank you
Sairam

  Was this answer useful?  Yes

abihari

  • Dec 26th, 2007
 

I don't think it is possible tp parametrize a checkpoint. A db checkpoint says, you have a expected set of data (which is obtained only from a query with hard coded values) and this is compared with the run-time query execution(which is dynamic).

I do not know if you did find a solution to the problem you have posted. Do let us know if there is any solution to parametrizing or some other way to go around the problem.

  Was this answer useful?  Yes

angiemercy

  • Jan 16th, 2008
 

I would like to do something like

QTP script
variablename=somevalue

select * from table where col=variablename

instead of doing
select * from table where col=123

Sairam, this is quite possible from my experience.
Instead of
variablename=somevalue

make it as a function, pass the somevalue

like,

function func(variablename)
select * from table where col=variablename
end function

Call func(somevalue)

it will work....

let me know after trying this.

Good Luck.

  Was this answer useful?  Yes

ManjuPillae

  • Mar 26th, 2008
 

'Assume that 'key' values are present 'keyValues' column under the Local datasheet


For ...
...
    myVar = DataTable("keyValues",dtLocalSheet)
    select * from myTable where myKey=myVar;
...
Next

In this way we can send new values each iteration and new query will be executed

  Was this answer useful?  Yes

sri_yarley

  • Apr 16th, 2008
 

While a database checkpoint is created, the select statement gets stored in "Source".

So for parameterizing it, Create a checkpoint initially in the normal flow with a constant value.....and then parametrize it by updating with SETTOPROPERTY command as shown below....


a="select * from tablename where colname='" & datatable("colnameinqtp",dtlocalsheet) & "'


dbtable("dbtable").settoproperty "source",a


hope this will help u....

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions