Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8884797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:09:01+00:00 2026-06-14T21:09:01+00:00

I have a function in PL/SQL which checks if a particular emp_id exists or

  • 0

I have a function in PL/SQL which checks if a particular emp_id exists or not which is:

CREATE OR REPLACE FUNCTION checkEmpNo(eno numeric)
RETURN boolean IS
    emp_number number;
BEGIN
    SELECT emp_id INTO emp_number
    FROM emp;
    IF eno=emp_number
    THEN
        return true;
    ELSE
        return false;
    END IF;
END checkEmpNo;

The function compiles successfully, but when I try to run it as:

DECLARE
    exist boolean;
BEGIN
    exist=checkEmpNo(1);
    dbms_output.put_line(exist);
END;

it returns the error:

ORA-06550: line 5, column 1:
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
ORA-06550: line 5, column 1:
PL/SQL: Statement ignored

3. BEGIN
4. exist:=checkEmpNo(1);
5. dbms_output.put_line(exist);
6. END;

EDIT:

I also tried this:

DECLARE
    exist boolean:=true;
BEGIN
    if(exist=checkEmpNo(1))
    then
        dbms_output.put_line('true');
    else
        dbms_output.put_line('false');
    end if;
END;

And it returns the error: ORA-01422: exact fetch returns more than requested number of rows

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:09:03+00:00Added an answer on June 14, 2026 at 9:09 pm

    dbms_output.put_line is not overloaded to accept a boolean argument. You can do something like

    dbms_output.put_line( case when exist = true 
                               then 'true'
                               else 'false'
                            end );
    

    to convert the boolean into a string that you can then pass to dbms_output.

    The ORA-01422 error is a completely separate issue. The function checkEmpNo includes the SELECT INTO statement

    SELECT emp_id 
      INTO emp_number
      FROM emp;
    

    A SELECT INTO will generate an error if the query returns anything other than 1 row. In this case, if there are multiple rows in the emp table, you’ll get an error. My guess is that you would want your function to do something like

    CREATE OR REPLACE FUNCTION checkEmpNo(p_eno number)
      RETURN boolean 
    IS
      l_count number;
    BEGIN
      SELECT count(*)
        INTO l_count
        FROM emp
       WHERE emp_id = p_eno;
    
      IF( l_count = 0 )
      THEN
        RETURN false;
      ELSE
        RETURN true;
      END IF;
    END checkEmpNo;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SQL Server 2005 I have an SQL Function (ftn_GetExampleTable) which returns a table with
I have a PL/SQL function (running on Oracle 10g) in which I update some
I have a huge problem with the REPLACE SQL function in Microsoft SQL Server
I have PHP function which checks to see if variables are set and then
I have function which return true or false depend of UserID and User Role.
I have a SQL-Statement which uses a Check-Function which takes a quite long time
I have a function which would return a record with type my_table%ROWTYPE , and
I have a function in SQL server 2008 that takes a string: 'A,B,C,D' and
I'm currently debugging an Ms SQL Function (SQL 2008). In this function, I have
Possible Duplicate: Parameterizing an SQL IN clause? I have a SQL function whereby I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.