Back to "null" in sql and pl/sql

Version of DB

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
"CORE 11.2.0.4.0 Production"
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

Created a function below

create or replace function return_null(p_string varchar2)
return varchar2
as
l_ret_string varchar2(32767);
begin
select p_string into l_ret_string from dual where 1=0;
return l_ret_string;
end;
/

When I call this function in a SQL return nothing but didn't no_data_found exception which I expected.



SQL> select return_null(p_string=>null) from dual;


RETURN_NULL(P_STRING=>NULL)
--------------------------------------------------------------------------------

But when I call the same function in PL/SQL block and he throws no_data_found error.

declare
l_ret_string varchar2(32767);
begin
l_ret_string :=return_null(p_string=>null);
dbms_output.put_line(l_ret_string);
end;
/

Error:

declare
*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "TESTDB1.RETURN_NULL", line 6
ORA-06512: at line 4

If I'm right get error service not in the calling pl/sql block. some body explain this behavior?

Thank you!

Here's a thread of AskTom 12 year old:

https://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:10321465390114

Tags: Database

Similar Questions

Maybe you are looking for

  • HP ENVY notebook - m7-k211dx: Synaptics ClickPad will not be disabled. Reactive after reboot.

    Whenever I have disable Synaptics ClickPad using the option 'disable the internal pointing device when external USB pointing device is attached', it works fine until I restart. When I return in the options, it is still once unchecked. I tried to turn

  • How can I delete one of my folders in Hotmail?

    I can't find an option anywhere to remove the files, which I no longer use.

  • How to get a gaming license

    If I wanted to use Windows as a platform for a game like World of Warcraft, how could I go to get a license?  How much would it cost? And where I could find the actual document?  I want only know because I am doing a project for school and I need to

  • Size 50mm Macro life adapter/converter

    I own the lens macro 50mm f: 2.5.  This objective will focus to 1/2 size but for life-size Canon indicates that I need to buy their single adapter that cost an arm and a leg.  What is the advantage of using the adapter/converter Canon instead of use

  • Cannot open docx files

    I am running windows XP. I downloaded the file MS File Format Converter and Office Compatibility Pack Service Pack 2 (SP2) and I still cannot open the docx files. I can open .xlsx files. I am running Outlook 2007 and Word 2003. I have 2 other compute