Msg of error taken in bulk collect?
HelloIn bulk below collect part i m having error of date code (i.e. cm_date = 12/12 k 2001 due to the issue of data).
So how can I catch exception msg bulk collect?
Can I use bulk collect as FORALL?
--------------------------------------------------------------------------
BECAUSE me in 1... % BULK_EXCEPTIONS SQL. COUNTY
LOOP
DBMS_OUTPUT. Put_line (' error :'||) SQLERRM (-SQL % BULK_EXCEPTIONS (i).) ERROR_CODE));
END LOOP;
--------------------------------------------------------------------------
looking at the o/p its only "str1" printing and the msg of error ora-01841
----------------------------------------------------------------------------------------------------------------
{
declare
VAR_TYP TYPE IS VARRAY (32767) OF VARCHAR2 (32767).
V_CASL_CM_DATE VAR_TYP;
Start
DBMS_OUTPUT. Put_line ('str 1');
Start
SELECT TO_DATE (casl. CM_DATE, "DD/MM/YYYY")
TO COLLECT FEES IN BULK
IN V_CASL_CM_DATE
The left outer JOIN of the DBMG_CM_A_STL-casl
B CO_CNY on B.CD_CNY_ISO = NVL (casl. Curr_Code, "AED")
WHERE casl. CM_NUMBER = 4203884;
EXCEPTION
WHILE OTHERS THEN
Tr_Ltm_Tnd_Err_Cnt: = Tr_Ltm_Tnd_Err_Cnt + SQL % BULK_EXCEPTIONS. COUNTY;
DBMS_OUTPUT. Put_line (' error: unexpected loading of SAL_DETL to Tr_Ltm_Tnd: ' |) SQLERRM);
BECAUSE me in 1... % BULK_EXCEPTIONS SQL. COUNTY
LOOP
DBMS_OUTPUT. Put_line (' error :'||) SQLERRM (-SQL % BULK_EXCEPTIONS (i).) ERROR_CODE));
END LOOP;
END;
DBMS_OUTPUT. Put_line ('str 2');
BEGIN
FORALL V_CASL_CM_DATE case. FIRST... V_CASL_CM_DATE. FINALLY SAVE THE EXCEPTIONS
INSERT INTO Tr_Ltm_Tnd
VALUES (V_CASL_CM_DATE (case),
);
Tr_Ltm_Tnd_Cnt: = Tr_Ltm_Tnd_Cnt + N_CASL_CM_NUMBER. COUNTY;
EXCEPTION
WHILE OTHERS THEN
Tr_Ltm_Tnd_Err_Cnt: = Tr_Ltm_Tnd_Err_Cnt + SQL % BULK_EXCEPTIONS. COUNTY;
Sqlerm: = SUBSTR (sqlerrm, 1, 200);
DBMS_OUTPUT. Put_line (' error: unexpected loading of SAL_DETL to Tr_Ltm_Tnd: ' |) Sqlerm);
BECAUSE me in 1... % BULK_EXCEPTIONS SQL. COUNTY
LOOP
DBMS_OUTPUT. Put_line (' error :'||) SQLERRM (-SQL % BULK_EXCEPTIONS (i).) ERROR_CODE));
END LOOP;
END;
end;
}
----------------------------------------------------------------------------------------------------------------
Rgds,
PC
Same error 10 times?
Depends on what you mean.
You should get an exception recorded for each exception.
The collections are actually reset each outer loop.
Index numbers (i in this case) will be recycled for each loop.
So if the indexed collection value wrong 3 in the first loop, no you wouldn't not see that in following loop unless it was a different error.
Tags: Database
Similar Questions
-
Hello
I tried with the following code,
get the following errDECLARE TYPE EmpRec IS RECORD (last_name EMP.ename%TYPE, salary emp.sal%TYPE); emp_info EmpRec; TYPE empnest IS TABLE OF EMP.empno%TYPE; empnestvar empnest; BEGIN empnestvar := empnest(7566,7788); FOR i in empnestvar.first..empnestvar.last LOOP UPDATE emp SET sal = sal * 1.1 WHERE empno = empnestvar(i) RETURNING ename, sal BULK COLLECT INTO emp_info; DBMS_OUTPUT.PUT_LINE('Just gave a raise to ' || emp_info.last_name || ', who now makes ' || emp_info.salary); ROLLBACK; END LOOP; END;
Could you please advice me in thisRETURNING ename, sal BULK COLLECT INTO emp_info; * ERROR at line 11: ORA-03113: end-of-file on communication channel
Thank youWhy he does ' t work with
COLLECTION in BULK IN the variable of type record. >
This is how it is designed and defined! In fact, to put it very simply, BULK COLLECT means collectors several at a go (forgive me if my English is not the best), the record type variable can contain both.
A vary another important thing that I missed before, avoid using COMMIT or ROLLBACK inside the loop. You can search for AskTom for more explanations.Published by: mohamed on April 8, 2011 18:19
-
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;
-
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
-
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;
-
Error using BULK collect with RECORD TYPE
Hello
I wrote a simple procedure to declare a record type & then by a variable of type NESTED table.
I then selects the data using COLLECT in BULK & trying to access it via a LOOP... We get an ERROR.
------------------------------------------------------------------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE sp_test_bulkcollect
IS
TYPE rec_type () IS RENDERING
emp_id VARCHAR2 (20).
level_id NUMBER
);
TYPE v_rec_type IS TABLE OF THE rec_type;
BEGIN
SELECT employe_id, level_id
LOOSE COLLECTION v_rec_type
OF portfolio_exec_level_mapping
WHERE portfolio_execp_id = 2851852;
FOR indx IN v_rec_type. FIRST... v_rec_type. LAST
LOOP
dbms_output.put_line ('Emp-' | v_rec_type.emp_id (indx) |) » '|| v_rec_type.level_id (indx));
END LOOP;
END;
-----------------------------------------------------------------------------------------------------------------------------------
Here is the ERROR I get...
-Errors of compilation for the PROCEDURE DOMRATBDTESTUSER. SP_TEST_BULKCOLLECT
Error: PLS-00321: expression "V_REC_TYPE" is not appropriate for the left side of an assignment statement
Online: 15
Text: IN portfolio_exec_level_mapping
Error: PL/SQL: ORA-00904: invalid identifier
Online: 16
Text: WHERE portfolio_execp_id = 2851852;
Error: PL/SQL: statement ignored
Line: 14
Text: COLLECT LOOSE v_rec_type
Error: PLS-00302: component 'FIRST' must be declared
Online: 19
Text: LOOP
Error: PL/SQL: statement ignored
Online: 19
Text: LOOP
------------------------------------------------------------------------------------------------
Help PLZ.and with a complete code example:
SQL> CREATE OR REPLACE PROCEDURE sp_test_bulkcollect 2 IS 3 TYPE rec_type IS RECORD ( 4 emp_id VARCHAR2(20), 5 level_id NUMBER 6 ); 7 TYPE v_rec_type IS TABLE OF rec_type; 8 v v_rec_type; 9 BEGIN 10 SELECT empno, sal 11 BULK COLLECT INTO v 12 FROM emp 13 WHERE empno = 7876; 14 FOR indx IN v.FIRST..v.LAST 15 LOOP 16 dbms_output.put_line('Emp -- '||v(indx).emp_id||' '||v(indx).level_id); 17 END LOOP; 18 END; 19 / Procedure created. SQL> SQL> show error No errors. SQL> SQL> begin 2 sp_test_bulkcollect; 3 end; 4 / Emp -- 7876 1100 PL/SQL procedure successfully completed.
-
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;
/
-
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;
/
-
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 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?
-
bulk collect into the collection of objects
create or replace type typ_obj as an object
(l_x number (10),)
l_y varchar2 (10),
LZ varchar2 (10)
);
Create the type typ_obj_tt is table of the typ_obj;
/ / DESC insert_table;
c_x number (10)
C_P number (10)
temp2_table / / DESC
doJir number (10)
c_y varchar2 (10)
c_z varchar2 (10)
procedure prc_x (p_obj_out ON typ_obj_tt)
is
cursor c1
is
Select t1.c_x,
T2.c_y,
T2.c_z
Of
insert_table t1,
temp2_table t2
where
....
;
Start
Open c1;
collect the fetch c1 into loose in p_obj_out;
Close c1;
end;
raises the error
can you tell
How to enter data in this object of type of output table
Thanks in advance... any help will be much appreciated...PL do not spam the forums with topics in double - bulk collect into the collection of objects
-
make exception when using BUlk collect
Hi all
version of DB 10 g
I've written a procedure as below
now, I tried to perform the procedure belowcreate or replace procedure test_proc2 is type v_emp_rec is record (empno number, ename varchar2 (200)); type v_emp_tab is table of v_emp_rec index by binary_integer; v_tab v_emp_tab; begin select empno,ename into v_tab(0) from emp where empno = 7369; dbms_output.put_line (v_tab(0).ename); exception when no_data_found then dbms_output.put_line ('I am in no data found exception'); end;
the foregoing is works well, but I want to use the functionality of collection in bulk so I use as belowbegin test_proc2; end;
the foregoing gives me exception, please someone can explain why it is not in the exception block.create or replace procedure test_proc2 is type v_emp_rec is record (empno number, ename varchar2 (200)); type v_emp_tab is table of v_emp_rec index by binary_integer; v_tab v_emp_tab; begin select empno,ename bulk collect into v_tab from emp where empno = 7369; dbms_output.put_line (v_tab(0).ename); exception when no_data_found then dbms_output.put_line ('I am in no data found exception'); end;
Thanks in advance.The obvious answer is because an exception no_data_found is raised.
The question is there.It's either select it because there is no data where empno = 7369.
Or is the .ename of v_tab (0), because there is no element 0. Automatic collection of indexing starts at 1.
for example
SQL> declare 2 type t1 is table of pls_integer index by pls_integer; 3 v1 t1; 4 begin 5 v1(1) := 1; 6 dbms_output.put_line(v1(0)); 7 end; 8 / declare * ERROR at line 1: ORA-01403: no data found ORA-06512: at line 6 SQL>
If you catch the exceptions and do not spread them properly, then hide you all information kind of useful as a line number, etc..
-
Issue of PL/SQL Bulk Collect
Hi Experts,
I did a lot of research on this and finally decided to post a new thread, impossible to find an answer. So what we try to do is to select a few order_number a table and remove order numbers in another table. I tried without bulk collect it worked, but the treatment is too evil takes a lot of time from the table and he selects in huge therefore planned to use the COLLECTION in BULK
CREATE OR REPLACE PROCEDURE closed_test (tabname varchar)
is
Type is Sub_Rp_Typ table of closed_order_cur % Rowtype;
order_nbr_var Sub_Rp_Typ;
v_sql varchar2 (4000);
number of v_rowcount_int;
number of v_rowcount_fin;
cursor closed_order_cur is select order_nbr from closed_order;
Start
run immediately "select count (*) from ' |" tabname in v_rowcount_int;
Open closed_order_cur;
collect the fetch closed_order_cur in bulk in order_nbr_var;
Because me in order_nbr_var... FIRST order_nbr_var. LAST loop
v_sql: =' delete ' | tabname |' where internal_order_id = "' | order_nbr_var (i) | " ' ;
immediately run v_sql;
commit;
run immediately "select count (*) from ' |" tabname in v_rowcount_fin;
When the output closed_order_cur % notfound;
end loop;
dbms_output.put_line (' number of deleted rows:-' | to_char(v_rowcount_int-v_rowcount_fin,'999'));
end;
/
This is my probably the easiest PL/SQL, I'm a developer ETL and put my hand around SQL procedure
The error I get is
LINE/COL ERROR
-------- ----------------------------------------------------------------
3/8 PL/SQL: ignored element
3/36 PLS-00320: the declaration of the type of this expression is
incomplete or incorrect
12/4 PL/SQL: statement ignored
12/45 PLS-00597: expression "ORDER_NBR_VAR" in the list is
wrong type
14/10 PL/SQL: statement ignored
14/17 PLS-00306: wrong number or types of arguments in the call to ' |'
your help is frequented in advance
Thank you
Alan(1) why do you need to use dynamic SQL statements? The fact that you do not know what as the name of the table that you delete but not sure he has an INTERNAL_ORDER_ID column that has an ORDER_NBR of the CLOSED_ORDER table seems pretty unlikely to me.
(2) if effectiveness is your goal, you'll want to do everything in SQL. It all comes down to a single DELETE statement
DELETE FROM some_table_name dest WHERE EXISTS( SELECT 1 FROM closed_order src WHERE src.order_nbr = dest.internal_order_id ) dbms_output.put_line( SQL%ROWCOUNT || ' rows deleted' );
If you really don't know the name of the destination table, you can, of course, use dynamic SQL to create this DELETE statement.
Justin
-
Bulk collect and type returns nothing
Hello
I have the following code:
This code returns PL/SQL procedure successfully completed.declare type view_my_type is table of admuser.my_view%rowtype index by pls_integer; --x admuser.my_view%rowtype; my_array view_my_type; cursor c1 is select * from admuser.my_view; s long; i number := 1; begin s := 'crate table '; open c1; loop fetch c1 bulk collect into my_array limit 1; --s := s ||' decode (tf.fin_dates_id, '||my_array(i).fin_dates_id||', sum(tf.act_work_cost), 0) '; s := my_array(i).fin_dates_id; exit when c1%notfound; end loop; close c1; dbms_output.put_line(s); exception when others then null; end;
but don't show me is not the variable "s".
Can you help me with this?
Thank youThere a quite a number of things not just here.
First of all, allow me to reproduce your situation:SQL> create table my_view 2 as 3 select 'hello' fin_dates_id from dual 4 / Table created. SQL> declare 2 type view_my_type is table of my_view%rowtype index by pls_integer; 3 my_array view_my_type; 4 cursor c1 is 5 select * 6 from my_view; 7 s long; 8 i number := 1; 9 begin 10 s := 'crate table '; 11 open c1; 12 loop 13 fetch c1 bulk collect into my_array limit 1; 14 s := my_array(i).fin_dates_id; 15 exit when c1%notfound; 16 end loop; 17 close c1; 18 dbms_output.put_line(s); 19 exception 20 when others then 21 null; 22 end; 23 / PL/SQL procedure successfully completed.
And I SERVEROUTPUT on. Your exception handler is notoriously wrong. It is said: If something goes wrong, we'll pretend it didn't happen. And that's exactly what happened here: something has gone wrong and you have chosen to not know about it.
We will remove the exception handler to see what went wrong:
SQL> declare 2 type view_my_type is table of my_view%rowtype index by pls_integer; 3 my_array view_my_type; 4 cursor c1 is 5 select * 6 from my_view; 7 s long; 8 i number := 1; 9 begin 10 s := 'crate table '; 11 open c1; 12 loop 13 fetch c1 bulk collect into my_array limit 1; 14 s := my_array(i).fin_dates_id; 15 exit when c1%notfound; 16 end loop; 17 close c1; 18 dbms_output.put_line(s); 19 end; 20 / declare * ERROR at line 1: ORA-01403: no data found ORA-06512: at line 14
A no-data-found, because you are referencing my_array (i), when I is null. Just move the OUTPUT when a line upwards as well as your code runs better:
SQL> declare 2 type view_my_type is table of my_view%rowtype index by pls_integer; 3 my_array view_my_type; 4 cursor c1 is 5 select * 6 from my_view; 7 s long; 8 i number := 1; 9 begin 10 s := 'crate table '; 11 open c1; 12 loop 13 fetch c1 bulk collect into my_array limit 1; 14 exit when c1%notfound; 15 s := my_array(i).fin_dates_id; 16 end loop; 17 close c1; 18 dbms_output.put_line(s); 19 end; 20 / hello PL/SQL procedure successfully completed.
Then next to fix things are:
-do not use the long data type Use a VARCHAR2 or a CLOB.
-' Cashier' should probably be 'create '.
-in bulk, treatment with limit 1. Now you have the worst of both sides: line by line, treatment and slightly more complex syntax
-Variable increment I
-Easier (and thus better) use a loop FORI hope this helps.
Kind regards
Rob. -
Bulk collect and cursors using rowtype
Hello
I'm trying just one big collect of a table and display one of the values.
It keeps giving me the error:
dbms_output.put_line ('f_viewed_rec: ' | f_viewed_rec.job_id (i));
*
ERROR on line 66:
ORA-06550: line 66, column 53:
PLS-00302: component 'JOB_ID' must be declared.
----
cursor f_viewed IS
Select job_id of the work;
type f_viewed_type is table of the f_viewed % rowtype;
f_viewed_rec f_viewed_type;
Start
Open f_viewed;
LOOP
F_viewed fetch bulk collect within the limit of 5000 f_viewed_rec;
--------
I'm in f_viewed_rec.first... f_viewed_rec. Last
LOOP
dbms_output.put_line ('f_viewed_rec: ' | f_viewed_rec.job_id (i));
END LOOP;
END LOOP;
end;
/
--------------------------
Any ideas? Thanks much for any help.
-JennyDifficulty
dbms_output.put_line('f_viewed_rec: '||f_viewed_rec.job_id(i));
TO
dbms_output.put_line('f_viewed_rec: '||f_viewed_rec(i).job_id);
Kind regards
Sayan M.
Maybe you are looking for
-
Windows Server R2 Enterprise 2012 drivers mouse/pointer
I recently recharge a little Windows 2012 R2 Enterprise NAS server that I have and I have no mouse pointer. I tried clicking through all the and none are coming. I tried to uninstall and reinstall by Device Manager, but it helped, and it's really h
-
Touchpad problem - running on battery power, does not work when it is connected.
Laptop Toshiba with Vista. The Synaptics touch pad battery power works fine. When it is plugged in, it freezes. Disconnect the power supply and back to the battery and everything is fine. That's happened? How can I get the touchpad to work in both
-
Pavilion dm4 3005tx: HP Pavilion dm4
I installed windows 8.1 pro on my laptop. When I try to install windows 7 Home Edition premium instead of windows 8.1, I have the following error "Recovery". Your PC needs to be repaired for pc uyour boot configuration data is missing or containing e
-
Upgrade in Place attached to the last step
I'm trying to fix a problem in MS Explorer by an upgrade in Place for my Vista Home Premium 32 - bit with a Vista DVD provided by SM. He went even until the last step and is now hooked to 64% (3 hours). I don't see no choice but to cancel and to expe
-
Odd error Q10 blackBerry connecting to wifi
Whenever I try to connect to a wifin connection that requires a user name and password, I get an error message saying "the network is unavailable. Please try again later"However, I see that I 've connected, despite the error message. Someone at - it