2

When I pass a parameter to a function call, I get the following error:

Error: PLS-00306: wrong number or types of arguments in call to 'GET_NUM'.

The code is as follows:

    CREATE OR REPLACE PACKAGE BODY TESTJNSABC IS

  -- FUNCTION IMPLEMENTATIONS
  FUNCTION get_num(num IN NUMBER) 
    RETURN VARCHAR2 IS
    my_cursor VARCHAR2(20);
  BEGIN
    IF get_num = 1 THEN

      my_cursor:= 'hello world';
    ELSE
      my_cursor:= 'Hi!';
    END IF;

    RETURN my_cursor;

  END;

  -- PROCEDURE IMPLEMENTATIONS 
  PROCEDURE testingabc AS
    x NUMBER(3);
    BEGIN
      x:= 2;
        dbms_output.put_line(get_num(x));
      END testingabc;

END TESTJNSABC;
5
  • 2
    The issue is in IF get_num = 1; what do you expect this to do? Commented Jan 16, 2017 at 14:01
  • I'm just creating a simple example to view the functionality of functions and procedures. But if 1 is a NUMBER TYPE why I'm I getting this error? Commented Jan 16, 2017 at 14:05
  • He already answered you. on the IF statement you are calling the function itself, the error is because it isn't a recursive function and get_num needs a parameter. what you want is probably IF num = 1 THEN which is your parameter. Commented Jan 16, 2017 at 14:08
  • you are calling the function get_num without parameters, while it has one input parameter. What do you need to do with that line of code? Commented Jan 16, 2017 at 14:08
  • Yes your right! I beleived I vas comparing to "num", not to the get_num function itself. Thanks! Commented Jan 16, 2017 at 14:10

2 Answers 2

4

You have an issue in IF get_num = 1 THEN, because you are calling the function get_num without parameters, while it has one input parameter

If you want to check the parameter value, you probably mean:

IF num = 1 THEN
Sign up to request clarification or add additional context in comments.

1 Comment

I was about to ask you to add your comment as an answer. So I could give you a +1 :)
0

The problem is at IF get_num = 1. The code will work after you change it to IF num = 1.

Entire sample code below:

CREATE OR REPLACE PACKAGE BODY TESTJNSABC IS

-- FUNCTION IMPLEMENTATIONS

FUNCTION get_num(num IN NUMBER) 
   RETURN VARCHAR2 IS
   my_cursor VARCHAR2(20);
BEGIN
IF num = 1 THEN

  my_cursor:= 'hello world';
ELSE
  my_cursor:= 'Hi!';
END IF;

RETURN my_cursor;

END;

 -- PROCEDURE IMPLEMENTATIONS 
PROCEDURE testingabc AS
x NUMBER(3);
BEGIN
  x:= 2;
    dbms_output.put_line(get_num(x));
  END testingabc;

END TESTJNSABC;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.