SQL & PL/SQL :: How To Handle Multiple Exceptions
Apr 11, 2012
I am having a pl/sql code with two blocks namely one inner block and outer block
declare
v_v1 varchar2(10);
v_v2 varchar2(10);
v_v3 varchar2(10);
[Code].....
from the above code I want to execute both the inner block exception and outer block exception and is there any way to pl/sql engine that execute the outer exception first and inner next
View 7 Replies
ADVERTISEMENT
Jul 20, 2012
I want to do something like this
-------------------------------------------------------------------------------------------------------
While Condition
LOOP
BEGIN
Insert into table1 values(......);
[Code]...
EXCEPTION
When OTHERS THEN <capture the error while inserting into an Error table>
END;
END LOOP;
-------------------------------------------------------------------------------------------------------
Now I want that If one of the insert statement within the loop fails (say table2) the exception should be captured and next insert statement (table3) should be executed.
How can I do this ? I guess I wont even need a loop
View 10 Replies
View Related
Jul 14, 2010
java.sql.SQLException: Unexpected exception while enlisting XAConnection java.sql.SQLException: XA error: XAResource.XAER_RMERR start() failed on resource 'weblogic.jdbc.jta.DataSource': XAER_RMERR : A resource manager error has occured in the transaction branch
javax.transaction.xa.XAException: Unexpected error during start for XAResource 'EOD': null
at weblogic.jdbc.wrapper.XA.createException(XA.java:103)
at weblogic.jdbc.jta.DataSource.start(DataSource.java:765)
at weblogic.transaction.internal.XAServerResourceInfo.start(XAServerResourceInfo.java:1182)
at weblogic.transaction.internal.XAServerResourceInfo.xaStart(XAServerResourceInfo.java:1115)
View 3 Replies
View Related
Sep 14, 2010
I have a set of 500 insert queries which i need to execute. I have included exception handler to catch any errors encountered. I don't want the execution to halt when an exception is encountered, i want the next insert statement to be executed
I am pasting the sample code below
DECLARE
error_code NUMBER := SQLCODE;
error_msg VARCHAR2 (300) := SQLERRM;
BEGIN
INSERT statement 1
INSERT statement 2.....
....................
INSERT statement 500.....
commit;
EXCEPTION WHEN OTHERS THEN
IF (SQLCODE != 0) THEN
DBMS_OUTPUT.put_line(SQLERRM);
END IF;
END;
For example if insert statement 100 fails the exception should be caught and execution should pass to 101 statement.
View 13 Replies
View Related
Aug 17, 2012
For the following procedure if I send the existed employee number of emp table as input. The procedure is executing successfully. But if I send the employee number as input which does not exist in the emp table . The execution block does not handling the exception.
I am getting the following error.
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "RAKULA.SP_TEST_EXCEPTION_BULK", line 8
ORA-06512: at line 7
If I use WHEN OTHERS exception then I am able to handle that exception. Why it's happening like this.
CREATE OR REPLACE PROCEDURE RAKULA.sp_test_exception_bulk(i_empno NUMBER)
IS
t type_test1;
BEGIN
SELECT deptno BULK COLLECT INTO t
FROM emp
WHERE empno=i_empno;
[code].......
how to handle that exception.
If I create the procedure without using
BULK COLLECT then I am able to handle that exception using WHEN NO_DATA_FOUND
In the following procedure I am able to handle the exception.
CREATE OR REPLACE PROCEDURE RAKULA.sp_test_exception(i_empno NUMBER,v_dept_no OUT NUMBER)
IS
BEGIN
SELECT deptno INTO v_dept_no FROM emp
WHERE empno=i_empno;
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('employee number' ||i_empno|| 'does not exist');
END sp_test_exception;
/
View 2 Replies
View Related
Aug 14, 2009
Is it possible to insert a table in case of exceptions. For example, i have a function like this:
Create or replace Function test_function(p_Parameter_ID number) Return number is
l_Variable number;
Begin
Select output into l_Variable from test_table where id=p_Parameter_ID;
Exception when others then
Insert into exception_Table values('No Data Found', p_Parameter_ID);
return l_Variable;
End test_function;
In this function, if you notice, i wanted to populate an exception table for further analysis in case data is not found. The function gets compiled without any error in this case.However when i execute this and the Select query does not return any output for a particular parameter_ID, then the exception part fails. It gives me an error "cannot perform a DML operation inside a query".
Can't i write insert statements inside the exception section?
View 39 Replies
View Related
Feb 17, 2012
Why exceptions does not raise in cursors declared by user like in the following program
create or replace function sal (p_id employees.department_id%Type) return number is
----sal1 employees.salary%type:=0;
cursor cx is
select * from employees where department_id=p_id;
begin
for i in cx
[code]...
View 13 Replies
View Related
Sep 20, 2013
how to put exceptions while defining the summary item ? In one of my datablock there are certain lines whose "inactive_flag" gets a "Y" value on certain events. I want my summary item to exclude such amounts from summing up.
View 3 Replies
View Related
Aug 23, 2011
I have a PL SQL program block as shown below,
create or replace
procedure except_handle
is
v_errorcode VARCHAR2(10);
v_errormsg varchar2(200);
constr_violation Exception;
PRAGMA Exception_Init(constr_violation,-2292);
[code]..........
Here, I have assigned values to the variables 'v_errorcode' and 'v_errormsg' directly inside the exception block so that I can use them in both exception types 'constr_violation' and 'others'. I am getting an error message like,
Error(22,1): PLS-00103: Encountered the symbol "V_ERRORCODE" when expecting one of the following: pragma when
View 6 Replies
View Related
Sep 7, 2012
how to define user defined exceptions for cases like, ==> when anyone tries to insert string values without using single quotation marks " '...' "? ==> update the column which is not present in table.
how can I define user defined exceptions for such cases?
View 3 Replies
View Related
Jan 29, 2013
Is there a save exceptions clause or an equivalent for an Insert as select* statement ?
How do I trap the errors in the below statement -
INSERT INTO copy_emp
SELECT * FROM emp;
Is it an all or nothing scenario ?
View 10 Replies
View Related
Mar 24, 2008
I have a stored procedure that does a "select name into v_name" SQL statement, which works fine. The only problem is when the query finds no data (the procedure will error because there is no value to put into the variable). Now i have a work around to this by running the query first with a count statement (which will always have results) and then if it is not equal to 0, then i will run the select into.
My question is, is there a better way to handle this kind of issue?
View 1 Replies
View Related
May 19, 2011
The following code is working fine,But the thing is if column already exists in the table,then also the other statements should be executed instead of coming out of procedure.SO how can I handle that exception??
SQL> CREATE OR REPLACE PROCEDURE sp_execparameters(tname IN VARCHAR2,
colname IN VARCHAR2,datatype IN VARCHAR2)
2 AS
3 v_sqlstr1 VARCHAR2(1000);
4 BEGIN
5 v_sqlstr1 := 'alter table '||tname||' add '||colname ||' '|| datatype ;
[code].........
View 3 Replies
View Related
Oct 6, 2013
we are using oracle database. We hold the company records in the database. The records of the company should be available at anytime but over years the database keeps growing. Now how to handle the old data. All the data is important but if this goes for few more years then we need more and more disk space to handle. Is there any efficient methodologies to handle the old data? For us old mean the data that is 10 year old.
View 9 Replies
View Related
Mar 11, 2013
I Got a scnario like a upload file contains
1.Header(Contains the File Name,Branch Name,MIS date)
2.Body(Customer Details)
3.Footer (File Name,Contians Total Number of Records and Number of Customers)
Like
CustomerDet_11-12-2013.csv,Chennai,11-12-2013
101,AAA,Savings,'M',10000
102,BBB,Current,'O',2000
103,CCC,Deposit Acct,'F',3000
CustomerDet_11-12-2013.csv,3,15000
How to handle this scnario through UTL_File
View 31 Replies
View Related
Jul 7, 2010
I handle newly the Tlist. I have Tlist Which is generated on runtime by the following code
Declare
cursor C1 is select 'A' col
from table
union
select 'B' col
[code]......
The list have 3 element now. But when i try get the element count in tlist using Get_list_element_count. i am not getting anything.
View 1 Replies
View Related
Feb 9, 2010
The following code works fine in the form 6i, but in the same form 10g I get map_handle='0' and win_handle='0' instead of certain value as in 6i.
map_handle:=get_item_property('MAP.MAP_ITEM',WINDOW_HANDLE);
win_handle:=get_window_property('CG$WINDOW_1',WINDOW_HANDLE);
MAP.MAP_ITEM has Chart Item type.
View 3 Replies
View Related
Nov 17, 2011
I trying to Assign XML content to the clob variable inside the pl/sql block, But i am getting the Below Error:
declare
t clob;
begin
t := 'xml content exceeds 32000 characters'
update test
clob_cloumn = t;
where id =2;
exception
when others then
null;
End;
ORA-06550: line 5, column 4:
PLS-00172: string literal too long
I need to handle this exception, i know it length exceeds 32000 characters, but even though i need to handle the exception and to perform other operation after handling the exception.
View 5 Replies
View Related
Oct 22, 2012
I'm working on a plsql program and i'm using collections. I loop the collection and delete rows of it depending on the edits of my program. Here is the question.
if my collection holds
rows
[1]value
[2]value
[3]value
i can simply do something like FOR indx in invoice.first..invoice.lasthowever if i delete row 2 of my collection i get an error. no data found.
ive been researching this site
[URL].......
rows
[1]value
[3]value
[4]value
is there a way to tell plsql i just want it to loop the collection from top to bottom regardless of the index values?
View 2 Replies
View Related
Oct 1, 2012
My OTN account handle shows the number but till yesterday it was showing the Alias Name "ranit B".
Handle: 912545
Email:
Status Level: Newbie (20)
Registered: Feb 6, 2012
[code]...
View 13 Replies
View Related
Feb 5, 2013
I've set up Oracle Streams replication between multiple N-way zones like this:
CODE------------------------------
Nway1 |Intersect| Nway2
DB1 --|-- DB3 --|-- DB5 DB1, DB2, DB3, DB4 - N-way1
| | | | | DB3, DB4, DB5, DB6 - N-way2
DB2 --|-- DB4 --|-- DB6 DB3, DB4 - intersection zone
| |
-------------------------------
Physically DB1 .... DBN connected sequentially, so I want to prevent segmentation if some DB is unaccessible, but at the same time fight unneeded redundancy which uses too much link bandwidth to send N-1 LCR-s to all members of a single N-way group (so I want to split one big N-way zone into smaller ones and sequentially connect them into chain - it significantly reduces load on link if N is big enough (>10)). Also I want to have 2 DB in intersection zone to prevent single point of failure.
This scheme has one drawback - if change originated on DB3 or DB4, then it will be propagated (more correctly - applied and captured again) to DB5 and DB6 by both DB1 and DB2 (and, as far as I know, I have no means in capture rules to detect state of DB2 from DB1 and vise versa), so on DB5 and DB6 I get:
CODEORA-00001: unique constraint (DUMMYUSR.UNIQUE_RECORDS) violated error
I've set up standard conflict handler for apply process:
CODE
declare
cols DBMS_UTILITY.NAME_ARRAY;
begin
cols(1) := 'no';
cols(2) := 'name';
cols(3) := 'ddate';
dbms_apply_adm.set_update_conflict_handler(
object_name => 'DUMMYUSR.DUMMYTBL',
method_name => 'DISCARD',
resolution_column => 'no',
column_list => cols
);
end;
but it seems that it does not handle uniqueness conflicts. What is the best way to handle uniqueness conflict (is there a better way than to write custom error handler) and how serious is the impact on insert performance of having unique constraint and corresponding error handler. (In real world I will have to deal with tables with metainformation and without any keys).
Also, how to proceed with no error or raise exception from apply error handler with error that caused this handler to run? In oracle docs I can find only example that modifies LCR and runs lcr.EXECUTE(TRUE), but what to do if I don't want to reexecute LCR, but merely check error code and propagate error if it is not ORA-00001?
View 1 Replies
View Related
Apr 17, 2013
I created a custom type what it has a clob member variable:
CREATE TYPE custom_type AS OBJECT(
c_type INTEGER,
c_number NUMBER(38, 8),
c_varchar2 VARCHAR2(4000 CHAR),
c_clob CLOB,
[code]........
The inserting and updating works with constructor: ... custom_type (to_clob('foo')) . But if the data is longest than 4000 characters then the PHP isn't access to it.
So:
The normal case:
$sql = ("INSERT INTO table ( clob_field ) VALUES ( EMPTY_CLOB() ) RETURNING clob_field INTO :clob");
$stid = oci_parse($conn, $sql);
$clobdescr = oci_new_descriptor($conn, OCI_DTYPE_LOB);
oci_bind_by_name($stid, ':clob', $clobdescr, -1, OCI_B_CLOB);
oci_execute($stid);
$clobdescr->save('more than 4000 chars');
...
This case:
I tried:
$sql = ("INSERT INTO table ( ctype ) VALUES ( custom_type(EMPTY_CLOB()) ) RETURNING ctype.c_clob INTO :clob");
$stid = oci_parse($conn, $sql);
$clobdescr = oci_new_descriptor($conn, OCI_DTYPE_LOB);
oci_bind_by_name($stid, ':clob', $clobdescr, -1, OCI_B_CLOB);
oci_execute($stid);
$clobdescr->save('more than 4000 chars');
ORA says: "ORA-00904: CTYPE.C_CLOB: invalid identifier";
How to?Or how to access with any solution?
View 2 Replies
View Related
Apr 10, 2009
How do I handle spaces in the path name of a file with PL/SQL? This is what I am trying to do.
start f:folder namefolder name with spacesfoldernamescript.sql
I keep getting an error:
"The file 'f:folder.sql' does not exist."
Is there a special character I need to put in there for the spaces? How can I get this to work?
View 3 Replies
View Related
Jan 13, 2013
create table top22 (timed timestamp);
insert into top22(timed)
values (current timestamp),(null);
select timed from top22;
2013-01-14 10:50:22.17
NULL
select 'no is '||coalesce("num",'') from "bifrost"."top22"
getting error in DB2
if i remove this coalesce function
select 'no is '||timed from "bifrost"."top22"
no is 2013-01-14 10:50:22.17
NULL
but i need the second result is no is null
View 9 Replies
View Related
Feb 27, 2013
In my code i am selecting a column which does not exist for a table so i m trying to handle that error in exception handler but i am getting error
I want to handle ORA-00904 invalid identifier error
DECLARE
l_count INTEGER:=0;
invalid_identifier_exception EXCEPTION;
PRAGMA EXCEPTION_INIT (invalid_identifier_exception, -06550);
invalid_identifier_exception1 EXCEPTION;
[code]......
select sdsd from emp;
*
ERROR at line 14:
ORA-06550: line 14, column 8:
PL/SQL: ORA-00904: "SDSD": invalid identifier
ORA-06550: line 14, column 1:
PL/SQL: SQL Statement ignored
View 3 Replies
View Related
Aug 24, 2012
I am trying to execute the below package. While executing i face a problem where when NO DATA FOUND the excpetion is handled and coming out of the loop.but i want to to continue the loop after handling the exception.
Is there anyway i can modify the code
CREATE OR replace PACKAGE BODY pkg_purge_archive_check
AS
PROCEDURE Purge_archive_tables_check (purgerows IN NUMBER)
IS
v_num_1 NUMBER(10);
v_num_2 NUMBER(10);
v_multiplier NUMBER(10);
[code].....
View 15 Replies
View Related
Sep 5, 2012
I am trying to handle PK violation error on a certain table, on INSERT, my best guess is I should use a trigger. The basic idea is this:
The table consists of 7 columns, and 6 of them are PK, and the seventh one is "amount". I want to handle PK violation in such way that, if it occurs during INSERT, then instead of inserting a new row, it should just update the "amount".
View 16 Replies
View Related
May 8, 2013
i have some form and reports, whenever i call report from forms i got rep-300 OCI invalid_handle_error.
View 8 Replies
View Related
Dec 16, 2011
declare
type osd_refone is ref cursor;
osd_ref osd_refone;
l_status number;
[code]......
abc_reports in this pack "ab_report" it is the function it having the ref cursor as out parameter . when am executing the above anonymous block am getting the below error,so how can i print the out ref cursor data in my block.
ERROR at line 8:
ORA-06550: line 8, column 12:
PLS-00221: 'OSD_REF' is not a procedure or is undefined
ORA-06550: line 8, column 3:
PL/SQL: Statement ignored
View 6 Replies
View Related
Jun 14, 2011
create table myex(qid number, lid number, myname varchar2(20), status varchar2(30));
insert into myex values(1,1,'uu',null);
commit;
CREATE OR REPLACE PACKAGE mypack
IS
PROCEDURE p_get (in_qid myex.qid%TYPE, out_mycur OUT SYS_REFCURSOR);
end mypack;
/
[code].....
Note the one record in the table does not satisfy the cursor query criteria, So I try to pass in 1 to see what happens.
In sqlplus:
var out_mycur refcursor;
begin
mypack.p_get(1,:out_mycur);
end;
/
print out_mycur;
ORA-24338: statement handle not executed
View 5 Replies
View Related