经过摸索和实践,我把自己的解决方法,写在下面:
说明:
我的Oracle客户端的版本是 oracle 9i, 安装client端的时候,不能用默认安装,一定要自定义, 然后选择所有 OLEDB 相关的内容,都装上,否则到下面的 Provider 的时候,会找不到。
复制代码 代码如下:
<%@Language="VBSCRIPT" CodePage="936" LCID="2052"%>
<%Option Explicit%>
<!-- #include file="../adovbs.inc" -->
<%
Dim cnOra
Function Connect2OracleServer
Dim conStr
conStr = "Provider=MSDAORA.Oracle;Data Source=xx;User Id=?;Password=?"
Set cnOra = Server.CreateObject("ADODB.Connection")
cnOra.CursorLocation = adUseClient '=3
On Error Resume Next
cnOra.Open conStr
Connect2OracleServer = (Err.Number = 0)
End Function
Sub DisconnectFromOracleServer
If Not cnOra is Nothing Then
If cnOra.State = 1 Then
cnOra.Close
End If
Set cnOra = Nothing
End If
End Sub
Sub Echo(str)
Response.Write(str)
End Sub
Sub OutputResult
Dim cmdOra
Dim rs
Set cmdOra = Server.CreateObject("ADODB.Command")
With cmdOra
.CommandType = adCmdText '=1
.CommandText = "{call PKG_TEST.GetItem(?,?)}"
.Parameters.Append cmdOra.CreateParameter("p1", adNumeric, adParamInput, 10, 1)
.Parameters.Append cmdOra.CreateParameter("p2", adVarChar, adParamInput, 10, "xx")
.ActiveConnection = cnOra
Set rs = cmdOra.Execute
If Not rs.Eof Then
While Not rs.Eof
Echo rs(0)
Echo "--"
Echo rs(1)
Echo "<br>"
rs.MoveNext
Wend
rs.Close
End If
Set rs = Nothing
Set cmdOra = Nothing
End With
DisconnectFromOracleServer
End Sub
If Connect2OracleServer Then
OutputResult
Else
Response.Write(Err.Description)
End If
%>
下面是 Oracle 的 sql 脚本
--------------------------------------SQL Script----------------------------------
--建包-----------------------------------
复制代码 代码如下:
Create Or Replace Package PKG_TEST
IS
TYPE rfcTest IS REF CURSOR ;
PROCEDURE GETITEM
( p1 IN NUMBER,
p2 IN VARCHAR2,
p3 OUT rfcTest
);
END; -- Package Specification PKG_TEST
---------------------------------------------------
--建包体-----------------------------------
Create Or Replace Package Body PKG_TEST
IS
PROCEDURE GETITEM
( p1 IN NUMBER,
p2 IN VARCHAR2,
p3 OUT rfcTest
)
IS
BEGIN
OPEN p3 FOR
SELECT * FROM tablename WHERE id = p1 AND name=p2 AND rownum < 10 ;
EXCEPTION
WHEN OTHERS THEN
NULL ;
END;
END; -- Package Body PKG_TEST
说明:
我的Oracle客户端的版本是 oracle 9i, 安装client端的时候,不能用默认安装,一定要自定义, 然后选择所有 OLEDB 相关的内容,都装上,否则到下面的 Provider 的时候,会找不到。
复制代码 代码如下:
<%@Language="VBSCRIPT" CodePage="936" LCID="2052"%>
<%Option Explicit%>
<!-- #include file="../adovbs.inc" -->
<%
Dim cnOra
Function Connect2OracleServer
Dim conStr
conStr = "Provider=MSDAORA.Oracle;Data Source=xx;User Id=?;Password=?"
Set cnOra = Server.CreateObject("ADODB.Connection")
cnOra.CursorLocation = adUseClient '=3
On Error Resume Next
cnOra.Open conStr
Connect2OracleServer = (Err.Number = 0)
End Function
Sub DisconnectFromOracleServer
If Not cnOra is Nothing Then
If cnOra.State = 1 Then
cnOra.Close
End If
Set cnOra = Nothing
End If
End Sub
Sub Echo(str)
Response.Write(str)
End Sub
Sub OutputResult
Dim cmdOra
Dim rs
Set cmdOra = Server.CreateObject("ADODB.Command")
With cmdOra
.CommandType = adCmdText '=1
.CommandText = "{call PKG_TEST.GetItem(?,?)}"
.Parameters.Append cmdOra.CreateParameter("p1", adNumeric, adParamInput, 10, 1)
.Parameters.Append cmdOra.CreateParameter("p2", adVarChar, adParamInput, 10, "xx")
.ActiveConnection = cnOra
Set rs = cmdOra.Execute
If Not rs.Eof Then
While Not rs.Eof
Echo rs(0)
Echo "--"
Echo rs(1)
Echo "<br>"
rs.MoveNext
Wend
rs.Close
End If
Set rs = Nothing
Set cmdOra = Nothing
End With
DisconnectFromOracleServer
End Sub
If Connect2OracleServer Then
OutputResult
Else
Response.Write(Err.Description)
End If
%>
下面是 Oracle 的 sql 脚本
--------------------------------------SQL Script----------------------------------
--建包-----------------------------------
复制代码 代码如下:
Create Or Replace Package PKG_TEST
IS
TYPE rfcTest IS REF CURSOR ;
PROCEDURE GETITEM
( p1 IN NUMBER,
p2 IN VARCHAR2,
p3 OUT rfcTest
);
END; -- Package Specification PKG_TEST
---------------------------------------------------
--建包体-----------------------------------
Create Or Replace Package Body PKG_TEST
IS
PROCEDURE GETITEM
( p1 IN NUMBER,
p2 IN VARCHAR2,
p3 OUT rfcTest
)
IS
BEGIN
OPEN p3 FOR
SELECT * FROM tablename WHERE id = p1 AND name=p2 AND rownum < 10 ;
EXCEPTION
WHEN OTHERS THEN
NULL ;
END;
END; -- Package Body PKG_TEST
标签:
Asp,Oracle,存储过程
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“Asp Oracle存储过程返回结果集的代码”评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。