Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why I didn't get the error : ORA-14551: cannot perform a DML operation inside a query

K NJun 1 2015 — edited Jun 3 2015

Hi,

create table table_1 (num number)

create or replace function function_a return number

  is

    l_rv number;

  begin

    l_rv := dbms_random.value();

    insert into table_1 values(l_rv);

    return l_rv;

  end;

select function_a from dual

Now i am getting the error:

ORA-14551: cannot perform a DML operation inside a query

ORA-06512: at "FUNCTION_A", line 6

create table table_2 (num number)

insert into table_2 select function_a from dual

Now am not getting the same error. It is inserting records into table_2

Can anyone please clarify this?

Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production

Message was edited by: O-O added : (select function_a from dual)

This post has been answered by Sven W. on Jun 3 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 1 2015
Added on Jun 1 2015
15 comments
3,717 views