05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

432<br />

CHAPTER 11 ■ INDEXES<br />

( s.nextval, x.OWNER, x.OBJECT_NAME, x.SUBOBJECT_NAME,<br />

x.OBJECT_ID, x.DATA_OBJECT_ID, x.OBJECT_TYPE, x.CREATED,<br />

x.LAST_DDL_TIME, x.TIMESTAMP, x.STATUS, x.TEMPORARY,<br />

x.GENERATED, x.SECONDARY );<br />

if ( mod(x.r,100) = 0 )<br />

then<br />

commit;<br />

end if;<br />

end loop;<br />

commit;<br />

end;<br />

/<br />

Now, since we discussed the PL/SQL commit time optimization in Chapter 9, I wanted to<br />

run a test that was using a different environment as well, so as to not be misled by this commit<br />

time optimization. I used Pro*C to emulate a data warehouse extract, transform, load (ETL)<br />

routine that processed rows in batches of 100 at a time between commits:<br />

exec sql declare c cursor for select * from all_objects;<br />

exec sql open c;<br />

exec sql whenever notfound do break;<br />

for(;;)<br />

{<br />

exec sql<br />

fetch c into :owner:owner_i,<br />

:object_name:object_name_i, :subobject_name:subobject_name_i,<br />

:object_id:object_id_i, :data_object_id:data_object_id_i,<br />

:object_type:object_type_i, :created:created_i,<br />

:last_ddl_time:last_ddl_time_i, :timestamp:timestamp_i,<br />

:status:status_i, :temporary:temporary_i,<br />

:generated:generated_i, :secondary:secondary_i;<br />

exec sql<br />

insert into t<br />

( id, OWNER, OBJECT_NAME, SUBOBJECT_NAME,<br />

OBJECT_ID, DATA_OBJECT_ID, OBJECT_TYPE, CREATED,<br />

LAST_DDL_TIME, TIMESTAMP, STATUS, TEMPORARY,<br />

GENERATED, SECONDARY )<br />

values<br />

( s.nextval, :owner:owner_i, :object_name:object_name_i,<br />

:subobject_name:subobject_name_i, :object_id:object_id_i,<br />

:data_object_id:data_object_id_i, :object_type:object_type_i,<br />

:created:created_i, :last_ddl_time:last_ddl_time_i,<br />

:timestamp:timestamp_i, :status:status_i,<br />

:temporary:temporary_i, :generated:generated_i,<br />

:secondary:secondary_i );

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!