ASP + Oracle Stored Procedure return result set

Source: Internet
Author: User
<% @ Language = "VBScript" codePage = "936" lcid = "2052" %>
<% Option explicit %>
<%
'*************************************** *******
'Coding by sjcatsoft |
'Please keep the message, THX |
'*************************************** *******
%>
<! -- # Include file = "../adovbs. Inc" -->

<%
Dim cnora

Function connect2oracleserver
Dim constr
Constr = "provider = msdaora. Oracle; Data Source = xx; user id = Sr; Password = bjlt"
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 = ad1_text '= 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
Disconnectfromoracleserver
End sub


If connect2oracleserver then
Outputresult
Else
Response. Write (ERR. description)
End if

%>

<%
'-------------------------------------- SQL script ----------------------------------
'Build a package
'-----------------------------------
'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

'================================================ ======

'Build a package
'-----------------------------------
'Create or replace package body pkg_test
'Is
'
'Procedure getitem
'(P1 in number,
'P2 in varchar2,
'P3 out rfctest
')
'Is
'Begin'
'Open P3
'Select * From tablename where id = p1 and name = P2 and rownum <10;
'Exception
'When others then
'Null;
'End;
'
'End; -- package body pkg_test
%>
Related Article

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.