TSQL procedure call to PLSQL procedure : ORA-06502: PL/SQL: numeric or value error

351 views Asked by At

I have a T-SQL procedure calling an Oracle procedure passing in some parameters. My oracle procedure works fine and returns the output parameters as expected. However when calling the oracle procedure from the T-SQL procedure, I have the following error. I can't understand why am I getting this. Varchars are being used in both procedures.


(1 row(s) affected) OLE DB provider "OraOLEDB.Oracle" for linked server "ORA_LINK_SERVER" returned message "ORA-06502: PL/SQL: numeric or value error ORA-06512: at "DBNAME.GETSHELLACNOANDINSTRUCTIONNO", line 7".

(1 row(s) affected)

(1 row(s) affected) Msg 7215, Level 17, State 1, Procedure USP_TXN_PF_CLIENT_URL_NEW, Line 56 Could not execute statement on remote server 'ORA_LINK_SERVER'.


This is my T-SQL procedure

    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

And this is my oracle procedure. The link server is fine.

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

There are 0 answers