标题: qtp 读取数据库里的数据 [打印本页] 作者: qdd6501 时间: 2011-4-6 16:52 标题: qtp 读取数据库里的数据 当我有一条普通的sql语句的时候,我用下面的vbscript代码去执行这条sql,从而把oracle数据库里相应的数据取出来:
Public Function GetMultiRowData(sqlQuery,intColNum,arrExpData())
Dim rowcount
Set oResultSet = oCon.Execute(sqlQuery)
' Place the cursor at the first record
'oResultSet.MoveFirst
rowcount =0
Do Until oResultSet.EOF
rowcount=rowcount + 1
oResultSet.MoveNext
Loop
If rowcount>=1 Then
ReDim arrExpData(rowcount,intColNum)
rowcount =0
oResultSet.MoveFirst
Do Until oResultSet.EOF
For i = 0 to intColNum
arrExpData(rowcount,i) = oResultSet.Fields(i)
Next
oResultSet.MoveNext
rowcount=rowcount + 1
Loop
oResultSet.close
Set oResultSet = Nothing
else
End If
begin
--- get port_key for the selected primary portfolio
select port_key
into n_port_key
from gdm_psr_dim_portfolio
where port_new_code = s_selected_portfolio
and port_record_Status ='A' ;
--- get date_key for inception date and to date
select dimd_date_key
into n_inception_date_key
from gdm_psr_dim_date
where dimd_full_date = s_inception_date ;
select dimd_date_key
into n_to_date_key
from gdm_psr_dim_date
where dimd_full_date = s_to_date ;
--functional currency key for the portfolio
select cccy_key
into n_base_curr_key
from gdm_psr_currency
where cccy_record_status = 'A'
and cccy_code = (select port_primary_ccy from gdm_psr_dim_portfolio where port_new_code = s_selected_portfolio and port_record_Status ='A' ) ;
---current market value
--get starting cash
select tmtr_amount
into n_starting_cash
from (
select tmtr_amount,tmtr_trade_date_key
from GDM_PSR_FACT_TM_TRANSACTION
where tmtr_amount is not null and tmtr_amount <> 0 and TMTR_CATEGORY_CD = 3 and tmtr_type_key = 521 -- 700 cash contrib
and tmtr_port_key = n_port_key
and ( select MGRG_MANAGER_GROUP_CODE from GDM_PSR_DIM_MANAGER_GROUP where mgrg_manager_group_key = tmtr_manager_group_key) = '5CA'
and ( select basi_currency_basis_code from GDM_PSR_DIM_BASIS where basi_basis_key = tmtr_basis_key and basi_currency_basis_desc = 'FUNCTIONAL' and basi_currency_basis_code = 2) = 2
and ( select basi_date_basis_desc from GDM_PSR_DIM_BASIS where basi_basis_key = tmtr_basis_key ) = 'Trade'
order by tmtr_trade_date_key
) where rownum = 1 ;