03-12-2010, 01:20 PM
Hi Samson,
you can not directly use a query to put in if condition.
you will need to exceute these query and compare the recordset.
steps you can follow -
1 connect to DB
2 execute your query
3 get the recordset
4 then compare the values
e.g in your case here
while creating DBCheckpoint put the same query there.
you can not directly use a query to put in if condition.
you will need to exceute these query and compare the recordset.
steps you can follow -
1 connect to DB
2 execute your query
3 get the recordset
4 then compare the values
e.g in your case here
Code:
Dim oConnection,ConnectionString , oRecordSet
ConnectionString ="<Connection string to Connect to DB>" 'refer https://www.learnqtp.com/qtp-database-part2-how-to-create-connection-strings/
Set oConnection = CreateObject("ADODB.Connection")
Set oRecordSet = CreateObject("ADODB.Recordset")
oConnection.Open ConnectionString
strSQL = "select l.Locality from TgnTerritorydtl tdtl, tgnLocality l, Tgncompany C where
l.localityid= tdtl.localityid and c.companyid=l.companyid and
c.company='company' and l.Locality='123'"
oRecordSet.Open strSQL,oConnection, adOpenStatic
if oRecordSet.Fields("Locality").value <> null then 'or you can get the record count here if > 0 then locality exists
print "Locality Exists"
else
print "Locality Not Exists"
end if
while creating DBCheckpoint put the same query there.