0

Unable to pass varchar2 datatype in my function. Below is my code:

create 
or replace function f1(i varchar2) return varchar is j varchar2(10);
begin
   select
      last_name into j 
   from
      employees 
   where
      first_name = 'I';
return j;
end
;
/

Select f1('Steven') from dual;

It is showing null value instead of returning the Name.

1 Answer 1

1

You need to reference your parameter without quotes in your where clause, not as 'I'.

create or replace function f1(i varchar2)
return varchar
is
j varchar2(10);
begin
select last_name
into j
from per_all_people_f
where first_name=i;
return j;
end;
Sign up to request clarification or add additional context in comments.

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.