alter session force parallel dml; alter session force parallel query; DECLARE --declare a table-based record for the table "document" v_document_rec document%ROWTYPE; CURSOR document_cur IS SELECT * FROM document WHERE trunc(created_date) between TO_DATE('01.01.2017','dd.mm.yyyy') AND to_date(to_char(SYSDATE,'dd.mm.yyyy')) FETCH FIRST 100000 ROWS ONLY; -- declare a cursor-based record v_document_rec document_cur%ROWTYPE; BEGIN OPEN document_cur; LOOP -- fetch the content of the cursor into the record FETCH document_cur into v_document_rec; EXIT WHEN document_cur%NOTFOUND; INSERT /*+ APPEND PARALLEL 8 */ INTO document_interim VALUES( v_document_rec.ID, v_document_rec.document_id, v_document_rec.document_name, v_document_rec.created_date, v_document_rec.security_level, v_document_rec.content ); END LOOP; COMMIT; CLOSE document_cur; END; /
Minimalistic Oracle contains a collection of practical examples from my encounters with Oracle technologies. When relevant, I also write about other technologies, like Linux or PostgreSQL. Many of the posts starts with "how to" since they derive directly from my own personal experience. My goal is to provide simple examples, so that they can be easily adapted to other situations.
Wednesday, November 8, 2017
How to use ROWTYPE to fetch entire rows for insert into an interim table
Here is how I used a PL/SQL record to insert rows from a table into an interim table, using parallel slaves and direct path:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment