开发者

Oracle function compilation error with no errors

I am creating a function, logged in as sys.

CREATE FUNCTION Core.Get_Contact_Code
(
       First_Name IN NVARCHAR2,
       Middle_Name IN  NVARCHAR2,
       Last_Name IN NVARCHAR2
) 
RETURN NVARCHAR2 
IS 
    Ret_Val NVARCHAR2(10);
    C_Code NVARCHAR2(10);

    CURSOR contact_cursor IS 
    SELECT Contact_Code FROM (
        SELECT Contact_Code
        FROM Core.Contacts
        WHERE
        Contact_Code LIKE UPPER(left(First_Name,2) ||
        CASE    
            WHEN Middle_Name IS NULL THEN left(Last_Name,3) 
            ELSE left(Middle_Name,1) || left(Last_Name,2) 
        END || '%')
        ORDER BY Contact_Code desc)
   WHERE ROWNUM=1;
BEGIN
    open contact_cursor;
    fetch contact_cursor into C_Code;
    close contact_cursor;

    IF C_Code IS NULL THEN
    Ret_Val := 
    UPPER(left(First_Name,2)||
        CASE    
            WHEN Middle_Name IS NULL THEN left(Last_Name,3) 
            ELSE left(Middle_Name,1) || left(Last_Name,2) 
        END
    )
       || '-' || '0001'; 
    ELSE
        Ret_Val := 
        UPPER(left(First_Name,2)||
            CASE    
                WHEN Middle_Name IS NULL THEN left(Last_Name,3) 
                ELSE left(Middle_Name,1) || left(Last_Name,2) 
            END
        )
           ||开发者_如何学Python '-' ||
              trim(to_char(CAST(right(C_Code,4) AS integer)+1,'0000')); 
    END IF;

    RETURN Ret_Val;
END;
/

show errors;

When I execute the query, it says:

Warning: compiled but with compilation errors
No errors.

But when I omit the schema Core in the definition

CREATE FUNCTION Get_Contact_Code

it compiles.

Any ideas why Oracle behaves this way?


What are LEFT and RIGHT? Does your script not include the schema name for those functions, so they only get installed in SYS and not in CORE?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