使用经典asp进行SQL到Oracle的迁移

时间:2013-10-02 10:17:27

标签: sql-server oracle asp-classic

我正在开发一个sql到oracle的迁移。 我从未使用过经典的asp,我可以在这方面使用一些帮助。

这是我现在的代码

<select onChange="AlterarDisabled();/*DGT();*/" name="TIPO_PLANO" id="TIPO_PLANO">
<%
    sSql = "TP_15_SP" & "'" & ENTIDADE & "'"

    set oRS = GlobaloConn.Execute(sSql)

    do while not oRS.Eof
        if oRS.Fields(0) = "04" then
        if BALCAO = "B0142" or BALCAO= "B0593" then
            %><option value="<%=oRS.Fields(0)%>"><%=oRS.Fields(1)%></option><%
            end if
    else
        %><option value="<%=oRS.Fields(0)%>"><%=oRS.Fields(1)%></option><%
    end if
    oRS.MoveNext
     loop

     set oRS = nothing
%>
</select>

这是sql存储过程

USE [TPS]
GO
/* Object:  StoredProcedure [dbo].[TP_15_SP] Script Date: 10/02/2013 11:09:46 */
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[TP_15_SP] @CdEnt VARCHAR(4)
AS
SELECT * FROM TP_15
WHERE CDENT = @CdEnt
ORDER BY 1

现在我必须连接到Oracle并运行oracle函数。 这是oracle函数

create or replace 
function TP_15_FN(v_CdEnt IN VARCHAR2) return SYS_REFCURSOR
as
l_return   SYS_REFCURSOR;
BEGIN
-- This procedure was converted on Fri Apr 05 17:05:05 2013
   open l_return for SELECT * FROM TP_15
   WHERE CDENT = v_CdEnt
   ORDER BY 1 NULLS FIRST;

   return l_return;
END;

这是我应该用来调用该函数的代码。据说我只需要改变 sSql = "TP_15_SP" & "'" & ENTIDADE & "'" sSql = "TP_15_FN(" & "'" & ENTIDADE & "')"<select onChange="AlterarDisabled();/*DGT();*/" name="TIPO_PLANO" id="TIPO_PLANO"> <% sSql = "TP_15_FN(" & "'" & ENTIDADE & "')" set oRS = GlobaloConn.Execute(sSql) do while not oRS.Eof if oRS.Fields(0) = "04" then if BALCAO = "B0142" or BALCAO= "B0593" then %><option value="<%=oRS.Fields(0)%>"><%=oRS.Fields(1)%></option><% end if else %><option value="<%=oRS.Fields(0)%>"><%=oRS.Fields(1)%></option><% end if oRS.MoveNext loop set oRS = nothing %> </select> 。 它没有用,有什么想法吗?

{{1}}

1 个答案:

答案 0 :(得分:0)

我设法自己解决了,这很好。这是我的最终代码。 我还必须将PLSQLRSet=1添加到我的连接字符串中。

Set cmd = Server.CreateObject("ADODB.Command")
Set oRS = Server.CreateObject("ADODB.Recordset")

With cmd
    .ActiveConnection = GlobaloConn
    .CommandText = "TP_15_SP"
    .CommandType = 4 'adCmdStoredProc
    .Parameters.Append cmd.CreateParameter("v_CdEnt", 129 , 1 , 4, ENTIDADE)
End With

Set oRS = cmd.Execute   

do while not oRS.Eof 
    if oRS.Fields(0) = "04" then
        if BALCAO = "B0142" or BALCAO= "B0593" then
            %><option value="<%=oRS.Fields(0)%>"><%=oRS.Fields(1)%></option><%
        end if
    else
        %><option value="<%=oRS.Fields(0)%>"><%=oRS.Fields(1)%></option><%
    end if

    oRS.MoveNext
loop

oRS.Close

Set oRS  = nothing
Set cmd  = nothing