We help IT Professionals succeed at work.
Get Started

TOAD Oracle Function error

1,379 Views
Last Modified: 2014-05-02
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...
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2012
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 2 Answers and 5 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE