Bulk collect
Hello
I have a pl/sql block, it will work, but runs for 10 hours, could help you modify using "bulk collect?
(I've tried, but still had errors... so I want to see how other friends can modify with success).
Thank you, happy Thanksgiving!
-It's original screenplay:
DECLARE
CURSOR C_CURSOR IS SELECT * FROM MF_S224_RPT WHERE UIDY_LO IS NOT NULL AND PATN_LIST IS NOT NULL;
V_DEF_DATA C_CURSOR % ROWTYPE;
str_new_uidy_lo VARCHAR2 (255);
CURSOR C_CURSOR_LN IS SELECT * FROM MF_S224_RPT_LN WHERE UIDY_LO IS NOT NULL;
V_DEF_DATA_LN C_CURSOR_LN % ROWTYPE;
str_new_uidy_lo_ln VARCHAR2 (255);
BEGIN
C_CURSOR OPEN;
EXTRACT THE C_CURSOR IN V_DEF_DATA;
C_CURSOR % LOOP WHILE
str_new_uidy_lo: = (' & 6084 &'|) V_DEF_DATA. FISC_YEAR | ' &' | V_DEF_DATA. FISC_MNTH | ' &' | V_DEF_DATA. VR | ' &' | V_DEF_DATA. BENEFITS | ' &' | V_DEF_DATA. PATN_LIST | ' &' | V_DEF_DATA. (SLA);
UPDATE T1 SET T1 MF_S224_RPT. UIDY_LO is str_new_uidy_lo WHERE T1. UIDY_LO = V_DEF_DATA. UIDY_LO;
UPDATE T2 T2 SET MF_S224_RPT_LN. PRPT_ID_LO is str_new_uidy_lo WHERE T2. PRPT_ID_LO = V_DEF_DATA. UIDY_LO;
UPDATE MF_S224_RPT_ACT T5 T5 SET. PRPT_ID_LO is str_new_uidy_lo WHERE T5. PRPT_ID_LO = V_DEF_DATA. UIDY_LO;
EXTRACT THE C_CURSOR IN V_DEF_DATA;
END LOOP;
CLOSE C_CURSOR;
C_CURSOR_LN OPEN;
EXTRACT THE C_CURSOR_LN IN V_DEF_DATA_LN;
C_CURSOR_LN % LOOP WHILE
str_new_uidy_lo_ln: = ('& 6085' |) SUBSTR (V_DEF_DATA_LN. PRPT_ID_LO, 6). ' &' | V_DEF_DATA_LN. TSYM | ' &' | V_DEF_DATA_LN. GLAC | ' &' | V_DEF_DATA_LN. ACMP_YEAR | ' &' | V_DEF_DATA_LN. ACMP_MNTH | ' &' | V_DEF_DATA_LN. RCPT_DISB_IN | ' &' | V_DEF_DATA_LN. PATN);
UPDATE MF_S224_RPT_LN SET T3 T3. UIDY_LO is str_new_uidy_lo_ln WHERE T3. UIDY_LO = V_DEF_DATA_LN. UIDY_LO;
UPDATE MF_S224_RPT_ACT SET T4 T4. PRPT_LINE_ID_LO is str_new_uidy_lo_ln WHERE T4. PRPT_LINE_ID_LO = V_DEF_DATA_LN. UIDY_LO;
EXTRACT THE C_CURSOR_LN IN V_DEF_DATA_LN;
END LOOP;
CLOSE C_CURSOR_LN;
END;
/
This should be a lot faster:
declare
type of TRec's record)
OLD_UIDY_LO MF_S224_RPT. UIDY_LO % TYPE,
NEW_UIDY_LO MF_S224_RPT. TYPE % UIDY_LO
);
type TRecList is table of the TRec;
vRecList TRecList;
Start
Select UIDY_LO,
"& 6084 &' | FISC_YEAR | » &'|| FISC_MNTH | » &'|| VR | » &'|| BENEFITS | » &'|| PATN_LIST | » &'|| SLA
bulk collect into vRecList
of MF_S224_RPT
where UIDY_LO is not null and
PATN_LIST is not null;
ForAll i in vRecList.First... vRecList.Last
Update MF_S224_RPT T1
the T1 value. UIDY_LO = vRecList (i). NEW_UIDY_LO
where T1. UIDY_LO = vRecList (i). OLD_UIDY_LO;
ForAll i in vRecList.First... vRecList.Last
MF_S224_RPT_LN T2 update
the value of T2. PRPT_ID_LO = vRecList (i). NEW_UIDY_LO
where T2. PRPT_ID_LO = vRecList (i). OLD_UIDY_LO;
ForAll i in vRecList.First... vRecList.Last
Update MF_S224_RPT_ACT T5
SET T5. PRPT_ID_LO = vRecList (i). NEW_UIDY_LO
where T5. PRPT_ID_LO = vRecList (i). OLD_UIDY_LO;
-------------
Select UIDY_LO,
("& 6085' | ') SUBSTR (PRPT_ID_LO, 6). » &'|| TSYM | » &'|| GLAC | » &'|| ACMP_YEAR | » &'|| ACMP_MNTH | » &'|| RCPT_DISB_IN | » &'|| PATN)
bulk collect into vRecList
of MF_S224_RPT_LN
where UIDY_LO is not null;
ForAll i in vRecList.First... vRecList.Last
MF_S224_RPT_LN T3 update
Set the T3. UIDY_LO = vRecList (i). NEW_UIDY_LO
where T3. UIDY_LO = vRecList (i). OLD_UIDY_LO;
ForAll i in vRecList.First... vRecList.Last
Update MF_S224_RPT_ACT T4
Set the T4. PRPT_LINE_ID_LO = vRecList (i). NEW_UIDY_LO
where T4. PRPT_LINE_ID_LO = vRecList (i). OLD_UIDY_LO;
end;
/
Tags: Database
Similar Questions
-
Hello world
I'm doing a big collect of the row ID in order to group my lines by pieces and then dealt with separately.
My problem at present is that I can't seem to know what to put in my definition of type for the line id then it will work.
the only way I get it to compile, I know it's wrong, and when I run it I get:
ORA-21700: object does not exist or is marked for deletion
I decided to ask here after that I went through this two positions but did not find my answer, or at least I think not.
ORA-21700: object does not exist or is marked for deletion - nested table
my code is something like this:
type t_rid_tab is table of rowid; with migr as ( select rowid rid ,ceil(rownum/i_chunk_size) chunk_nr from TABLE m ) select cast(collect(rid) as t_rid_tab) rid_tab bulk collect into l_row_id_tab from migr group by chunk_nr ;
to be honest the code part is not the biggest problem, eventually can be changed until it works.
My two questions are:
1 - Why do a compilation error data type in this code for my t_rid_tab (PLS-00531: not supported type in a type VARRAY of the TABLE: "ROWID")
2 even just to execute the query in my sql developer does not work with something simple like: does not work, can someone just give me a first pointer?
I am trying to run a small debug program to see what I get in my big, but I can't make it work... should be something pretty basic-no?
I can't seem to run until I understand how can I declare my table of rowid type
declare l_tab t_rid_tab; begin with migr as ( select rowid rid ,ceil(rownum/100) chunk_nr from TABLE m ) select cast(collect(rid) as rowid) rid_tab bulk collect into l_tab from migr group by chunk_nr ; debug(l_tab(1)); end; /
Thank you
It is more clear what you want now and why you want it!
create table test_cmg (column number (5));
/
insert into test_cmg
Select the level
of the double
connect by level<>
/
Create the type TROWIDCharTable is table of the varchar2 (100)
/
declare
type of TRec's record)
Whole piece,
RIDTable TROWIDCharTable
);
type TRecTable is table of the TRec;
vRecTable TRecTable;
Start
with Rahul like)
Select ceil(rownum/100) chunk_nr,
Cast (cost vires (ROWIDTOCHAR (rowid)) as TROWIDCharTable) ridtable
of test_cmg m
ceil(rownum/100) group
)
Select chunk_nr, ridtable
bulk collect into vRecTable
of Rahul.
-A loop around your data...
end;
/
-
Hi all
I want to know if using bulk collect into limit will help to avoid the TEMP tablespace error run out.
We use Oracle 11 g R1.
I am assigned to a task of creating journal facilitated for all tables in a query of the APEX.
I create procedures to execute some sql statements to create a DEC (Create table select), and then fires on these tables.
We have about three tables with more than 26 million records.
It seems very well running until we reached a table with more than 15 million record, we got an error says that Miss tablespace TEMP.
I googled on this topic and retrieve the tips:
Use NO LOG
Parallel use
BULK COLLECT INTO limited
However, the questions for those above usually short-term memory rather than running out of TEMPORARY tablespace.
I'm just a junior developer and does not have dealed with table more than 10 million documents at a time like this before.
The database support is outsourced. If we try to keep it as minimal contact with the DBA as possible. My Manager asked me to find a solution without asking the administrator to extend the TEMP tablespace.
I wrote a few BULK COLLECT INTO to insert about 300,000 like once on the development environment. It seems.
But the code works only against a 000 4000 table of records. I am trying to add more data into the Test table, but yet again, we lack the tablespace on DEV (this time, it's a step a TEMP data)
I'll give it a go against the table of 26 million records on the Production of this weekend. I just want to know if it is worth trying.
Thanks for reading this.
Ann
I really need check that you did not have the sizes of huge line (like several K by rank), they are not too bad at all, which is good!
A good rule of thumb to maximize the amount of limit clause, is to see how much memory you can afford to consume in the PGA (to avoid the number of calls to the extraction and forall section and therefore the context switches) and adjust the limit to be as close to that amount as possible.
Use the routines below to check at what threshold value would be better suited for your system because it depends on your memory allocation and CPU consumption. Flexibility, based on your limits of PGA, as lines of length vary, but this method will get a good order of magnitude.
CREATE OR REPLACE PROCEDURE show_pga_memory (context_in IN VARCHAR2 DEFAULT NULL)
IS
l_memory NUMBER;
BEGIN
SELECT st. VALUE
IN l_memory
SYS.v_$ session se, SYS.v_$ sesstat st, SYS.v_$ statname nm
WHERE se.audsid = USERENV ('SESSIONID')
AND st.statistic # nm.statistic = #.
AND themselves. SID = st. SID
AND nm.NAME = 'pga session in memory. "
Dbms_output.put_line (CASE
WHEN context_in IS NULL
THEN NULL
ELSE context_in | ' - '
END
|| 'Used in the session PGA memory ='
|| To_char (l_memory)
);
END show_pga_memory;
DECLARE
PROCEDURE fetch_all_rows (limit_in IN PLS_INTEGER)
IS
CURSOR source_cur
IS
SELECT *.
FROM YOUR_TABLE;
TYPE source_aat IS TABLE OF source_cur % ROWTYPE
INDEX BY PLS_INTEGER;
l_source source_aat;
l_start PLS_INTEGER;
l_end PLS_INTEGER;
BEGIN
DBMS_SESSION.free_unused_user_memory;
show_pga_memory (limit_in |) "- BEFORE"); "."
l_start: = DBMS_UTILITY.get_cpu_time;
OPEN source_cur.
LOOP
EXTRACTION source_cur
LOOSE COLLECTION l_source LIMITED limit_in;
WHEN l_source EXIT. COUNT = 0;
END LOOP;
CLOSE Source_cur;
l_end: = DBMS_UTILITY.get_cpu_time;
Dbms_output.put_line (' elapsed time CPU for limit of ')
|| limit_in
|| ' = '
|| To_char (l_end - l_start)
);
show_pga_memory (limit_in |) "- AFTER");
END fetch_all_rows;
BEGIN
fetch_all_rows (20000);
fetch_all_rows (40000);
fetch_all_rows (60000);
fetch_all_rows (80000);
fetch_all_rows (100000);
fetch_all_rows (150000);
fetch_all_rows (250000);
-etc.
END;
-
Bulk collect using some different column insert a table
Hi all
I gave an example of emp table in my original 100 million table record are I need to change group (IE deptno) 10 to 20 copy the same records
about these codes, I get exception
ORA-06550: line 11, column 53:
PLS-00386: concordance that is 'EMP_TAB' between FETCH cursor and IN variables of type
can help me please for these
declare
type row_tab is table emp % rowtype
INDEX BY PLS_INTEGER;
emp_tab row_tab;
cursor cur_emp is select ENAME, 20 DEPTNO, HIREDATE, emp COMM EMPNO;
Start
Open cur_emp;
loop
Cur_emp fetch bulk collect in the limit emp_tab 2000;
ForAll i in 1.emp_tab. COUNTY
Insert / * + APPEND * / into emp (EMPNO, ENAME, DEPTNO, HIREDATE, COMM)
values (emp_tab (i). EMPNO, emp_tab (i). Ename, emp_tab (i). DEPTNO, emp_tab (i). HIREDATE, emp_tab (i). COMM.) ;
When the output cur_emp % notfound;
END LOOP;
close cur_emp;
end;
/
Thank you
VSM
I use the user define the type of record to over come error
declare
type emp_rt is record (empno, ename emp.ename%type,deptno NUMBER (2) emp.empno%type, hiredate emp.hiredate%type,comm emp.comm%type);
TYPE row_type IS the emp_rt INDEX TABLE OF pls_integer;
emp_tab row_type;
cursor cur_emp is select empno, ename, 20 deptno, hiredate, comm from emp where deptno = 10;
Start
Open cur_emp;
loop
Cur_emp fetch bulk collect in the emp_tab limit 2;
ForAll i in 1.emp_tab. COUNTY
Insert / * + APPEND * / into EMP (EMPNO, ENAME, DEPTNO, HIREDATE, COMM)
values (emp_tab (i). EMPNO, emp_tab (i). ENAME, emp_tab (i). DEPTNO, emp_tab (i). HIREDATE, emp_tab (i). COMM.)
;
When the output cur_emp % notfound;
END LOOP;
close cur_emp;
end;
/
records are successful inserted, I do not know is not the right approach for 100 million documents?
Thank you
VM
-
Get 'not enough values error' in bulk collect
I want to insert all the rows in the employees table in the tmp table which has the structure.
Purpose: Try just feature fired block to create a return to the top of a table.
Problem: My code is to not "enough of values" error please report if mistaken.
structure of the employees table:
SQL > desc employee;
Name Null? Type
----------------------------------------- -------- ----------------------------
EMPLOYEE_ID NOT NULL NUMBER (6)
FIRST NAME VARCHAR2 (20)
LAST_NAME NOT NULL VARCHAR2 (25)
EMAIL NOT NULL VARCHAR2 (25)
PHONE_NUMBER VARCHAR2 (20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2 (10)
SALARY NUMBER (8.2)
COMMISSION_PCT NUMBER (2.2)
MANAGER_ID NUMBER (6)
DEPARTMENT_ID NUMBER 4
tmp table structure:
SQL > tmp desc;
Name Null? Type
----------------------------------------- -------- ----------------------------
EMPLOYE_ID NUMBER (6)
FIRST NAME VARCHAR2 (20)
LAST_NAME NOT NULL VARCHAR2 (25)
EMAIL NOT NULL VARCHAR2 (25)
PHONE_NUMBER VARCHAR2 (20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2 (10)
SALARY NUMBER (8.2)
COMMISSION_PCT NUMBER (2.2)
MANAGER_ID NUMBER (6)
DEPARTMENT_ID NUMBER 4
SQL > select * from tmp;
no selected line
Code:
declare
type rec is the employee table % rowtype
index by pls_integer;
a rec;
Start
Select * bulk collect in a
employees;
ForAll i in a.first... a.Last
Insert into tmp values (a (i));
end;
/
Result:
SQL > declare
2
3 type rec is the employee table % rowtype
4 index of pls_integer;
5 a rec;
6
7. start
8 remove tmp;
9 select * bulk collect in a
10 employees;
11 ForAll i in a.first... a.Last
12 insert into tmp values (a (i));
13 end;
14.
Insert into tmp values (a (i));
*
ERROR on line 12:
ORA-06550: line 12, column 13:
PL/SQL: ORA-00947: not enough values
ORA-06550: line 12, column 1:
PL/SQL: SQL statement ignored
Remove parentheses
insert into tmp values a(i);
or call the individual columns
insert into tmp( employee_id, first_name, ... ) values( a(i).employee_id, a(i).first_name, ... );
Justin
-
change a pl/sql block using "bulk collect.
Hello
I have a pl/sql block, short it slows...
DECLARE
CURSOR CURUPDATE1 IS
SELECT MF_TJ. UID_LO
OF MF_TJ
WHERE MF_TJ. DTYP (SELECT CD
OF MF_DOC_TYPE
WHERE MF_DOC_TYPE. DTYP_CAT = 'xx')
AND MF_TJ. LINE_TYP IS SET TO NULL;
BEGIN
FOR T IN CURUPDATE1
LOOP
UPDATE MF_TJ
THE MF_TJ VALUE. LINE_TYP = "NR."
WHERE MF_TJ. UID_LO = T.UID_LO;
UPDATE MF_AJ
THE MF_AJ VALUE. LINE_TYP = "NR."
WHERE MF_AJ. TJ_UID_LO = T.UID_LO;
END LOOP;
END;
/
now I change to use bulk collect, but I split it into two pl/sql blocks (each for an update)
DECLARE
CURSOR CURUPDATE1 IS
SELECT MF_TJ. UID_LO
OF MF_TJ
WHERE MF_TJ. DTYP (SELECT CD
OF MF_DOC_TYPE
WHERE MF_DOC_TYPE. DTYP_CAT = 'xx')
AND MF_TJ. LINE_TYP IS SET TO NULL;
TYPE of recs_type IS the TABLE OF CURUPDATE1% ROWTYPE directory INDEX;
REB recs_type;
BEGIN
CURUPDATE1 OPEN;
Go SEARCH the CURUPDATE1 COLLECT in BULK IN REB 8000 limit;
CLOSE CURUPDATE1;
FORALL i IN 1.recs. COUNTY
UPDATE MF_TJ
THE MF_TJ VALUE. LINE_TYP = "NR."
WHERE MF_TJ. UID_LO = (i) recs. UID_LO;-END;
/
DECLARE
CURSOR CURUPDATE1 IS
SELECT MF_TJ. UID_LO
OF MF_TJ
WHERE MF_TJ. DTYP (SELECT CD
OF MF_DOC_TYPE
WHERE MF_DOC_TYPE. DTYP_CAT = 'xx')
AND MF_TJ. LINE_TYP IS SET TO NULL;
TYPE of recs_type IS the TABLE OF CURUPDATE1% ROWTYPE directory INDEX;
REB recs_type;
BEGIN
CURUPDATE1 OPEN;
Go SEARCH the CURUPDATE1 COLLECT in BULK IN REB 8000 limit;
CLOSE CURUPDATE1;
FORALL i IN 1.recs. COUNTY
UPDATE MF_AJ
THE MF_AJ VALUE. LINE_TYP = "NR."
WHERE MF_AJ. TJ_UID_LO = (i) recs. UID_LO;-
END;
/Is there a way I can just use pl/sql block using bulk collect?
Thank you very much
Hi 5181139
As Paulzip and Jarkko Turpeinen have pointed out, you could do it using only SQL...
This is a course using COLLECT in BULK:
DECLARE blimit CONSTANT PLS_INTEGER := 500; CURSOR curupdate1 IS SELECT MF_TJ.UID_LO FROM MF_TJ WHERE MF_TJ.DTYP IN (SELECT CD FROM MF_DOC_TYPE WHERE MF_DOC_TYPE.DTYP_CAT = 'xx') AND MF_TJ.LINE_TYP IS NULL; TYPE c_arr IS TABLE OF curupdate1%ROWTYPE; c_rows c_arr; BEGIN OPEN curupdate1; LOOP FETCH curupdate1 BULK COLLECT INTO c_rows LIMIT blimit; FORALL i IN c_rows.FIRST..c_rows.LAST UPDATE MF_TJ SET MF_TJ.LINE_TYP = 'NR' WHERE MF_TJ.UID_LO = c_rows(i).uid_lo; FORALL i IN c_rows.FIRST..c_rows.LAST UPDATE MF_AJ SET MF_AJ.LINE_TYP = 'NR' WHERE MF_AJ.TJ_UID_LO = c_rows(i).uid_lo; EXIT WHEN c_rows.COUNT < blimit; END LOOP; CLOSE curupdate1; END;
See you soon,.
Gas
-
iHi.
Declare cursor c_1 is select col1,col2,col3,col4 from table1 type t_type is table of c_1%rowtype index by binary_integer; v_data t_type; BEGIN OPEN c_1; LOOP FETCH c_1 BULK COLLECT INTO v_data LIMIT 200; EXIT WHEN v_data.COUNT = 0; FORALL i IN v_data.FIRST .. v_data.LAST INSERT INTO xxc_table (col1, col3, col4 ) SELECT v_data (i).col1, v_data (i).col3, v_data (i).col4 FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM xxc_table a WHERE col1=col1 ..... ); --commit; INSERT INTO xxc_table1 (col1, col2, col3, col4 ) SELECT v_data (i).col1, v_data (i).col2, v_data (i).col3, 'Y' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM xxc_table1 a WHERE col1=col1 ..... ); --exit when c_1%notfound; END LOOP; CLOSE c_1; commit; END;
I get 40/28-PLS-00201: identifier 'I' must be declared what the problem in the above code please help me and I have lakhs of data
Thank you
Post edited by: Rajesh123 I changed IDX
Post edited by: Rajesh123 changed t_type c_1 in Fetch
But by using a SET of INSERT to insert into two tables at once in the same query would do the job without any collection of bulk of PL and avoid to query two times too.
for example, as a single INSERT...
SQL > create table table1 as
2. Select 1 as col1, col2 of 1, 1 as col3, 1 as col4 Union double all the
3 select 2,2,2,2 of all the double union
4 Select 3,3,3,3 Union double all the
5 Select 4,4,4,4 of all the double union
6 select 5,5,5,5 of all the double union
7 select 6,6,6,6 of all the double union
8 select 7,7,7,7 of all the double union
9 select 8,8,8,8 of all the double union
10. Select 9,9,9,9 to the Union double all the
11. Select double 10,10,10,10
12.Table created.
SQL > create table xxc_table like
2. Select 1 as col1, col3 2, 3 as col4 Union double all the
3. Select the 3, 4, 5 Union double all the
4. Select the 5, 6, 7 double
5.Table created.
SQL > create table xxc_table1 like
2. Select 3 as col1, col2, col3, 5 4 "n" as col4 Union double all the
3. Select the 6, 7, 8, double "n"
4.Table created.
SQL > insert all
2 when the xt_insert is null then
3 in xxc_table (col1, col3, col4)
4 values (col1, col3, col4)
5 when the xt1_insert is null then
6 in xxc_table1 (col1, col2, col3, col4)
7 values (col1, col2, col3, 'Y')
8. Select t1.col1 t1.col2, t1.col3, t1.col4
9, xt.col1 as xt_insert
10, xt1.col1 as xt1_insert
11 from table1 t1
12 left join external xxc_table xt (t1.col1 = xt.col1)
13 left xt1 xxc_table1 outer join (t1.col1 = xt1.col1)
14.15 rows created.
SQL > select * from xxc_table by 1.
COL1 COL3 COL4
---------- ---------- ----------
1 2 3
2 2 2
3 4 5
4 4 4
5 6 7
6 6 6
7 7 7
8 8 8
9 9 9
10-10-1010 selected lines.
SQL > select * from xxc_table1 by 1.
COL1 COL2 COL3 C
---------- ---------- ---------- -
1 1 1 Y
2 2 2 Y
3 4 5 N
4 4 4 Y
5 5 5 Y
6 7 8 N
7 7 7 Y
8 8 8 Y
9 9 9 Y
10-10-1010 selected lines.
SQL >
-
Bulk collect / forall type what collection?
Hi I am trying to speed up the query below using bulk collect / forall:
SELECT h.cust_order_no AS custord, l.shipment_set AS Tess
Info.tlp_out_messaging_hdr h, info.tlp_out_messaging_lin l
WHERE h.message_id = l.message_id
AND h.contract = '12384'
AND l.shipment_set IS NOT NULL
AND h.cust_order_no IS NOT NULL
H.cust_order_no GROUP, l.shipment_setI would like to get the 2 selected fields above in a new table as quickly as possible, but I'm pretty new to Oracle and I find it hard to sort out the best way to do it. The query below is not working (no doubt there are many issues), but I hope that's sufficiently developed, shows the sort of thing, I am trying to achieve:
DECLARE
TYPE xcustord IS TABLE OF THE info.tlp_out_messaging_hdr.cust_order_no%TYPE;
TYPE xsset IS TABLE OF THE info.tlp_out_messaging_lin.shipment_set%TYPE;
TYPE xarray IS the TABLE OF tp_a1_tab % rowtype INDEX DIRECTORY.
v_xarray xarray;
v_xcustord xcustord;
v_xsset xsset;
CUR CURSOR IS
SELECT h.cust_order_no AS custord, l.shipment_set AS Tess
Info.tlp_out_messaging_hdr h, info.tlp_out_messaging_lin l
WHERE h.message_id = l.message_id
AND h.contract = '1111'
AND l.shipment_set IS NOT NULL
AND h.cust_order_no IS NOT NULL;
BEGIN
Heart OPEN;
LOOP
News FETCH
LOOSE COLLECTION v_xarray LIMIT 10000;
WHEN v_xcustord EXIT. COUNT() = 0;
FORALL I IN 1... v_xarray. COUNTY
INSERT INTO TP_A1_TAB (cust_order_no, shipment_set)
VALUES (v_xarray (i) .cust_order_no, v_xarray (i) .shipment_set);
commit;
END LOOP;
CLOSE cur;
END;I'm running on Oracle 9i release 2.
Short-term solution may be to a world point of view. Pay once per hour for the slow and complex query execution. Materialize the results in a table (with clues in support of queries on the materialized view).
Good solution - analysis logic and SQL, determine what he does, how he does it and then figure out how this can be improved.
Ripping separate cursors in SQL and PL/SQL code injection to stick together, are a great way to make performance even worse.
-
Fetch Bulk collect Insert error
CREATE OR REPLACE PROCEDURE bulk_collect_limit (StartRowOptional in NUMBER, EndRowOptional number, fetchsize in NUMBER)
IS
SID TYPE TABLE IS NUMBER;
Screated_date TYPE IS an ARRAY OF DATE;
Slookup_id TYPE TABLE IS NUMBER;
Surlabasedesdonneesdufabricantduballast ARRAY TYPE IS VARCHAR2 (50);
l_sid sid;
l_screated_date screated_date;
l_slookup_id slookup_id;
l_sdata surlabasedesdonneesdufabricantduballast;
l_start NUMBER;
ID IS of SELECT CURSOR of c_data, created_date, lookup_id, data1 FROM big_table WHERE id > = StartRowOptional AND id < = EndRowOptional;
Reclist TYPE IS an ARRAY OF c_data % ROWTYPE;
reclist REB;
BEGIN
l_start: = DBMS_UTILITY.get_time;
OPEN c_data;
LOOP
Fetch the c_data COLLECT in BULK IN CER LIMIT fetchsize;
BECAUSE me IN REB. FIRST... REB. LAST
LOOP
INSERT INTO values big_table2 (REB (i) user.user, REB (i) .created_date, recs (i) .lookup_id, (i) recs .data1);
END LOOP;
OUTPUT WHEN c_data % NOTFOUND;
END LOOP;
C_data CLOSE;
COMMIT;
Dbms_output.put_line ('Total elapsed:-' |) (DBMS_UTILITY.get_time - l_start) | "hsecs");
EXCEPTION
WHILE OTHERS THEN
LIFT;
END;
/
DISPLAY ERRORS;
WARNING: the execution is completed with warning
29/87 PLS-00302: component "DATA1" must be declared
29/87 PL/SQL: ORA-00984: column not allowed here
29/6 PL/SQL: statement ignored
I get the error error above in the insert statement.
Please can I get help to solve.
I won't answer your question, but say you something else - do not do this with bulk collect. Do it in a single SQL statement.
Stop using loops and by engaging in loops.
Who will solve the error, makes it less likely, you get error ORA-01555, create less recovery and be more effective.
Oh, and it does nothing useful:
EXCEPTION
WHILE OTHERS THEN
LIFT;
The entire procedure should be:
CREATE OR REPLACE PROCEDURE bulk_collect_limit (startrow IN NUMBER,endrow IN NUMBER,fetchsize IN NUMBER) IS l_start NUMBER; begin insert into big_table2(put a column list here for crikey's sake) select id,created_date,lookup_id,data1 FROM big_table WHERE id >= startrow AND id <= endrow; DBMS_OUTPUT.put_line('Total Elapsed Time :- ' || (DBMS_UTILITY.get_time - l_start) || ' hsecs'); end;
-
Get help in BULK COLLECT IN the treatment
the following gives me PLS-00302 error: component 'R_MDATA' must be declared
---------------------------------------------
declare
error_1555 exception;
pragma exception_init (error_1555,-1555);
number num.
-set the record
TYPE RJ_RECORD is RECORD (r_rowr_mdata BLOB ROWID);
-set the table based on the file type
TYPE RJ_LIST_T IS TABLE OF RJ_RECORD
INDEX BY PLS_INTEGER;
-our structure will be bulk collect into
l_List RJ_LIST_T;
sql_str varchar2 (2000);
cursor ovs_tab is SELECT table_name from user_tables;
Start
for c_rec in ovs_tab LOOP
sql_str: = ' select rowid, m_data of ' | c_rec.table_name;
run immediately sql_str
COLLECTION in BULK IN l_list;
for indx in 1.l_list. COUNTY
LOOP
Start
NUM: = dbms_lob.instr (l_list. R_MDATA(indx), hextoraw ('889911')) ; -He does not like r_mdata
exception
When error_1555 then
-Insert in the values of corrupted_lob_data (l_list.rj_rowid (indx), c_rec.table_name);
-commit;
dbms_output.put_line (' corrupt tab = ' | c_rec.table_name);
end;
END LOOP;
end loop;
end;
/
change l_list.r_mdata (indx)
TO
.r_mdata l_list (indx)
Each table has a column named m_data?
-
Exception handlers in bulk collect and for all operations?
Hello world
My version of DB is
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
AMT for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
My question is, what are the possible exception handlers can add us in a bulk collect and for all operations?
When we use for all, we add except exception and sql % bulk_exceptions. But apart from that what can we add to bulk collect?
Kind regards
BS2012.
Save stores Exception all the exceptions that occur during in bulk in a collection of treatment and at the end of the most much treatment raises an exception. The SQL % BULK_EXCEPTIONS collection has all exceptions. It's the right way to handle the exception during treatment in bulk. And that's all you need. Don't know what else await you.
-
Bulk Collect and Millions of records.
Hey guys,.
I did experiences autour with big collect in GR 11, 2...
I have millioms of files with very large tables.
In fact, my question is this. How do you use bulk collect when you have millions of records?
Everytime I try to use it for bulk collect into, I have run out of memory.
So should I stick with the SQL engine when it comes to manipulate millions
folders? Is maninly bulk collect for insert, updates to use for applications?
Summer banging my head for awhile with it. Can a Pl/SQL pro if you please
Give me some advice on this?
In most cases SQL insert/update engine will end up more quickly then PL/SQL select + Insert/Update. Normally, you would use PL/SQL, if there is a complex logic that is based on calculations of several rows that can be easily made in SQL. If you must use BULK COLLECT many or / and wide lines, you can divide it into segments using LIMIT.
SY.
-
Select Insert and bulk collect into exadata
Hi all
We work in Oracle Exadata. I am new to oracle exacta. We need to insert some 7.5 million records in our table. My manager who has worked at exadata asked me to insert, select to load the data of 7.5 million records from one table to another. He asked me to forget fired fresh concepts in bulk. I read exadata prefer basic set rank of basic techniques. Is in bulk collect not a technical set base? Select Insert or in bulk which is a better technique, gather to load records from one table to the other in oracle exadata? Please advise me on this issue
Mantra of Tom apply for Exadata and, in its follow-up here:
Ask Tom & quot; DML only insert & #x2F; Select or bulk collect... & quot;
-
On bulk collect forall vs fusion simple statement
I understand that a single DML statement is better that use bulk collect to have all the intermediary undertakes. My only concern is that if I load a large amount of data as a record 100 million records in a 800 million table with foreign keys and indexes and the session is killed, the cancellation may take some time which is not acceptable. Using bulk collect forall with interval of validations is slower than a declaration unique fusion straight, but in the case of dead session, the restore time will be not too bad and a reload of the not yet committed data will be not as bad. For the design of a load of recoverable data which may not be affected as badly, is in bulk collect + for all the right approach?
So if I chunk it upward in 50 lines, the child table must be loaded to its matching when records the parent table loaded and validate them.
... and then create a procedure that takes care of the parent AND child data at the same time.
SQL for DBMS_PARALLEL_EXECUTE would be:
"start load_parent_and_child (: start_id,: end_id); end; »
PS - you don't want to run ECD and DML PARALLEL at the same time...
MK
-
Hello
I'm using the version of oracle 11g.
How can I access the data in the table variable V_emp?
Set serveroutput size unlimited
declare
type emp_type is table emp % rowtype
index of directory;
v_emp emp_type;
Start
Select emp.* bulk collect into v_emp
EMP;
because me in 1.v_emp.count
loop
dbms_output.put_line (How can I display all the data in the v_emp array variable?);
end loop;
end;
/
Thank you
DECLARE
CURSOR c1 IS (SELECT * FROM emp);
TYPE typ_tbl IS TABLE c1% rowtype;
v typ_tbl;
BEGIN
OPEN c1;
LOOP --Loop added
C1 FETCH BULK COLLECT IN v LIMIT 3; -treat 3 records at a time
-treat the first 3 max records
DBMS_OUTPUT. Put_line ('Treatment' | v.COUNT |) "documents.");
I'm IN v.first... v.Last LOOP
DBMS_OUTPUT. Put_line (v (i) .empno);
END LOOP;
OUTPUT WHEN c1% NOTFOUND;
END LOOP;
DBMS_OUTPUT. Put_line ('all done');
END;
Maybe you are looking for
-
HP G62-450sl: laptop enter your administrator password or power on password
Hi there please... I'm desperate please help me with this password. My error code: 51249417
-
Lenovo B50-50 does not recognize my external hard drive
I recently bought a laptop Lenovo B50-50 and it does not recognize my external hard drive. It's a WD elements with USB 3.0 storage device. I tried a few of the fixes recommended on other forums, but none of them work. The hard drive comes up is the l
-
Hi all I'm currently trying (and failing!) to set up an event from a display Image window reminder in CVI. All that I need SIA a collation of co-ordinate of Pixel that was clicked I try to use SetEventCallback, but am not sure how to set up the Event
-
Problems with the published variable network shared
Greetings, I have difficulties in obtaining data on the network. I can see that the editor SV will correctly the data, but the customer (lu) variable is an empty string. I don't get any errors and I also checked the IP addresses in the alias files
-
Need help with windows media player. I have about 4500 titles on an external memory that I play via my portable media player and windows. Which is annoying, when he's near the end of a track that plays it skips and jumps. It does on all of the tracks