TSQL过程调用PLSQL过程:ORA-06502:PL / SQL:数值或值错误

时间:2017-01-05 19:35:54

标签: tsql plsql numeric varchar2 ora-06502

我有一个调用Oracle过程的T-SQL过程传入一些参数。 我的oracle过程工作正常,并按预期返回输出参数。 但是,当从T-SQL过程调用oracle过程时,我有以下错误。我不明白为什么我得到这个。两种程序都使用变速器。

  

(1行(s)受影响)OLE DB提供程序“OraOLEDB.Oracle”用于链接   服务器“ORA_LINK_SERVER”返回消息“ORA-06502:PL / SQL:数字   或值错误ORA-06512:在“DBNAME.GETSHELLACNOANDINSTRUCTIONNO”,   第7行“。

     

(1行受影响)

     

(1行(s)受影响)Msg 7215,Level 17,State 1,Procedure   USP_TXN_PF_CLIENT_URL_NEW,第56行无法执行语句   远程服务器'ORA_LINK_SERVER'。

这是我的T-SQL程序

    USE [TVE]
    GO
    /****** Object:  StoredProcedure [CompanyName].[USP_TXN_PF_CLIENT_URL]    Script Date: 12/29/2016 11:14:02 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO


        --To test +
        /*
            Declare @ReturnString varchar(255)
            EXEC [CompanyName].[USP_TXN_PF_CLIENT_URL_NEW] 'CompanyName','50585609',@ReturnString = @ReturnString OUTPUT    
            select @ReturnString    
    */

   /*
        ALTER TABLE [dbo].[PF_CLIENT_URLS]  
        ADD [STATUS] VARCHAR(1) NULL  
        GO 


        SELECT * FROM [dbo].[PF_CLIENT_URLS]
    */
        ALTER PROCEDURE [CompanyName].[USP_TXN_PF_CLIENT_URL_NEW]
        (
            @IN_PMancoID        VARCHAR(10),
            @IN_PInvestorRef    VARCHAR(12),
            @ReturnString       varchar(255) OUTPUT 
        )
        AS
        BEGIN
        DECLARE @runStr VARCHAR(2000)
        DECLARE @URL varchar(36)
        DECLARE @MessageID AS VARCHAR(40), @RecipientID AS VARCHAR(40), @FileName VARCHAR(40),@ResponseFileName VARCHAR(40), @Message VARCHAR(500),
                @Cell VARCHAR(35), @OUT_ShellAccountNumber VARCHAR(40), @OUT_InstructionNumber VARCHAR(40)


        DECLARE @ParamKeys VARCHAR(max), @ParamValues VARCHAR(max), @Return_ID INT, @Current_User_ID INT,
                @ErrorNumber INT, @ErrorSeverity INT, @ErrorState INT, @ErrorLine INT, 
                @ErrorMessage nVARCHAR(2048), @LogInfo_ID INT, @ProcedureName NVARCHAR(126),
                @ProfileName VARCHAR(50), @Recipients VARCHAR(max), @Subject VARCHAR(100), @Body VARCHAR(max)

        Set @ProcedureName = 'YYYY.USP_PF_CLIENT_URL_NEW'
        Set @ParamKeys = '' 
        Set @ParamValues = ''
        set @URL = newID()

        Set @ParamKeys =    'IN_PMancoID' + '|' +
                            'IN_PInvestorRef' 


        Set @ParamValues =  ISNULL(CONVERT(VARCHAR(max),@IN_PMancoID),'NULL') + '|' +
                            ISNULL(CONVERT(VARCHAR(max),@IN_PInvestorRef),'NULL')

        exec [DYNAMIC].[ss_StoredProcLogInfo_Save]  @ProcName = @ProcedureName,
                                                    @ParameterKeys = @ParamKeys,
                                                    @ParameterValues = @ParamValues,
                                                    @User_ID = @Current_User_ID,
                                                    @Return_ID = @Return_ID OUTPUT

        exec ('CALL DBNAME.GETSHELLACNOANDINSTRUCTIONNO(?,?,?)', @IN_PInvestorRef, @OUT_ShellAccountNumber, @OUT_InstructionNumber) AT ORA_LINK_SERVER

        INSERT INTO [dbo].[TableName]([UserID],[MancoID],[Reference],[DateCreated],[LoginAttempts],[STATUS],[ShellAccount],[InstructionNumber]) 
        values(ISNULL(@URL, ''),'CompanyName',ISNULL(@IN_PInvestorRef, ''),getdate(),0,'I', ISNULL(@OUT_ShellAccountNumber,''),ISNULL(@OUT_InstructionNumber,'')) 

        set @ReturnString = @URL
        --Select @ReturnString as ReturnString
        END

这是我的oracle程序。链接服务器很好。

CREATE OR REPLACE
PROCEDURE GETSHELLACNOANDINSTRUCTIONNO
( IN_PInvestorRef IN VARCHAR2(12)
, OUT_ShellAccountNumber OUT VARCHAR2(40)
, OUT_InstructionNumber OUT VARCHAR2(40)
) AS
BEGIN
  Select SHELL_ACCOUNT, INSTRUCTIONNUMBER into OUT_ShellAccountNumber, OUT_InstructionNumber
  from pf
  where client_id = IN_PInvestorRef;
  EXCEPTION WHEN OTHERS THEN
  dbms_output.put_line(SQLERRM);
END GETSHELLACNOANDINSTRUCTIONNO;

0 个答案:

没有答案