Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
using queries in functions (Store Procedures)
#1
Not Solved
Hi all,

Code:
if not exists (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')
print 'WARNING: Locality not Exists'
else
Print 'Locality Exists'

now my issue is : How do i use this type of query or store procedure in QTP 10,
Note: while creating DBcheckPoint it could not create. and while pasting this in function too QTP 10 shows errors, so how do i do , if kindly help,
Waiting for the reply thank you.
Note 1: while replacing print with MsgBox too errors were found.
Thank you,
Samson.B
Reply
#2
Not Solved
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

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.

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  VB Script to separate upper & small Letters from a string and store in excel pradeep537 1 2,214 08-05-2016, 12:26 AM
Last Post: Ankur
  Perform some functions whenever QTP Stop button is pressed smartkarthi 2 3,222 08-22-2013, 11:43 AM
Last Post: smartkarthi
  exit parent functions as well Shridevi.Salagare 3 3,869 07-31-2013, 12:15 AM
Last Post: Ankur
  Datatable in functions shwetasharma 2 3,521 03-26-2013, 08:00 AM
Last Post: sams001
  Problem with using two functions in the same action mhanaan 2 3,043 09-14-2012, 10:09 PM
Last Post: mhanaan

Forum Jump:


Users browsing this thread: 1 Guest(s)