The exception of collection management in bulk
Hello guys,.
Please help me with a code to retrieve the data from the table with the wrong data type...
I have a table with data
Col1 (VARCHAR2 (10))
--------------------
1001
1002
1003
1004
1006
1007
A
1009
1010
I need to write a PL/SQL code to bulk collect the data in the table above in a variable (number v_num) except that "a." Please let me know how to handle the exception invalid number in this case. I use oracle 10G
But I need to know how to handle the exception in Collect(while collecting the data, there is an error) in bulk
Hmm, good to know how it works, you can try to SAVE the exceptions (as below). But remember what said Paul Horth and keep in mind. That is why I didn't post earlier.
-Create a table to store
SQL > create table tab_num (col1 NUMBER);
DECLARE
type tt is the table of a % rowtype;
v_num tt;
v_errnum NUMBER;
CURSOR c1
IS
SELECT col1 from a;
BEGIN
OPEN c1;
LOOP
FETCH c1 COLLECT LOOSE v_num LIMIT 1; -The limit that you can modify according to the requirement
-DBMS_OUTPUT. Put_line('v_num. COMTE-'|| v_num. COUNT);
WHEN v_num EXIT. COUNT = 0;
FORALL idx IN 1.v_num. COUNT SAVE EXCEPTIONS
INSERT INTO tab_num VALUES v_num (idx);
COMMIT;
END LOOP;
CLOSE c1;
EXCEPTION
WHILE OTHERS THEN
DBMS_OUTPUT. Put_line ('Others - Err' |) SQLERRM);
v_errnum: = SQL % BULK_EXCEPTIONS. COUNTY;
BECAUSE me IN 1.v_errnum
LOOP
DBMS_OUTPUT. Put_line ('Err' |) SQL % BULK_EXCEPTIONS (i) .error_index | "Message - ' | SQLERRM (0 - SQL %BULK_EXCEPTIONS(i).error_code));)
END LOOP;
END;
Tags: Database
Similar Questions
-
The exception of procedure management
Hello guys,.I have a code below:
BEGIN
-Appeal procedure B;
END;
B() PROC
AS
USER_DEF EXCEPTION;
BEGIN
IF < SOME_CONDITION > THEN
RAISE USER_DEF;
END IF;
END;
I want to throw an exception of PROCEDURE B and want to handle in the calling PL/SQL block.
IS THIS POSSIBLE?
Can anyone guide me on this please?
Thank you
Rajendra
Hello
given that the exception is defined in B the calling procedure may not see it.
You can create a package with your exceptions, then B would raise errorpackage.user_def and the calling procedure can check WHEN errorpackage.user_def.
Concerning
Marcus
Edit:
Example of
CREATE or REPLACE PACKAGE my_errors
AS
e_user_defined EXCEPTION;
c_user_defined CONSTANT INTEGER: =-20500;
PRAGMA EXCEPTION_INIT (e_user_defined,-20500);
...
Now, you can
RAISE my_errors.e_user_defined;
and search for
WHEN my_errors.e_user_defined THEN
And your exception will be associated with SQLCODE-20500
See also 101 PL/SQL: exception handling
-
The exception of DOM JmsAdapter analysis management
Hello
I am currently facing a problem with the behavior of the Jms adapter.
Whenever a JMS message is put in the queue, and the message is not XML valid, the Jms adapter (consumer) throw the exception "DOM Parsing Exception to the Exception translator".
It's fine, I understand that the message was not well-formed. But what is not fine is that the underlying BPEL is not instantiated: which means that I can't handle the exception properly.
Y at - there a way to force the Jms adapter not crashing on the analysis of DOM for the BPEL to be instantiated (and then be able to handle the exception it)?
Or is there a way to manage the error thrown by the Jms adapter itself? How?
I think that I have a workaround if there is no better option (if the two above questions cannot be decided) but I would rather not implement it since it will be a few extra steps / complexity.
> It would be to check the option "opaque schema native format" and then use a java embedded in order to decode the base64 string for finally parsing it.
Kind regards
Mathieu
Hi Mathieu,
Error messages before being assigned to the infrastructure of service are called rejects messages. For example, the Oracle file adapter selects a file with data in the CSV format and try to translate it into XML format (using NXSD). If there is a mistake in translation, the message is rejected and are not counted for the composite target.
You can create release managers to manage message errors. Message errors include those that occur during translation, incompatibility of correlation and analysis XML ID after receipt of the message.
Docs on how to do that are here...
http://docs.Oracle.com/CD/E28280_01/integration.1111/e10231/life_cycle.htm#CIAIICJJ
See you soon,.
Vlad
-
Management concept the exceptions that went wrong!
Well, this is by far the most embarrassing hack code I've done so far... but it works. I'm trying to run a select where if there is no data or null returned, place it in the value "v_pidm"and then let the action happen.» Pretty simple, right? Fake! A select statement returns no data that uses a function 'en' is an exception... "no data found". Oracle, it sends to the exception block as it should. Well, I don't want to stop and start my script a million times here, I added a Begin/End sub, with an exception to handle the error to say and perform an insert. I know that you should not use a State of exception for inserts another capture errors... you know bad practices and all. Any ideas as how to better manage the select statement that must regularly return no data? I was thinking some along the line of nvl (v_pidm, 0) or something, but I get errors.
set serveroutput ON SIZE 1000000 set heading off set feedback off set trimspool off set echo off set pagesize 0 set termout on Declare error varchar(255); v_pidm number(8); Begin Begin select distinct saraatt_pidm into v_pidm from saraatt, saradap where saraatt_appl_no = SARADAP_APPL_NO and saraatt_term_code = SARADAP_TERM_CODE_ENTRY and saraatt_pidm = 4; Exception when too_many_rows then error := SQLERRM; DBMS_OUTPUT.PUT_LINE(' %% Oracle Error! %% The select statement returned more than two rows '); when no_data_found then error := SQLERRM; DBMS_OUTPUT.PUT_LINE('Select Returned No Data . . . Therefore Insert new record for ' || v_pidm ); v_pidm := -999; when others then error := SQLERRM; DBMS_OUTPUT.PUT_LINE(' %% Oracle Error! %% An Error Occured ' || substr(error,5,20)); End; DBMS_OUTPUT.PUT_LINE('Pidm: ' || v_pidm); End;
There is nothing inherently wrong with code like
BEGIN SELECT column_name INTO l_variable_name FROM table_name WHERE some_where_clause; EXCEPTION WHEN no_data_found THEN l_variable_name := 0; END;
It is perfectly reasonable to have exception handlers that make anything other than newspaper an exception if they can in fact wisely handle the exception (e.g., you know that the query may return 0 rows and you know how to handle this case correctly).
You don't want an exception handler that simply calls to DBMS_OUTPUT. Put_line without re-raise the exception. It is a mistake to delay. And there is no real reason in this case to extract the SQLERRM in the variable error - it would be better to let the exception is propagated to the top so that you can see the full error stack.
Justin
-
How to manage the plsql error occurring in the exception block
We know how to manage exceptins located in the BEGIN block.
But I am unable to catch the exception in the exception block. Write an erroeneous code so that the control will go to the exception block and there is also a plsql error, but I am unable to handle that error, it returns the error to the calling environment.
DECLARE
CNT NUMBER (5): = 0;
BEGIN
Select "Chris" IN double's NTC;
DBMS_OUTPUT. Put_line (to_char (CNT));
EXCEPTION
WHEN invalid_number CAN
DBMS_OUTPUT. Put_line (' error occurred inside the start block ');
CNT: = "deba";
WHILE OTHERS THEN
DBMS_OUTPUT. Put_line (' error occurred inside the start block ');
END;
Please suggest me how to catch this exception?Hello
DECLARE
CNT NUMBER (5): = 0;BEGIN
Select "Chris" IN double's NTC;
DBMS_OUTPUT. Put_line (to_char (CNT));EXCEPTION
WHEN invalid_number CAN
DBMS_OUTPUT. Put_line (' error occurred inside the start block ');CNT: = "deba";
WHILE OTHERS THEN
DBMS_OUTPUT. Put_line (' error occurred inside the start block ');END;
First of all your exception mouhamadou who you have sent i.e. invalid_number itself does not.
You should use named exception VALUE_ERROR to catch the exception in the main block.SQL> DECLARE 2 cnt NUMBER(5):=0; 3 BEGIN 4 select 'debalina' INTO cnt from dual; 5 DBMS_OUTPUT.PUT_LINE(to_char(cnt)); 6 EXCEPTION 7 WHEN Invalid_number THEN 8 DBMS_OUTPUT.PUT_LINE('error has occured inside main block'); 9 end; 10 / DECLARE * ERROR at line 1: ORA-06502: PL/SQL: numeric or value error: character to number conversion error ORA-06512: at line 4 SQL> DECLARE 2 cnt NUMBER(5):=0; 3 BEGIN 4 select 'debalina' INTO cnt from dual; 5 DBMS_OUTPUT.PUT_LINE(to_char(cnt)); 6 EXCEPTION 7 WHEN VALUE_ERROR THEN 8 DBMS_OUTPUT.PUT_LINE('error has occured inside main block'); 9 end; 10 / error has occured inside main block PL/SQL procedure successfully completed.
Your doubts regarding catch the exception in the exception block, you can run as below, by nesting a block Begin in the exception block itself.
SQL> DECLARE 2 cnt NUMBER(35):=0; 3 BEGIN 4 select 'debalina' INTO cnt from dual; 5 DBMS_OUTPUT.PUT_LINE(to_char(cnt)); 6 EXCEPTION 7 WHEN Value_error THEN 8 DBMS_OUTPUT.PUT_LINE('error has occured inside main block'); 9 Begin 10 cnt:='deba'; 11 Exception 12 WHEN OTHERS THEN 13 DBMS_OUTPUT.PUT_LINE('error has occured inside exception block'); 14 End; 15 END; 16 / error has occured inside main block error has occured inside exception block PL/SQL procedure successfully completed.
Hope your question is clear.
:)
Twinkle -
Continue the block after the exception management
The guys in the slot block.
create or replace procedure proc_case (p_in IN number) is begin case p_in when 1 then dbms_output.put_line('its one'); when 2 then dbms_output.put_line('its two'); end case; dbms_output.put_line('after the exception handler'); exception when case_not_found then dbms_output.put_line('its not found'); end;
When the procedure is executed as follows.
begin proc_case(3); end;
It shows the statement in the block of exception, but after that it does not run the statement following the exception handler and the outputs of the block, how can I execute the statement after the end case statement. I do not use the Else statement in case because I wanted to understand the logic of this block.
CREATE OR REPLACE
PROCEDURE proc_case
(
p_in in NUMBER)
IS
BEGIN
BEGIN
P_in CASE
WHEN 1 THEN
dbms_output.put_line ('the one');
WHEN 2 THEN
dbms_output.put_line ('two');
END CASE;
EXCEPTION
WHEN case_not_found THEN
dbms_output.put_line ("' its not found");
END;
dbms_output.put_line ("' after the exception handler");
END;
-
Why out of the loop after a managed exception is thrown
I am trowing a custom exception inside a nested for loop. The execption notes, however, both the inner and outer loop output once the exception is thrown. I tried to add a continue statement, but that has not solved the problem.
Jet moves execution of capture, closing the loop. You can send a cancelable event instead.
-
Delete the exception management
Hi guys,.
I have a problem in my procedure. There are 3 parameters that I'm passing in the procedure. I am corresponding to these parameters to those of the table to delete one record at a time.
For example if I want to delete the record with the values (' '900682', 3, July 29, 2008 ') as parameters, it deletes the record of table, but still when I run it with the same parameters must show me an error message but it again says "deleted the request for transcript...". "Can you please help me with this?
PROCEDURE p_delete_szptpsr_1 (p_shttran_id IN saturn.shttran.shttran_id%TYPE,
p_shttran_seq_no IN saturn.shttran.shttran_seq_no%TYPE,
p_shttran_request_date IN saturn.shttran.shttran_request_date%TYPE) IS
BEGIN
DELETE FROM saturn.shttran
WHERE shttran.shttran_id = p_shttran_id
and shttran.shttran_seq_no = p_shttran_seq_no
and trunc (shttran_request_date) = trunc (p_shttran_request_date);
DBMS_OUTPUT. Put_line (' removed the transcript request Seq No. (' | p_shttran_seq_no | student (' | p_shttran_id |') for the requested date (' | p_shttran_request_date |'))) ') ;
COMMIT;
EXCEPTION WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT. Put_line (' error: the Notre Dame provided = student ID (' | p_shttran_id |))
('), Transcript No Request = (' | p_shttran_seq_no |) ('), Ask Date = (' | p_shttran_request_date | not found.');
END p_delete_szptpsr_1;
I have a SELECT statement to use NO_DATA_FOUND?A DELETE statement that will remove any line (such as an UPDATE statement that updates no line) is not an Oracle error. Oracle throws no exceptions.
If you want your code throws an exception, you will need to write this logic. You can throw an exception NO_DATA_FOUND yourself, i.e.
IF( SQL%ROWCOUNT = 0 ) THEN RAISE no_data_found; END IF;
If you go just to catch the exception, however, you could just some embedded code you would use to handle the exception in your IF statement, i.e.
IF( SQL%ROWCOUNT = 0 ) THEN <
> END IF; In your original code, your exception handler is just a statement of DBMS_OUTPUT. It is incredibly dangerous in real production code. You rely on the fact that the customer has allowed him to exit, that the customer has allocated a sufficient buffer, the user will see the message, and that the procedure will never be called to any piece of code that never worry if it succeeded or failed. There are very few situations where those who are sure of things to build on.
Justin
-
the exception in the procedure call management
Hello
I have a package where currently make phone calls to private public process procedures.
and the senario is: -.
create package body p_tst
is
ex_failed exception;
-It's private proc
procedure p_private
is
Start
.
.
raise ex_failed;
exception
When ex_failed
then
lift;
.........
end p_private;
procedure p_public
is
Start
....
-nomaking appeal to the private sector
-procedure
p_private;
-Here, I need to catch
-the exception thrown
-past of callee
-procedure
When ex_failed
...
end p_public;
end;
Basically, I want to catch any exception of procedure called passed to the procedure call and raise the same exception by calling procedure.
is it possible to intercept the exception even in the calling procedure?Yes, p_private throws the exception, it will be taken by p_public and the program stops after dbms_output.
-
I purchased the CS4 master collection for windows and I change my computer on a Mac. How to upgrade my license?
There is no option to update your CS4 license except subscribe to specially of the first creative cloud plan cuts the year for owners of CS (Adobe: creative, marketing, and document management solutions).
Platform swaps are allowed only for the most recent released CS software (CS6). You can get a version license Mac to CS4 by Adobe since Adobe doesn't sell older versions, and the only version of CS for sale is CS6... CS4 is not eligible to get CS6 at an upgrade price.
You can buy CS6 via the following page: http://www.adobe.com/products/catalog/cs6._sl_id-contentfilter_sl_catalog_sl_software_sl_c reativesuite6.htm
-
Save the exception error message
Hi all
Take into consideration the following:create table WXX_TEST ( ID NUMBER, COL1 VARCHAR2(5), COL2 VARCHAR2(25), ERRMS VARCHAR2(4000) )
create table WXX_TEST2 ( ID NUMBER, COL1 VARCHAR2(25), COL2 VARCHAR2(4) )
so... we're going to do the following:insert into wxx_test (ID, COL1, COL2) values (1, 'AA', 'BB'); insert into wxx_test (ID, COL1, COL2) values (2, 'AA', 'BB'); insert into wxx_test (ID, COL1, COL2) values (3, 'AA', 'BB'); insert into wxx_test (ID, COL1, COL2) values (4, 'AA', 'BB'); insert into wxx_test (ID, COL1, COL2) values (5, 'AA', 'BB'); insert into wxx_test (ID, COL1, COL2) values (6, 'AA', 'BB'); insert into wxx_test (ID, COL1, COL2) values (7, 'AA', 'CCCCCCCCCCCC'); insert into wxx_test (ID, COL1, COL2) values (8, 'AA', 'BB'); insert into wxx_test (ID, COL1, COL2) values (9, 'AA', 'BB'); insert into wxx_test (ID, COL1, COL2) values (10, 'AA', 'BB');
.. .and query the wxx_test table:declare cursor c is select id,col1,col2 from wxx_test; type t_a is table of c%rowtype; l_msg VARCHAR2(4000 CHAR); dml_errors EXCEPTION; PRAGMA exception_init(dml_errors, -24381); l_errors number; l_errno number; l_idx number; v_a t_a; begin open c; loop begin fetch c bulk collect into v_a limit 10; forall i in 1..v_a.count save exceptions insert /*+APEND_VALUES*/ into wxx_test2 values v_a(i); exception when dml_errors then l_errors := SQL%bulk_exceptions.count; FOR ii IN 1 .. l_errors LOOP l_errno := SQL%BULK_EXCEPTIONS(ii).error_code; l_msg := SQLERRM(-l_errno); l_idx := SQL%BULK_EXCEPTIONS(ii).error_index; update wxx_test set ERRMS = l_msg || ': ' || l_errno where id = v_a(l_idx).id; end loop; end; exit when c%notfound; end loop; close c; end; /
The result is:select * from wxx_test where id = 7
We can see that economy exceptions works very well, but we do not know which column is the problem... the error message indicates that the code of the error, not the context.ID COL1 COL2 ERRMS ---------- -------------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- 7 AA CCCCCCCCCCCC ORA-12899: value too large for column (actual: , maximum: ): 12899
In contrast, we do the following:
Any ideas how to get the context of the error message in the EXCEPTION of SAVING clause?insert into wxx_test2 values(11,'BB','TTTTTTTTTT') ORA-12899: value too large for column "WXX_TEST2"."COL2" (actual: 10, maximum: 4)
Have we not all SQL % BULK_EXCEPTIONS options?
DB version: 11g
Thanks in advance,
Alexander.
Published by: a.stoyanov on October 23, 2012 05:30
-
'Save the exception' does not work... ?
Hi all
In why I am not able to catch exceptions of code below... EMP_LOG. Ename size is 100 characters
--------------------------------------------------------------------------------------------------
DECLARE
TYPE EMPTYPE IS TABLE OF THE varchar2 (101)
INDEX OF DIRECTORY;
EMPTAB EMPTYPE.
EXCEPTION MY_EXCEPTION;
PRAGMA EXCEPTION_INIT (MY_EXCEPTION,-20001);
BEGIN
SELECT ENAME
BULK COLLECT INTO EMPTAB
FROM EMP;
EMPTAB (2): = RPAD (EMPTAB (2), 101, ' ');
EMPTAB (4): = RPAD (EMPTAB (4), 101, ' ');
FORALL I IN EMPTAB. FIRST... EMPTAB. FINALLY SAVE THE EXCEPTIONS
INSERT INTO EMP_LOG (ENAME)
VALUES (EMPTAB (I));
COMMIT;
EXCEPTION MY_EXCEPTION THEN
BECAUSE me in 1... % BULK_EXCEPTIONS SQL. COUNTY
LOOP
DBMS_OUTPUT. Put_line ('Record' |) SQL % BULK_EXCEPTIONS (i) .error_index |' original mistake ' | I have |
': '|| SQL % BULK_EXCEPTIONS (i). ERROR_CODE | » '|| SQLERRM (-SQL % BULK_EXCEPTIONS (i).) ERROR_CODE));
END LOOP;
END;
--------------------------------------------------------------------------------------------------
Rgds,
PC
Published by: PC Sep 16, 2010 12:39 AM
Published by: PC Sep 16, 2010 12:44 AM1. it is always useful to include the error message you have met.
2. Please describe the tables EMP and EMP_LOG.
-
call another proc and passing the values in the exception block
Hello
I'm trying to call the procedure another passing values in the exception block... but I couldn't m figure out how would the values in the exception block
Thank you very much!!create or replace procedure test_proc is cursor test_cur is select update_dt from test_tbl; test_rec test_cur%rowtype; begin for test_rec in test_cur loop begin insert into test_tbl values (test_rec.update_dt); commit; exception when others then rollback; -- test_proc2(update_dt) -- want to call another procedure and want to pass that update_dt here ; this process will insert the update_dt into the message table commit; end loop; end; My question is how do i pass value(update_dt) into the exception block or do i need to create any varaible ?? any idea
BTW, you can still use SQL % BULK_EXCEPTIONS even if you don't use EXCEPTION to LOG. You just can't use ORA-24381, since it will not be raised. Using SO many OTHER instead. And of course, there will be only one element in SQL % BULK_EXCEPTIONS:
SQL> CREATE TABLE emp_temp AS SELECT * FROM emp; Table created. SQL> DECLARE 2 TYPE empno_tab IS TABLE OF emp.empno%TYPE; 3 emp_sr empno_tab; 4 errors NUMBER; 5 dml_errors EXCEPTION; 6 PRAGMA EXCEPTION_INIT(dml_errors, -24381); 7 BEGIN 8 SELECT empno BULK COLLECT INTO emp_sr FROM emp_temp; 9 FORALL i IN emp_sr.FIRST..emp_sr.LAST --SAVE EXCEPTIONS 10 UPDATE emp_temp SET job = job || '_SR' 11 WHERE emp_sr(i) = emp_temp.empno; 12 EXCEPTION 13 WHEN OTHERS THEN -- Now we figure out what failed and why. 14 errors := SQL%BULK_EXCEPTIONS.COUNT; 15 DBMS_OUTPUT.PUT_LINE('Number of statements that failed: ' || errors); 16 FOR i IN 1..errors LOOP 17 DBMS_OUTPUT.PUT_LINE('Error #' || i || ' occurred during '|| 18 'iteration #' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX); 19 DBMS_OUTPUT.PUT_LINE('Error message is ' || 20 SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE)); 21 END LOOP; 22 END; 23 / Number of statements that failed: 1 Error #1 occurred during iteration #2 Error message is ORA-12899: value too large for column "SCOTT"."EMP_TEMP"."JOB" (actual: 11, maximum: 9) PL/SQL procedure successfully completed. SQL> DROP TABLE emp_temp; Table dropped. SQL>
SY.
-
the use of collections, copy a record with children/grandchildren
I understand that loops FOR cursor are not as good as the use of collections, and now I need to convert some of my code accordingly.
I've been doing a bit of good to read the documentation and have not yet encountered examples of the situation that is so prolific in our system; namely, someone wants to make a copy of a record, with its outbuildings down a few levels.
Here's what looks like a typical of this instance (except that everything is in packages). Take the 3 tables: grandparent_table, parent_table and child_table, with primary keys being gp_id, p_id and c_id respectively (and related as one might guess these names):
create or replace procedure p_copy_record (p_gp_id in grandparent_table.gp_id%type)
is
cursor c_parent
is
Select *.
from parent_table
where gp_id = p_gp_id;
v_gp_id grandparent_table.gp_id%type;
v_parent_id parent_table.p_id%type;
Start
Select grandparent_seq.nextval
in v_gp_id
Double;
insert into grandparent_table
Select v_gp_id,
other_columns_here
of grandparent_table
where gp_id = p_gp_id;
for r_parent loop c_parent
Select parent_seq.nextval
in v_parent_id
Double;
insert into parent_table)
P_ID,
gp_id,
other_columns_again)
Select v_parent_id,
v_gp_id,
r_parent.other_columns_again;
insert into child_table)
C_ID,
P_ID,
other_columns3)
Select child_seq.nextval,
v_parent_id,
other_columns3
of child_table c,.
where parent_id = r_parent.parent_id;
end loop;
end;
/
I tried to change the code of this a few different ways, but running into errors. The main problem seems to be that the collections don't refer to an element, in order to make this join (where parent_id = r_parent.parent_id).
How you would replace the slider - for loops here (using 10 gr 2)?
Thank youTo replace the sliders, you will need to fill a table with the same data. Then process these tables
create or replace procedure p_copy_record (p_gp_id in grandparent_table.gp_id%type)
is
type gp_array is table of grandparent_table % roytype;
type p_array is the table of the parent_table % rowtype;l_gp gp_array;
l_p p_array;v_gp_id grandparent_table.gp_id%type;
v_parent_id parent_table.p_id%type;
Start
-get the next gp id
Select grandparent_seq.nextval
in v_gp_id
Double;
-bulk collect the current record of the gp - you don't really need but for pleasure it's im
Select * bulk collect into l_gp from grandparent_table where gp_id = p_gp_id;
-creation of a grandparent registration
insert into grandparent_table
values v_gp_id,
.name l_gp (1),
.other_columns_here l_gp (1);-Now bulk collect the parent records
Select * bulk collect into l_p Parent_table where gp_id = l_gp (1) .gp_id;FOR i IN 1.NVL(l_p.COUNT,0) LOOP
-get the next parent id
Select parent_seq.nextval in the double v_parent_id;
-create the parent record
insert into parent_table)
P_ID,
gp_id,
other_columns_again)
v_parent_id,
v_gp_id,
LP (i) .other_columns_again;-While we are here create the records for this parent child
insert into child_table)
C_ID,
P_ID,
other_columns3)
Select child_seq.nextval,
v_parent_id,
other_columns3
of child_table c,.
where parent_id = lp (i) .parent_id;
END LOOP;
END;To be honest, I'm not sure that you will really see a great improvement since you already limit the scope until the recording of one of the grandparents. Let's say the grandparent has 10 children each with 10 children who is just 111 records. As long as your tables are indexed by the node Id it should be fast just like that.
-
No exceptions of found data in bulk updates
I'm trying to catch any exception found data in bulk updates when it cannot find a record to update in the forall loop.
P & c OPENED.
LOOP
EXTRACTION casulaty
BULK COLLECT INTO v_cas, v_adj, v_nbr
LIMIT 10000;
FORALL i IN 1.v_cas.count
UPDATE tpl_casualty
Set casualty_amt = (select TN from tpl_adjustment where cas_adj = v_adj (i))
where cas_nbr = v_nbr (i);
EXCEPTION WHEN NO_DATA_FOUND THEN dbms_output.put_line ('exception')
I get this error at the line where I'm the exception:
PLS-00103: encountered the symbol "EXCEPTION" when expecting one of the following conditions:
begin case declare end exit for goto if loop mod null pragma
raise return select update while < ID >
< between double quote delimited identifiers of > < a variable binding > < <
Close current delete fetch locking insert open rollback
SAVEPOINT SQLExecute set pipe fusion commit forall
Can someone direct me pls on how to work around this problem?
If I do not handle the exception, the script fails when it tries to update a record that does not exist and the error says: no data available exception.
Thanks for your help.
Published by: user8848256 on November 13, 2009 18:15No data found is not an exception that is thrown when an UPDATE cannot find all files.
% ROWCOUNT SQL can be used to determine the number of rows affected by an update statement, but if 0 rows are updated, no exception will be thrown (it's just not how things work).
If you post your real return of CURSOR (injured), it is quite possible, that we can help you create a single SQL statement to meet your needs (a single SQL will be faster than your current implementation).
Have you looked at using the MERGE command?
Maybe you are looking for
-
Plugged in new iPhone 6 s and stupidly selected restore from backup instead of the new phone option and therefore lost a bunch of videos and photos taken today. No way to recover the files? Thank you very much...
-
new SL1, Q value always default key
SL1 body. When you press the key Set Q it still Image quality by default and does not allow me to manually change other parameters by using the arrows. I know that I can use the touch screen to do, but I have obviously been a Rebel T1i user for many
-
SE connect/disconnect Internet using a command prompt
original title: to connect/disconnect Internet Is it possible to disconnect & reconnect my internet connection of cable to a command line in Windows XP?
-
Re - install xp os leaving old registry entries
I had to reinstall xp home edition repeatedly and want to know how to clean the old entries registry of the operating system (?), or what? The OS (?) screen still shows 2 to choose at boot. I just let it start to the first option, but wonder if I hav
-
How to remove the old hard drive files. Can not defragment
Not enough space to defragment.