SQL & PL/SQL :: Error Handling Inside Cursor

Dec 31, 2012

I am writing a cursor and inside that cursor I am checking record exists or not and based on that I am doing my operation.But I am getting error that i can not use exception inside cursor see the below sample code (syntax may not be correct)

sample code------------------
cur c1
is select * from T1;
open c1
loop
fetch c1 into cur_id;

select name into var_name from t2 where id = cur_id;

exception
when no_data_found then
continue with next cursor value
end

update t3 set name = var_name where t3.id = cur_id;
commit;
end loop;
end;

View 6 Replies


ADVERTISEMENT

SQL & PL/SQL :: OPEN FOR Cursor Handling?

Jan 13, 2011

I have a snippet of code

EXCEPTION
WHEN OTHERS THEN
H_Report_Error('sql',Sqlerrm);
end;

And I'm trying to figure out how to catch a error from a loop such as:

OPEN My_cursor FOR SQLCODEBLOCK
LOOP
FETCH a_variable INTO ResultCount;
EXIT
WHEN My_cursor % NOTFOUND ;
BEGIN
--Stuff done
End;
End Loop;

So right now I have a error in the SQLCODEBLOCK, but I can't catch that error. I've tried putting the exception in various places but it wont compile.

View 6 Replies View Related

Loop Inside Cursor

Sep 11, 2012

I have a cursor returning some value.

for each value returned by the cursor i need to traverse through 31 rows(1 row per day * no of days in the month).

E.g. if cursor returns service_name as xyz then for xyz there can be 31 rows(service may not be used on some days)

I need to go to all of them and take some values and move them to a flat file. how should that be done?

Attached File(s)
Query.png ( 20.99K )
Number of downloads: 9

View 1 Replies View Related

SQL & PL/SQL :: Calling APIs Inside Cursor

Jun 17, 2011

im calling an api inside a cursor.. for the first loop in a cursor , the api works well. however, for the rest of the loops the api doesn't give any error, but it doesn't insert any row to the table.

if i called the same api for every single value in a cursor seperately the api would insert all rows.

View 1 Replies View Related

SQL & PL/SQL :: Cursor Declaration Inside Block?

Jun 30, 2011

I can't understand the following cursor declaration (inside the DECLARE of a PL/SQL block)

