CURSOR_SHARING does not result in literal substitution for sql statements executed from PS/SQL blocks (Doc ID 790128.1)

Last updated on JULY 05, 2017

Applies to:

Oracle Server Enterprise Edition - Version: 10.2.0.1
PL/SQL - Version: 10.2.0.1
Information in this document applies to any platform.

Goal

Database initialization parameter CURSOR_SHARING set to FORCE or SIMILAR does not result in literal substitution for statements executed from PLSQL blocks, as it does for statements executed directly, and can be seen with the following example:

create table foo_direct(co1 number);
create table foo_anon(col1 number);
create table foo_execimm(col1 number);

alter session set cursor_sharing=FORCE;
alter system flush shared_pool;

insert into foo_direct values(1);

begin  insert into foo_anon values(1);  end;
/

begin
execute immediate 'insert into foo_execimm values(1)';
end;
/

select sql_text from v$sqlarea where sql_text like '%foo%';

SQL_TEXT
--------------------------------------------------------------------------
insert into foo_execimm values(:"SYS_B_0")
insert into foo_direct values(:"SYS_B_0")
begin  insert into foo_anon values(1);  end;
begin execute immediate 'insert into foo_execimm values(1)'; end;

Solution

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms