2012-10-11 70 views
1

我打電話從SQL Server 2008 R2一個Oracle包裝功能和正在以下錯誤在Oracle功能:錯誤調用鏈接服務器

OLE DB provider "OraOLEDB.Oracle" for linked server "TEST" returned message "ORA-06502: PL/SQL: numeric or value error: character string buffer too small

這裏是我試圖撥打電話:

DECLARE @p_pidm VARCHAR(8) 
    DECLARE @p_emal_code VARCHAR(4) 
    DECLARE @p_email_address VARCHAR(90) 
    DECLARE @p_rowid VARCHAR(18) = NULL 
    DECLARE @p_exists VARCHAR(1) 

    SET @p_pidm = '11111' 
    SET @p_emal_code = 'POA' 
    SET @p_email_address = '[email protected]' 

    EXECUTE ('BEGIN ? := gb_email.f_exists(?,?,?,?);END;',@p_exists, @p_pidm, @p_emal_code, @p_email_address, @p_rowid) 
    AT [TEST] 

如果我在SQL Developer中執行此調用,它可以正常工作。這裏是我在那裏執行查詢:

set serveroutput on ; 
DECLARE rec_exists VARCHAR2(1) ; 
begin 
rec_exists := gb_email.f_exists(11111,'POA','[email protected]',NULL); 
DBMS_OUTPUT.PUT_LINE(rec_exists); 
end; 

我試圖改變@p_exists大小VARCHAR(MAX)並沒有採取任何行動。我已經驗證過,我聲明的所有變量都與我調用的包/函數的定義匹配。

這不是我經常做的事情,所以任何幫助解決這個問題將不勝感激。

這裏的函數定義:

FUNCTION f_exists(p_pidm   goremal.goremal_pidm%TYPE, 
        p_emal_code  goremal.goremal_emal_code%TYPE, 
        p_email_address goremal.goremal_email_address%TYPE, 
        p_rowid   gb_common.internal_record_id_type DEFAULT NULL) 
    RETURN VARCHAR2 


Checks to see if a record exists. 


Parameters 
p_pidm The PIDM of the entity who owns this e-mail information. NUMBER(8) Required Key  
p_emal_code The type of the e-mail address. VARCHAR2(4) Required Key  
p_email_address The e-mail address. VARCHAR2(90) Required Key  
p_rowid Database ROWID of record to be selected. VARCHAR2(18)  

Returns 
Y if found, otherwise N. 
+0

'gb_email.f_exists()'返回什麼類型? – Annjawn

+0

我在我的問題中添加了函數描述。 – Chuck

回答

2

好吧,我找到了解決辦法。我未能將參數指定爲OUTPUT。這裏是工作查詢:

DECLARE @p_pidm VARCHAR(8) 
    DECLARE @p_emal_code VARCHAR(4) 
    DECLARE @p_email_address VARCHAR(90) 
    DECLARE @p_rowid_out VARCHAR(18) = NULL 
    DECLARE @p_rec_exists VARCHAR(1) 

    SET @p_pidm = '11111' 
    SET @p_emal_code = 'POA' 
    SET @p_email_address = '[email protected]' 

    EXECUTE ('BEGIN ? := gb_email.f_exists(?,?,?,?);END;',@p_rec_exists OUTPUT, @p_pidm, @p_emal_code, @p_email_address, @p_rowid_out) 
    AT [TEST] 
    SELECT @p_rec_exists