charles.han 发表于 2009-1-7 11:00:03

qtp从QC中取出Blob类型的数据报错

Set tdc = QCUtil.TDConnection
Set com = tdc.Command

sql="select rp_datafrom REPOSITORY where rp_id=5916" 'rp_data为Blob

com.CommandText = sql

Set Testrecordset = com.Execute '执行时候报错,没有具体的错误信息。

求助高手,如何读取oracle 数据库中的Blob 文件

charles.han 发表于 2009-1-7 17:39:44

用ADO搞定

Set Res = CreateObject("ADODB.Recordset")      
Set Cmd = CreateObject("ADODB.Command")      'Oracle   
StrCon ="DRIVER={Oracle in OraHome92};SERVER=localhost;UID=XXX;PWD=XXX;DBQ=XXX;DBA=W;APA=T;EXC=F;XSM=Default;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;GDE=F;FRL=Lo;BAM=IfAllSuccessful;MTS=F;MDI=Me;CSR=F;FWC=F;PFC=6000;TLO=O;"      
Cmd.activeconnection=StrCon   
Cmd.CommandType =1

SQL = " select rp_id,rp_data,rp_name,RP_PARENT_PATH from REPOSITORY where "
SQL = SQL &" rp_name='Results.xml' and RP_PARENT_PATH like (select RP_PARENT_PATH||'%' from REPOSITORY where RP_NAME="
SQL = SQL &" (select rn_path from run where rn_cycle_id='" & cycleid & "' and rn_test_id='" & testid & "' and rn_run_id=(select max(rn_run_id) from run where rn_cycle_id='" & cycleid & "' and rn_test_id='" & testid & "')))"
SQL = SQL &" and rp_id=(select max(rp_id) from REPOSITORY "
SQL = SQL &" where rp_name='Results.xml' and RP_PARENT_PATH like (select RP_PARENT_PATH||'%' from REPOSITORY where RP_NAME="
SQL = SQL &" (select rn_path from run where rn_cycle_id='" & cycleid & "'and rn_test_id='" & testid & "' and rn_run_id=(select max(rn_run_id) from run where rn_cycle_id='" & cycleid & "' and rn_test_id='" & testid & "'))))"

Cmd.CommandText=sql

SetRes = Cmd.Execute()

Filedata=Res.Fields.Item("rp_data")


set mstream = CreateObject("ADODB.Stream")

mstream.Type = 1 'adTypeBinary
mstream.Open
mstream.Write Filedata
mstream.SaveToFile "c:\Results.xml",2'

[ 本帖最后由 charles.han 于 2009-1-7 17:41 编辑 ]
页: [1]
查看完整版本: qtp从QC中取出Blob类型的数据报错