Link to home
Create AccountLog in
Avatar of jknj72
jknj72

asked on

TOAD Oracle Function error

I have a Select statement that im trying to return a value for a column and its giving me an error saying that
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "ANET.FUNC_OMNI_CHECK_ESSENTIAL", line 32

Does it have anything to do with passing the column FILE_GUID which is in the same select statement.

Here is the Select statement Im trying to use the function in...
SELECT FILE_GUID, FILE_UPLOADED_BY, FILE_DESCRIPTION, FILE_BYTES, FILE_NAME, FILE_UPLOAD_LOCATION, FILE_FULL_NAME, FILE_UPLOAD_TYPE, FILE_UPLOAD_DATE,
FUNC_OMNI_DEPT_NAME_PAGEID(FILE_DEPT_OWNER) FILE_DEPT_OWNER, CONTENT_TYPE, FILE_CREATE_DATE,
FUNC_DOC_LINKS(FILE_GUID) as LinkInfo,
FUNC_OMNI_CHECK_ESSENTIAL(FILE_GUID) as FILE_ESSENTIAL
FROM VW_OMNI_ENT_FILE_LIST WHERE FILE_DEPT_OWNER ='400000' AND UPPER(FILE_UPLOAD_TYPE)='ADOBE' ORDER BY FILE_CREATE_DATE DESC

And here is the function code...
CREATE OR REPLACE FUNCTION FUNC_OMNI_CHECK_ESSENTIAL
(vFile_GUID IN VARCHAR2)
RETURN NUMBER

IS

BEGIN
   DECLARE
        lnkURL VARCHAR(255);
        lnkID NUMBER;
        cnt NUMBER;
       
        BEGIN      
            SELECT UPPER(FILE_UPLOAD_TYPE || '/' || FILE_FULL_NAME) into lnkURL from OMNI_ENT_FILES where UPPER(FILE_GUID) = UPPER(vFile_GUID);
            SELECT LINK_ID into lnkID FROM OMNI_ENT_LINK WHERE UPPER(LINK_URL) = UPPER(lnkURL);
           
        SELECT COUNT(*) into cnt from OMNI_COMMON_LOOKUP where LOOKUP_KEY LIKE '%ESSENTIALS_%' and LOOKUP_VALUE_NUMBER=lnkID;
            if cnt > 0 then
                RETURN 1;
            else
                RETURN 0;
            end if;
       
        END;

Thanks all....Id appreciate any help I can get...
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of jknj72
jknj72

ASKER

I found the problem.  It was bad data. Thanks to you both. Splitting points
Avatar of jknj72

ASKER

Thanks to you both
You are Welcome ..!! Glad that we could be of help :)