Micro Focus QTP (UFT) Forums
Importing Oracle Database data to RunTime datatable - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Importing Oracle Database data to RunTime datatable (/Thread-Importing-Oracle-Database-data-to-RunTime-datatable)



Importing Oracle Database data to RunTime datatable - prabhu656656 - 02-04-2010

Hi,
Is there a method or script that could Import Oracle Database data to RunTime datatable in QTP.

Thank You.
Prabhu
______________


RE: Importing Oracle Database data to RunTime datatable - Jackomcnabb - 02-04-2010

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


RE: Importing Oracle Database data to RunTime datatable - Jackomcnabb - 02-04-2010

'
'--- 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


RE: Importing Oracle Database data to RunTime datatable - jparson11 - 01-22-2011

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