CURSOR c_emps IS
SELECT emp_large_ot(empno, ename, job, mgr,hiredate, sal, comm, deptno) FROM emp_large;
emp_large_ot is an object type created as
CREATE TYPE emp_large_ot AS OBJECT
( empno NUMBER
, ename VARCHAR2(10)
, job VARCHAR2(9)

[code]...

and emp_large is similar to the standard emp table

View 3 Replies View Related

SQL & PL/SQL :: Cursor With Parameter Inside Function

Mar 7, 2010

I have code inside function
.....
cursor cur1 is
select *
from sarchkler
where sarchkler_appl_no = in_appl_no
begin
select max(saradap_appl_no) into in_appl_no from saradap;
for rec1 in cur1 loop
......
my question I get variable for cursor after cursor declaration

View 7 Replies View Related

SQL & PL/SQL :: Cursor In DML Statement Inside A Procedure

Sep 12, 2011

I have a DML Statement inside a procedure and i use a cursor variable to get the values checked as below . I have attached my procedure not completely but the declaration part and the DML statement part.

The issue is my procedure is not inserting the records at all. It selects the values and then inserts accoringly but its not selecting because of the cursor reference R_LOC.LOCATION_GID.

when i hard code the value in the DML statemnt for the R_LOC.LOCATION_GID, the rows are inserted as expected. So i guess the way the procedure executes the value is not correct.

Modifying my select part which uses cursor variable R_LOC.LOCATION_GID under Insert statement.

select d.servprov_gid, d.depot_gid, replace(d.appointment_time,'':'') appmt_time, d.'||v_day_to_use||' DayUsed
from tesco_fresh_templates t, tesco_fresh_templates_d d, location_refnum r
where t.set_id= d.set_id
and d.depot_gid=r.location_gid
AND D.SERVPROV_GID=''R_LOC.LOCATION_GID''
and r.location_refnum_qual_gid=''TESCO.IVS SCHEDULING''
and (r.location_refnum_value=''YES'' or r.location_refnum_value=''Y'')
and t.default_set=''Y''

View 21 Replies View Related

SQL & PL/SQL :: Using Function Inside Query And Without Cursor?

Mar 17, 2013

To display highest marks,least marks,average marks,total marks of the student name entered.

desc stud;
Name Null? Type
----------------------------------------- -------- ----------------------------
SID NUMBER
NAME VARCHAR2(20)
M1 NUMBER
M2 NUMBER

How do I do that using PL/SQL and without Cursor.

View 4 Replies View Related

Reports & Discoverer :: Error Messages Handling In Report

Jan 18, 2011

I am generating a report with parameter form.

I do not want users to leave a parameter value null . so I applied after parameter form trigger

function AfterPForm return boolean is
begin
IF ( :my_no IS NULL ) THEN
srw.message(101, 'Please enter proper No.');
return (FALSE);
END IF;
return (TRUE);
end;

it is working fine, it displays proper message but after my message, a default message is displayed

REP-0771: After Form Trigger Failed.

I want to avoid this message. if i comment out return(false) then it displays message and runs the report. I want to avoid default oracle message and stop running report also.

View 7 Replies View Related

SQL & PL/SQL :: Error While Using Cursor

Apr 10, 2013

My task has more lines of code,so i tried to present here only few lines of code where i am getting the error.The following cursor needs to select data from two tables with some conditions that are included in cursor and place those in other table.I used BULK collect.

CURSOR c_arch_trk (p_run_date DATE,
p_nbr_days_arch1 NUMBER,
p_nbr_days_arch2 NUMBER )
IS
SELECT a.SIS_PGM_START_DATE,a.SIS_PGM_END_DATE,a.PGM_MSTR_NBR,a.PGM_TRK_NBR,a.CNTL_LOCN,a.CMPNY_VNDR_NBR,a.AGRMNT_MSTR_NBR,
a.SLS_CONT_NBR,b.PGM_NAME,b.PGM_BASIS,b.AGRMNT_CNTL_LOCN
[code]....

View 3 Replies View Related

SQL & PL/SQL :: Invalid Cursor Error In Procedure

Feb 2, 2011

I have this stored procedure as part of package.

PROCEDURE XCOM_X060_UPDATEOHBFAILURE( in_CALL_ID IN NUMBER,
in_SPLY_REORD_NO IN CHAR,
in_OHB_QTY_CARTONS IN NUMBER,
in_OHB_QTY_UNITS IN NUMBER,
in_SPLY_TOT_OHB_QTY IN NUMBER,
in_OHB_INPUT_CTNS_MIN IN NUMBER,
in_OHB_INPUT_CTNS_MAX IN NUMBER,
in_UNITS_PER_CARTON IN NUMBER,
in_OHB_INPUT_UNIT_CONSTANT IN NUMBER,
in_TOTAL_CARTONS IN NUMBER,
out_ALLOW_OHB_INPUT_FLAG OUT CHAR,
out_ERR_CODE OUT NUMBER,
out_ERR_MESSAGE OUT VARCHAR2)

When the stored procedure is executed it is throwing following exception OTHERS EXCEPTION in XCOM_X060_UPDATEOHBFAILURE - SQL -1001 SQLERRM: ORA-01001: invalid cursor

Here is the execution script
DECLARE
IN_CALL_ID NUMBER;
IN_SPLY_REORD_NO VARCHAR2(32767);
IN_OHB_QTY_CARTONS NUMBER;
IN_OHB_QTY_UNITS NUMBER;
IN_SPLY_TOT_OHB_QTY NUMBER;
IN_OHB_INPUT_CTNS_MIN NUMBER;
[code]...

There is no cursor used in the procedure. It just inserts records in the table for given input values.

View 10 Replies View Related

PL/SQL :: How To Clear Runtime Error In Ref Cursor

May 27, 2013

the code as follows

create or replace
procedure Country_sel(key in varchar2)
as
cc Res_RelcountryLan.countrycode%type;
len Res_Language.langname_en%type;
lid Res_Language.langid%type;
ab Res_Language.Abrivation%type;

[code]....

when i am running this code im getting

ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "RASOOL.COUNTRY_SEL", line 11
ORA-06512: at line 6

View 2 Replies View Related

PL/SQL :: Error Displaying As Cursor Is Hanged?

May 1, 2013

create or replace procedure upd(name in varchar2) is
cnumber number;
cursor c1(name in varchar2) is select sid from student where sname=name;
begin
open c1(name);

[code]....

it has no errors . .. . but when i try to execute it is displaying as cursor hanged . . .

View 5 Replies View Related

PL/SQL :: Getting Error - ORA-06511 - Cursor Already Open?

Jul 27, 2012

I have the following code for a Apex(Application Express) project I am developing.

declare
mail_id varchar2(100);
min_skill_cnt number;
skill_cde varchar2(30);
total_leave number;
toal_emp number;

cursor cur is
select S_EMP_EMAIL
from EMP_SKILLS_INFO where SKILLCODE='MGR' and S_EMP_EMAIL = lower(:APP_USER) ;

cursor minskill is
select skill_code,MINRQMT_AM
from skills_code_info
where skill_code in (select skillcode from emp_skills_info where S_EMP_EMAIL = lower(:APP_USER));

cursor leavecnt(v_skill IN VARCHAR2) is
select count(*) from emp_leave_info
where leave_date = :P24_LEAVE_DATE
and emp_email IN (select S_EMP_EMAIL from EMP_SKILLS_INFO where SKILLCODE = v_skill);
cursor empcnt(v_skills IN VARCHAR2) is

[code]...

Ideally this should send email to managers when a particular skill is running short when employee applies for leave. I am getting error that cursor is already open when I run this code. I am not sure which cursor or where it is picking open cursor command.

View 2 Replies View Related

PL/SQL :: Cursor Went To Exception When It Got Error / No Data Found

Jul 7, 2012

My cursor went to the exception when its got the error " ORA-01403: no data found"

But my cursor need to run even though it got the error " ORA-01403: no data found"...This is my exception part

EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (c1rec);
DBMS_OUTPUT.put_line (SQLCODE);
DBMS_OUTPUT.put_line (SQLERRM);
--  RETURN NULL;
-- code change added as part of GCA642 -- END
END get_geo_test1;

View 14 Replies View Related

SQL & PL/SQL :: Very Long Query With Ref Cursor - Buffer Too Small Error

Jun 21, 2011

I want to pass a damn long query(which includes a lot of column names, tables, joins, union, where clauses etc. and whose length is more than 120000) in a Ref cursor (that's length is more than 32767). Query is stored in a LONG type variable V_QRY in stored procedure, and I am opening that ref cursor like below-

OPEN P_RPT_TEST FOR V_QRY;

at run time its giveing string buffer too small error.

View 7 Replies View Related

SQL & PL/SQL :: Error In Reading Data From Collection Variable For Ref Cursor

Jun 19, 2013

While reading data from collection variable using ref cursor . I am getting the below two errors.

PLS-00382:Expression is of wrong type
ORA-22905 Cannot access rows from a non-nested table item.

CREATE OR REPLACE PACKAGE APPS_GLOBAL.GIIOMEGAORDERLIST
AS
TYPE BU_LIST_TYPE IS TABLE OF VARCHAR(50);
TYPE OFFER_DETAIL IS RECORD
(
GII_BU VARCHAR(50),
GII_OFFER NUMBER,
[code]........

View 4 Replies View Related

SQL & PL/SQL :: Exception Handling?

Jul 16, 2012

Is it possible to take execution control back from exception handling section to Execution statement?.. If Yes then How?..

View 25 Replies View Related

Handling NULL Value In XML Using GetStringVal?

Dec 13, 2012

I have below query which works fine if column 'XML_COL' has values. This select statement fails if the value is NULL for

select xmltype(t.xml_col).extract('//fax/text()').getStringVal() from mytab t

How to handle rows with NULL values in the column 'XML_COL'.

View 3 Replies View Related

Handling NULL Values?

Jan 23, 2013

I have 2 tables, AFF_TEMP and COUNTY
AFF_TEMP has the following columns FNAME, LNAME, EMAIL and COUNTY
COUNTY has 2 columns COUNTY_ID and CNAME

Both tables have the following test data
AFF_TEMP
Joe, Bloggs, joe@gmail.com, ''
Ann, Bloggs, anne@gmail.com,Donegal

and COUNTY column in AFF_TEMP can contain a NULL value

County table has the following Test data,
1, Dublin
2, Donegal
3, Tipperary,
4, Galway

I am trying to select the following from both tables FNAME, LNAME, EMAIL, COUNTY_ID.Tried the following queries
select a.FNAME, a.LNAME,a.EMAIL, C.COUNTY_ID FROM temp_aff A LEFT OUTER JOIN COUNTY C ON A.COUNTY=C.CNAME
OR (A.COUNTY IS NULL)
select a.FNAME, a.LNAME,a.EMAIL, C.COUNTY_ID FROM temp_aff A, COUNTY C
WHERE C.CNAME IN (SELECT UPPER(A.COUNTY) FROM TEMP_AFF A)

[code]...

View 3 Replies View Related

PL/SQL :: Exception Handling In Procedures

Oct 8, 2012

I am using for writing text files data to database. The problem here is let us assume there are 6 records in text file and if there is a problem at 2nd record, the later records are not getting inserted.

CREATE OR REPLACE PROCEDURE PROC1
IS
temp varchar2(500);
tmp_name varchar2(5);
tmp_no varchar2(4);
.
BEGIN
WHILE NOT end_of_file
LOOP

IF i = 18 THEN
tmp_no := temp;
END IF;

IF i = 21 THEN
tmp_name := temp;
END IF;

END LOOP;
END;
/If i=18 and temp = '12345' here, then tmp_no := temp; won't work (tmp_no varchar2(4);)
Similarly, If i=21 and temp = 'ABCDEFG' here, then tmp_name := temp; won't work (tmp_name varchar2(5));

how to handle this through EXCEPTIONS so that even if there is a problem with 1 record, while loop remain working for further records..

View 4 Replies View Related

Flexible Handling Of Duplicates Using A Trigger

Feb 12, 2007

I'd like to achieve the following (and YES, I do know that this is not multi-user safe, but that's not the point here):

Before inserting a record, the trigger shall check if there's already a duplicate one. Duplicate means in this case when there is an intersection of the time frame, defined by two numeric timestamps. That's also the cause why I cannot use a simple UNIQUE constraint here (in my opinion).

Okay, that already works (see code below). But now I need colliding records to be written to a temporary table so that those records can be returned and presented to the user for selection.

create or replace
TRIGGER TRIGGER1
BEFORE INSERT ON FLIGHT_TABLE
FOR EACH ROW
BEGIN
FOR fs_entry IN (SELECT * FROM FLIGHT_TABLE)
LOOP

[Code] .........

View 1 Replies View Related

SQL & PL/SQL :: Exception Handling In A Created Function

Dec 8, 2010

Basically I've created a function, when I run it there is a user input. Mine is a customer number between 1-10.

I was wondering is there a way to add in error check so if I typed in an invalid number it would give me a message saying "Wrong customer_number" or something along the lines of that?

I was told I wasn't able to use "DBMS_OUTPUT.PUT_LINE" in the function I need to tamper with the function header?

Here is my header -

CREATE OR REPLACE FUNCTION hours (custid customer.cust_id%TYPE)

RETURN NUMBER IS

multiply NUMBER;
returnanswer NUMBER;

View 2 Replies View Related

SQL & PL/SQL :: Handling Exceptions Without Halting Execution

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

SQL & PL/SQL :: Oracle Trigger Exception Handling

Jun 12, 2012

I am writing a after trigger for one of my tables on every insert update and delete for my dataware house staging area. The process here is when ever there is a change in the production database we need to capture this change in our changing area through triggers.

I am able to create the triggers but i am stuck with the exception handling portion of the trigger. I want to write an exception in the trigger where when the staging area is locked or for any other matter the data needs to be able to go to a error table when the staging area is not able to accept the data for some reason.

how i can write this excepyion in the trigger or anyother method i can follow to be able to handle this scenerio.

View 2 Replies View Related

SQL & PL/SQL :: Handling Exceptions In Bulk Collect

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

SQL & PL/SQL :: Handling No Of Rows Selected In Loops?

Feb 25, 2012

I'm attempting to write a plsql for finding missing archived logs for streams.

requirement is to run a select statement and print
1. 'NOT FOUND' if name column is null
2. '<name of the files>' if rows are returned
3. 'NOT FOUND' if no rows are selected. (here is were i'm having trouble)

code i developed so for:
for cr in (select decode(name, NULL, 'NOT FOUND', name) from v$archived_log where deleted='YES'
and status!='A')
loop
if (cr.name = 'NOT FOUND')

[code]...

View 6 Replies View Related

XML DB :: Handling Multiple Namespace In XML While Using Table

Feb 7, 2013

I have the following data stored as a CLOB in my table

<financialTransaction xmlns="http://lombardrisk.com/reform/dfa/2012/02" xmlns:cfpml="http://www.fpml.org/FpML-5/reform/2012/02" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lombardrisk.com/reform/dfa/2012/02 StandardisedTransactionInterface.xsd ">
<header>
[code]........                                 
               
I am trying to convert this into a relational DB view.

--CREATE OR REPLACE VIEW V_TRADES AS
SELECT
x.*
FROM ENGINE_ENTITIES,
XMLTABLE(xmlnamespaces('http://lombardrisk.com/reform/dfa/2012/02' as "n1",
'http://www.fpml.org/FpML-5/reform/2012/02' as "n2",
'http://www.matchingservice.com/coding-scheme/messageId' as "n3",
'http://www.matchingservice.com/partyId' as "n4",
[code].......  

I have multiple namespaces used in that CLOB. how to use it in the x Query?

View 3 Replies View Related

Globalization :: Handling Multibyte Characters

Aug 8, 2013

I have created a procedure which sends e-mail using UTL_SMTP. The procedure has a part in which we add the attachments to e-mail. Now , the issue is when i am adding an attachment which contains multibyte characters , these characters are replaced with '?'.

View 6 Replies View Related

PL/SQL :: Exception Handling In Insert Statement

Jul 17, 2012

Here's sample code :

declare
i number;
l_rec number;
cursor c1 is select i from t1;
begin
[code]....

After executing Data must be inserted into t2..If any error is there it should insert into t2 with status 'E' and move on T2

i fflag
---------
11 E
111 Y
1111 Y

The code above is failing after inserting 11 E into t2 table

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved