Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Importing Oracle Database data to RunTime datatable
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi,
Is there a method or script that could Import Oracle Database data to RunTime datatable in QTP.

Thank You.
Prabhu
______________
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
I haven't loaded a batabase into datatable but I have loaded a database inot the an array.... which would be much faster to query would this help at all
Reply
#3
Solved: 11 Years, 3 Months, 4 Weeks ago
'
'--- Run SQL query to create record set ---
'
Code:
With RecordSet
    .ActiveConnection = connString
    .CursorLocation = adUseClient
    .CursorType = adOpenDynamic
    .Open strSQL1, , , , adCmdText
    Set LineItem = RecordSet
End With

strSQL1 is the Query that would be run to make the data you need to be loaded
Reply
#4
Solved: 11 Years, 3 Months, 4 Weeks ago
This will connect to ORacle and run a SQL query and return the results to the runtime datatable. It uses the field names from the query as the column names in the Excel format.


Code:
Dim adocon,adorecordset
Set adocon=CreateObject("ADODB.Connection")
constr="Provider=OraOLEDB.Oracle.1;Password=XXXX;Persist Security Info=True;User ID=XXXX;Data Source=Dev"
adocon.Open constr
Set adorecordset=CreateObject("ADODB.Recordset")
Set adorecordset.ActiveConnection=adocon
Strsql="Select 'TEST PRICE LIST:' || to_char(sysdate,' MM-DD-YY HH:MM:SS') as PRICE_LST_NAME from Dual"
adorecordset.Source=Strsql
adorecordset.Open
set outsheet=Datatable.Addsheet("output")
For each fld in adoRecordset.Fields
    outsheet.AddParameter fld.name,""
Next
i=1
Do while Not adorecordset.EOF
DataTable.SetCurrentRow(i)
For each fld in adorecordset.Fields
outsheet.GetParameter(fld.name).value=fld.value
Next
adorecordset.MoveNext
i=i+1
Loop
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Importing data sheet Santu 2 3,377 08-20-2015, 11:37 PM
Last Post: ADITI1992
Smile Importing Excel sheet - Reference Values are not recognized michiusa69 3 7,880 01-23-2015, 02:36 AM
Last Post: lkng2001
  Find a text in Runtime datatable ra.dineshkumar@gmail.com 1 1,996 12-01-2014, 06:18 PM
Last Post: supputuri
  Invalid File error importing a spreadsheet but only on a VM msacks 1 2,739 10-19-2014, 09:04 PM
Last Post: supputuri
  Function writes data from datatable to database Fairbanks 0 2,575 06-27-2014, 07:51 PM
Last Post: Fairbanks

Forum Jump:


Users browsing this thread: 3 Guest(s)