ASP Oracle Stored procedures return a result set of code _ database related

Source: Internet
Author: User
After groping and practicing, I put my own solution, written in the following:
Description
The version of my Oracle client is Oracle 9i, when the client side is installed, you cannot use the default installation, be sure to customize it, and then select all OLE DB-related content to install, otherwise you will not find it when you go to the Provider below.
Copy Code code as follows:

<% @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 are 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, ten, "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
%>

The following is an Oracle SQL script
--------------------------------------SQL Script----------------------------------
--Build the package-----------------------------------
Copy Code code as follows:

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
---------------------------------------------------
-- The build-----------------------------------
Create Or Replace Package body pkg_test
is
PROCEDURE getitem (P1 in number,
P2 in VARCHAR2,
P3 out rfctest
)
are
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.