UME commit exception
have written web dynpro program that uses UME to create users, but get strange exception when code gets to
iUserAccount.commit() so i cannot create the account
is there anything special about using UME in web dynpro i may have overlooked, like a required jar file or something like that
Venkat Venkataramanan wrote:
Hello:
I had posted earlier a message about an exception I get using Weblogic's Oracle JDBC driver.
When I tried to run through the getting_started_with_controls, I tried using an oracle Database.
When I clicked on the option to create a table, I got the following exception:
Exception in createTable
java.sql.SQLException: [BEA][Oracle JDBC Driver][Oracle]ORA-02089: COMMIT is not allowed in a subordinate session
Can somebody suggest how I can resolve this issue? Thanks.
VenkiHi Venki. Something simple is wrong here... Could you please open a
support case for this? thanks,
Joe
Similar Messages
-
Delete Statement Exception Handling
Hi guys,
I have a problem in my procedure. There are 3 parameters that I am passing into the procedure. I am matching these parameters to those in the table to delete one record at a time.
For example if I would like to delete the record with the values ('900682',3,'29-JUL-2008') as parameters, it deletes the record from the table but then again when I execute it with the same parameters it should show me an error message but it again says 'Deleted the Transcript Request.....' 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('Deleted the Transcript Request Seq No (' || p_shttran_seq_no || ') of the Student (' || p_shttran_id ||') for the requested date of (' || p_shttran_request_date ||')');
COMMIT;
EXCEPTION WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('Error: The supplied Notre Dame Student ID = (' || p_shttran_id ||
'), Transcript Request No = (' || p_shttran_seq_no || '), Request Date = (' || p_shttran_request_date || ') was not found.');
END p_delete_szptpsr_1;
Should I have a SELECT statement to use NO_DATA_FOUND ???A DELETE statement that deletes no rows (just like an UPDATE statement that updates no rows) is not an error to Oracle. Oracle won't throw any exception.
If you want your code to throw an exception, you'll need to write that logic. You could throw a NO_DATA_FOUND exception yourself, i.e.
IF( SQL%ROWCOUNT = 0 )
THEN
RAISE no_data_found;
END IF;If you are just going to catch the exception, though, you could just embed whatever code you would use to handle the exception in your IF statement, i.e.
IF( SQL%ROWCOUNT = 0 )
THEN
<<do something about the exception>>
END IF;In your original code, your exception handler is just a DBMS_OUTPUT statement. That is incredibly dangerous in real production code. You are relying on the fact that the client has enabled output, that the client has allocated a large enough buffer, that the user is going to see the message, and that the procedure will never be called from any piece of code that would ever care if it succeeded or failed. There are vanishingly few situations where those are safe things to rely on.
Justin -
No Data Found: Exception in SQL inside PL/SQL block
Hi Friends
I am trying to execute an SQL SELECT stmt inside a PL/SQL block. But when i execute the procedure, it gives me No Data Found Exception.
I know it is because no row is fetched in the query, but the condition of the SELECT query i have specified is being satisfied, i have checked it by running it on the SQL prompt.
But somehow, it is not running from inside the PL/SQL procedure.Can anybody help me out on this as to why is this happening?? I am giving my code for reference and have Highlighted the Query inside it:
CREATE OR REPLACE procedure insert_sfdc_account
as
--DECLARE
CURSOR C1 IS
SELECT customer_code, name1, name2, name3, name4, phone_number, fax, web_address, industry_sector, customer_profile, customer_type,
address, city, postal_code, country_key, zzcust_type, vat_code
FROM load_cust_general
WHERE account_group = 'ZSIT';
v_cust_cur c1%ROWTYPE;
-- type sales_tab is table of load_cust_sales_area%rowtype;
v_sales_area load_cust_sales_area%ROWTYPE;
-- v_sales_area sales_tab;
v_salesorg varchar2(10);
v_sales_district varchar2(10);
v_salesoff varchar2(10);
v_custgrp varchar2(10);
v_salesgrp varchar2(10);
v_type varchar2(20);
v_nature varchar2(10);
v_partner_code varchar2(10);
v_parent_cust varchar2(20);
v_credit_blk varchar2(20);
BEGIN
open c1;
loop
fetch c1 into v_cust_cur;
exit when c1%NOTFOUND;
for i in (SELECT customer_code, salesorg from load_cust_partner
where customer_code = v_cust_cur.customer_code ) LOOP
dbms_output.put_line(v_cust_cur.customer_code );
SELECT partner_code into v_partner_code from load_cust_partner
where customer_code = i.customer_code and salesorg = i.salesorg and partner_function = 'Z1';
dbms_output.put_line(v_partner_code||i.customer_code);
SELECT salesorg, sales_district, salesoff, salesgrp, custgrp INTO v_salesorg, v_sales_district, v_salesoff, v_salesgrp, v_custgrp FROM load_cust_sales_area
WHERE customer_code = i.customer_code and salesorg = i.salesorg;
dbms_output.put_line(v_salesorg||i.salesorg);
SELECT parent_customer INTO v_parent_cust from load_cust_hierarchy
WHERE customer_code = i.customer_code and salesorg = i.salesorg and hierarchy_type = 'G'; dbms_output.put_line(v_parent_cust);
SELECT credit_block INTO v_credit_blk from load_cust_company_cod
WHERE customer_code = i.customer_code;
dbms_output.put_line(v_credit_blk);
for j in (SELECT account_group, customer_type from load_cust_general
where customer_code IN (select customer_code from load_cust_partner
where partner_code = i.customer_code and salesorg = i.salesorg and partner_function = 'ZS'))
LOOP
-- exit when j%NOTFOUND;
dbms_output.put_line(j.account_group);
if (j.account_group = 'ZDIS') THEN
v_type := 'DISAC';
v_nature := '06';
-- EXIT ;
else
v_type := 'SPACC';
v_nature := '01';
END IF;
dbms_output.put_line(v_type||' '||v_nature);
END LOOP;
INSERT INTO sfdc_account
(SAP_ACCOUNT_ID__C, NAME, TYPE, RECORDTYPEID, PARENTID, PHONE, FAX, WEBSITE, OWNERID, MARKETING_DOMAIN__C,
INDUSTRIAL_SECTOR__C, ABC_CLASSIFICATION__C, NAME_1__C, NAME_2__C, NAME_3__C, NAME_4__C, PAYMENT_STATUS__C,
CUSTOMER_GROUP__C, ADDRESS_STREET__C, CITY__C, POSTAL_CODE__C, COUNTRY__C, SALES_OFFICE__C, SALESORG__C,
SALESDISTRICT__C, SALESGROUP__C, NATURE__C, VATCODE__C)
VALUES((i.customer_code||i.salesorg), (v_cust_cur.Name1||' '||v_cust_cur.name2), ' ', v_type, v_parent_cust,
v_cust_cur.phone_number, v_cust_cur.fax, v_cust_cur.web_address, v_partner_code, SUBSTR(v_cust_cur.industry_sector,1,2),
v_cust_cur.industry_sector, v_cust_cur.customer_profile, v_cust_cur.name1, v_cust_cur.name2, v_cust_cur.name3,
v_cust_cur.name4, v_credit_blk, v_custgrp, v_cust_cur.address, v_cust_cur.city, v_cust_cur.postal_code,
v_cust_cur.country_key, v_salesoff, v_salesorg, v_sales_district,
v_salesgrp, v_nature, v_cust_cur.vat_code);
end loop;
end loop;
CLOSE c1;
-- Delete data from Load Table
-- EXECUTE IMMEDIATE 'TRUNCATE TABLE load_cust_general';
/* truncate table load_cust_partner;
truncate table load_cust_hierarhy;
truncate table load_cust_sales_area;
truncate table load_cust_company_cod;
commit;
exception
when others then
raise_application_error( -20001, substr( sqlerrm, 1, 150 ) );
END;
Kindly Help.....
Thanks and RegardsCreate the procedure again and execute it in SQL*Plus environment and paste the output:
CREATE OR REPLACE procedure insert_sfdc_account
as
--DECLARE
CURSOR C1 IS
SELECT customer_code, name1, name2, name3, name4, phone_number, fax, web_address, industry_sector, customer_profile, customer_type,
address, city, postal_code, country_key, zzcust_type, vat_code
FROM load_cust_general
WHERE account_group = 'ZSIT';
v_cust_cur c1%ROWTYPE;
-- type sales_tab is table of load_cust_sales_area%rowtype;
v_sales_area load_cust_sales_area%ROWTYPE;
-- v_sales_area sales_tab;
v_salesorg varchar2(10);
v_sales_district varchar2(10);
v_salesoff varchar2(10);
v_custgrp varchar2(10);
v_salesgrp varchar2(10);
v_type varchar2(20);
v_nature varchar2(10);
v_partner_code varchar2(10);
v_parent_cust varchar2(20);
v_credit_blk varchar2(20);
BEGIN
open c1;
loop
fetch c1 into v_cust_cur;
exit when c1%NOTFOUND;
for i in (SELECT customer_code, salesorg from load_cust_partner
where customer_code = v_cust_cur.customer_code ) LOOP
SELECT partner_code into v_partner_code from load_cust_partner
where customer_code = i.customer_code and salesorg = i.salesorg and partner_function = 'Z1';
SELECT salesorg, sales_district, salesoff, salesgrp, custgrp INTO v_salesorg, v_sales_district, v_salesoff, v_salesgrp, v_custgrp FROM load_cust_sales_area
WHERE customer_code = i.customer_code and salesorg = i.salesorg;
dbms_output.put_line('Customer_Code : '|| i.customer_code);
dbms_output.put_line('SalesOrg : '|| i.salesorg);
SELECT parent_customer INTO v_parent_cust from load_cust_hierarchy
WHERE customer_code = i.customer_code and salesorg = i.salesorg and hierarchy_type = 'G';
dbms_output.put_line('Successfully Executed SQL st. Error is somewhere else');
SELECT credit_block INTO v_credit_blk from load_cust_company_cod
WHERE customer_code = i.customer_code;
for j in (SELECT account_group, customer_type from load_cust_general
where customer_code IN (select customer_code from load_cust_partner
where partner_code = i.customer_code and salesorg = i.salesorg and partner_function = 'ZS'))
LOOP
-- exit when j%NOTFOUND;
if (j.account_group = 'ZDIS') THEN
v_type := 'DISAC';
v_nature := '06';
-- EXIT ;
else
v_type := 'SPACC';
v_nature := '01';
END IF;
END LOOP;
INSERT INTO sfdc_account
(SAP_ACCOUNT_ID__C, NAME, TYPE, RECORDTYPEID, PARENTID, PHONE, FAX, WEBSITE, OWNERID, MARKETING_DOMAIN__C,
INDUSTRIAL_SECTOR__C, ABC_CLASSIFICATION__C, NAME_1__C, NAME_2__C, NAME_3__C, NAME_4__C, PAYMENT_STATUS__C,
CUSTOMER_GROUP__C, ADDRESS_STREET__C, CITY__C, POSTAL_CODE__C, COUNTRY__C, SALES_OFFICE__C, SALESORG__C,
SALESDISTRICT__C, SALESGROUP__C, NATURE__C, VATCODE__C)
VALUES((i.customer_code||i.salesorg), (v_cust_cur.Name1||' '||v_cust_cur.name2), ' ', v_type, v_parent_cust,
v_cust_cur.phone_number, v_cust_cur.fax, v_cust_cur.web_address, v_partner_code, SUBSTR(v_cust_cur.industry_sector,1,2),
v_cust_cur.industry_sector, v_cust_cur.customer_profile, v_cust_cur.name1, v_cust_cur.name2, v_cust_cur.name3,
v_cust_cur.name4, v_credit_blk, v_custgrp, v_cust_cur.address, v_cust_cur.city, v_cust_cur.postal_code,
v_cust_cur.country_key, v_salesoff, v_salesorg, v_sales_district,
v_salesgrp, v_nature, v_cust_cur.vat_code);
end loop;
end loop;
CLOSE c1;
-- Delete data from Load Table
-- EXECUTE IMMEDIATE 'TRUNCATE TABLE load_cust_general';
/* truncate table load_cust_partner;
truncate table load_cust_hierarhy;
truncate table load_cust_sales_area;
truncate table load_cust_company_cod;
commit;
exception
when others then
raise_application_error( -20001, substr( sqlerrm, 1, 150 ) );
END;
SQL> set serveroutput on
SQL> exec insert_sfdc_account; -
Using WWSBR_API.ADD_ITEM raises exception ITEM_CREATION_ERROR
All,
i create a very simple procedure in the schema of the portal owner:
create or replace procedure test_insert_item is
l_item_nr number;
l_site_id number;
l_corner_id number;
l_type_id number;
l_type_caid number;
l_region_id number;
begin
l_site_id := 154;
l_corner_id := 6989;
l_type_id := 2;
l_type_caid := 0;
l_region_id := 5;
l_item_nr := wwsbr_api.add_item (
p_caid => l_site_id
, p_folder_id => l_corner_id
, p_display_name => 'my test item'
, p_type_id => l_type_id
, p_type_caid => l_type_caid
, p_region_id => l_region_id
, p_text => 'my own text'
commit;
end;
If i run this procedure in SQL*Plus as the Portal-owner, then the first time during a session the procedure raises the exception
WWSBR_API.ITEM_CREATION_ERROR. Each following time that i run the procedure it inserts the text item as expected.
How come? I checked for invalid object etc., but there are none.
Any ideas?
Thanks in advance!
Regards,
Bindert GlazemaI experimented a little bit further. If i change the procedure to:
create or replace procedure test_insert_item is
l_item_nr number;
l_site_id number;
l_corner_id number;
l_type_id number;
l_type_caid number;
l_region_id number;
begin
l_site_id := 154;
l_corner_id := 6989;
l_type_id := 2;
l_type_caid := 0;
l_region_id := 5;
l_item_nr := wwsbr_api.add_item (
p_caid => l_site_id
, p_folder_id => l_corner_id
, p_display_name => 'my test item'
, p_type_id => l_type_id
, p_type_caid => l_type_caid
, p_region_id => l_region_id
, p_text => 'my own text'
commit;
exception
when WWSBR_API.ITEM_CREATION_ERROR then
l_item_nr := wwsbr_api.add_item (
p_caid => l_site_id
, p_folder_id => l_corner_id
, p_display_name => 'my test item'
, p_type_id => l_type_id
, p_type_caid => l_type_caid
, p_region_id => l_region_id
, p_text => 'my own text'
commit;
end;
then no exception will be raised when i run the procedure the first time during a SQL*Plus session and still the item is inserted. The weird thing is, that when i call this procedure from a dynamic page:
<HTML>
<BODY>
<ORACLE>
begin
portal30.test_insert_item;
exception
when portal30.wwsbr_api.ITEM_CREATION_ERROR
then
htp.p('Item creation error');
end;
</ORACLE>
</BODY>
</HTML>
then the item is not inserted when the page is run, but the page shows 'Item creation error' instead. Does anyone have an idea why this doesn't work?
null -
Handling no_Data_found and handling the cursor context not found exceptions
hi all,
when the value is not there in table, we will get the no_data_found exception.
im sending the sample procedure.
check that one.
create or replace procedure registration.P_GetPatientDetails(in_UHID in Patient.Uhid%Type,
ocursor_Component1 OUT SYS_REFCURSOR,
---ocursor_Component2 OUT SYS_REFCURSOR,
ocursor_Component3 OUT SYS_REFCURSOR,
ocursor_Component4 OUT SYS_REFCURSOR
AS
in_RegistrationID varchar2(50);
ln_genderLovID NUMBER(10);
ln_rhfactorLovID NUMBER(10);
BEGIN
SELECT RegistrationId
into in_RegistrationID
from Patient
where (Upper(UHID) = Upper(in_UHID)) ;
/* COMMIT;*/
/*dbms_output.put_line(in_RegistrationID);*/
OPEN ocursor_Component1 FOR
SELECT RegistrationID,PreRegistrationNo,EmergencyNo,UHID
FROM patient p LEFT OUTER JOIN EHIS.Titlemaster TM ON p.title = tm.titlecode LEFT OUTER JOIN EHIS.SuffixMaster SM on p.sufix = SM.SUFFIXCODE LEFT OUTER JOIN EHIS.Maritalstatusmaster MSM ON MSM.MARITALSTATUSID = p.maritalstatus LEFT OUTER JOIN EHIS.Bloodgroupmaster BGM ON BGM.BLOODGROUPID = p.bloodgroup LEFT OUTER JOIN EHIS.LovDetail LD ON(LD.LOVDETAILID = p.gender AND LD.LOVID = ln_genderLovID) LEFT OUTER JOIN EHIS.LovDetail rf ON(rf.LOVDETAILID = p.rhfactor AND rf.LOVID = ln_rhfactorLovID)
WHERE RegistrationID = in_RegistrationID AND p.Status = 1 ;
OPEN ocursor_Component3 FOR
SELECT RegistrationID,ResidenceNumber,MobileNumber,PrimaryEmail
FROM AddressMaster
WHERE UPPER(RegistrationID) = UPPER(in_RegistrationID) AND Status = 1 AND
AddressTypeID =
(SELECT AddressTypeID
FROM AddressTypeMaster
WHERE AddressTypeName = 'PermanentAddress');
/* COMMIT;*/
OPEN ocursor_Component4 FOR
SELECT ResidenceNumber, MobileNumber,EmergencyNumber,PrimaryEmail
FROM AddressMaster am LEFT OUTER JOIN EHIS.Countrymaster CM ON CM.COUNTRYID = am.country LEFT OUTER JOIN EHIS.Statemaster SM ON SM.STATEID = am.state LEFT OUTER JOIN EHIS.Districtmaster DM ON DM.DISTRICTID = am.district LEFT OUTER JOIN EHIS.Citymaster CM1 ON CM1.CITYID = am.city
WHERE UPPER(RegistrationID) = UPPER(in_RegistrationID) AND Status = 1 AND
AddressTypeID =
(SELECT AddressTypeID
FROM AddressTypeMaster
WHERE AddressTypeName = 'CurrentAddress');
/* COMMIT;*/
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(TO_CHAR(SQLCODE) || SQLERRM);
END;
if the data is not there for teh given uhid,
we are displaying the err msg in exception block
but from .net environment ,
they will define the cursors as out params.
if they wont get the data,
in .net environment, the exception is raised.
how to handle these situations.Implicit cursors are prone to both the NO_DATA_FOUND and TOO_MANY_ROWS errors. They MUST return precisely one row or you get to do extra coding in the form of exception handlers. Using explicit cursors (declared in the DECLARE SECTION) will avoid both errors, though they have their own considerations. When an explict cursor doesn't find something it doens't put NULL into the destination variable(s); it leaves them alone so its a good idea to null out variables and records before fetching into them.
-
Oracle Stored Procedure Not Accepting Comma delimited values in database
I have a stored procedure which does the following, declares variables and assigns values retrieved from a parameter temp_table database to each variable, then it reads column headings from a master table. Using the variables assigned to each parameter from the temp_table as a filter, the rows from the MASTER TABLE are finally output by the procedure. The stored procedure works fine when dealing with single value string values passed from the parameter temp_table.
The problem comes in when multiple values are selected and stored in the database parameter field as a comma separated string, eg. A045, A012
So, the strored procedure has been modified to use a function to split the string into separate values: 'A045' and 'A012'. So that: A045, A012 from the database will be returned to the stored procedure variable as *('A045', 'A012')* . When testing the stored procedure using the static values *('A045', 'A012')* , data is returned.
eg. EMPLOYEE_MASTER.CODE IN ('*A045*', '*A012*') will return results
However, when *('A045', 'A012')* is dynamically concatenated from the function and assigned to variable:
paramCode := split_str(paramCode) with paramCode eventually being passed: *('A045', 'A012')*
to become:
EMPLOYEE_MASTER.CODE IN (paramCode)
then NO DATA is returned.
I am stuck and don't know what the problem is. If anyone has any ideas, please feel free to help. I have included the Actual Stored Procedure below for a better understanding.
--------------------------------------------- STORED PROCEDURE-------------------------------------------------------
create or replace
PROCEDURE GETEMPLOYEEDATA
( sesId IN VARCHAR2,
l_cursor in out sys_refcursor
) is
compCode varchar(200);
businessUnit varchar(200);
locCode varchar(200);
hrDeptID varchar(200);
glDept varchar(200); plat varchar(200);
deptFunc varchar(200); empType varchar(200);
unionCode varchar(200); jobCode varchar(200);
careerLvl varchar(200);
empStatus varchar(200);
zid varchar(200);
superID varchar(200);
counter varchar(200) ;
token_index number;
--v_errm VARCHAR2(256);
BEGIN
dbms_output.put_line('Start of BEGIN');
/* Counter to get number of Unique Employee ID based on valid Session ID */
select count(*) into counter from XXCCHRWEB.hr_web_sessionid_tmp where parameter_20=sesId;
open l_cursor for SELECT counter EMPLOYEE_ID, '' LAST_NAME,
'' FIRST_NAME from dual;
dbms_output.put_line('OPENING FIRST CURSOR');
/* If no valid session ID returned then error gently */
if counter=0 then
open l_cursor for SELECT '' EMPLOYEE_ID, '' LAST_NAME,
'' FIRST_NAME,'' MIDDLE_NAME,'' NAME,
'' EMPLOYEE_TYPE, '' COMPANY, '' COMPANY_DESCRIPTION,
'' BUSINESS_UNIT, '' BUSINESS_UNIT_DESCRIPTION, '' LOCATION,
'' LOCATION_NAME, '' HR_DEPARTMENT_ID,'' DEPARTMENT_NAME,
'' DEPARTMENT_FUNCTION, '' PLATFORM, '' JOB_CODE,
'' JOB_TITLE, '' BUSINESS_TITLE, '' MANAGER_LEVEL,
'' JOB_FUNCTION, '' GL_DEPARTMENT_ID, '' GL_OP_UNIT,
'' GL_RESPONSIBILITY_CENTER, '' HR_CHANNEL,'' FULL_OR_PART_TIME,
'' REGULAR_OR_TEMP, '' GRADE,'' UNION_CODE,
'' BARGAINING_UNIT, '' ANNUAL_RATE,'' HOURLY_RATE,
'' HIRE_DATE, '' BIRTH_DATE, '' REHIRE_DATE,
'' SERVICE_DATE, '' POSITION_NUMBER, '' REPORTS_TO,
'' REPORTS_TO_TITLE, '' SUPERVISOR_ID, '' SUPERVISOR_NAME,
'' LAN_ID from dual;
dbms_output.put_line('End of counter=0');
-- return;
end if;
/* read from hr_web_sessionid_tmp */
select
parameter_1,parameter_2, parameter_3, parameter_4,
parameter_5,parameter_6, parameter_7, parameter_8,
parameter_9,parameter_10, parameter_11, parameter_12,
parameter_13, parameter_14
into
compCode, businessUnit, locCode, hrDeptID,
glDept, plat, deptFunc, empType,
unionCode, jobCode, careerLvl, empStatus,
zid, superID
from
XXCCHRWEB.hr_web_sessionid_tmp
where
parameter_20= sesId;
/*Assigning All Value to NULL superID*/
IF superid is null then
superID:= 'All';
END IF;
jobCode:='('''|| get_token(jobCode, 1)||''')'||','||'('''|| get_token(jobCode, 2)||''')';
dbms_output.put_line('SELECTING PARAMETERS FROM TEMP TABLE WITH ROW COUNT : '||l_cursor%ROWCOUNT);
/* read from Employee Master */
open l_cursor for SELECT DISTINCT * FROM ( SELECT HR_EMPLOYEE_MASTER.EMPLOYEE_ID, HR_EMPLOYEE_MASTER.LAST_NAME,
HR_EMPLOYEE_MASTER.FIRST_NAME, HR_EMPLOYEE_MASTER.MIDDLE_NAME, HR_EMPLOYEE_MASTER.NAME,
HR_EMPLOYEE_MASTER.EMPLOYEE_TYPE, HR_EMPLOYEE_MASTER.COMPANY, HR_EMPLOYEE_MASTER.COMPANY_DESCRIPTION,
HR_EMPLOYEE_MASTER.BUSINESS_UNIT, HR_EMPLOYEE_MASTER.BUSINESS_UNIT_DESCRIPTION, HR_EMPLOYEE_MASTER.LOCATION,
HR_EMPLOYEE_MASTER.LOCATION_NAME, HR_EMPLOYEE_MASTER.HR_DEPARTMENT_ID, HR_EMPLOYEE_MASTER.DEPARTMENT_NAME,
HR_EMPLOYEE_MASTER.DEPARTMENT_FUNCTION, HR_EMPLOYEE_MASTER.PLATFORM, HR_EMPLOYEE_MASTER.JOB_CODE,
HR_EMPLOYEE_MASTER.JOB_TITLE, HR_EMPLOYEE_MASTER.BUSINESS_TITLE, HR_EMPLOYEE_MASTER.MANAGER_LEVEL,
HR_EMPLOYEE_MASTER.JOB_FUNCTION, HR_EMPLOYEE_MASTER.GL_DEPARTMENT_ID, HR_EMPLOYEE_MASTER.GL_OP_UNIT,
HR_EMPLOYEE_MASTER.GL_RESPONSIBILITY_CENTER, HR_EMPLOYEE_MASTER.HR_CHANNEL, HR_EMPLOYEE_MASTER.FULL_OR_PART_TIME,
HR_EMPLOYEE_MASTER.REGULAR_OR_TEMP, HR_EMPLOYEE_MASTER.GRADE, HR_EMPLOYEE_MASTER.UNION_CODE,
HR_EMPLOYEE_MASTER.BARGAINING_UNIT, HR_EMPLOYEE_MASTER.ANNUAL_RATE, HR_EMPLOYEE_MASTER.HOURLY_RATE,
HR_EMPLOYEE_MASTER.HIRE_DATE, HR_EMPLOYEE_MASTER .BIRTH_DATE, HR_EMPLOYEE_MASTER.REHIRE_DATE,
HR_EMPLOYEE_MASTER.SERVICE_DATE, HR_EMPLOYEE_MASTER.POSITION_NUMBER, HR_EMPLOYEE_MASTER.REPORTS_TO,
HR_EMPLOYEE_MASTER.REPORTS_TO_TITLE, HR_EMPLOYEE_MASTER.SUPERVISOR_ID, HR_EMPLOYEE_MASTER.SUPERVISOR_NAME, HR_EMPLOYEE_MASTER.GENDER,
HR_EMPLOYEE_MASTER_1.LAN_ID
FROM
(XXCCHR.HR_EMPLOYEE_MASTER HR_EMPLOYEE_MASTER_1
LEFT OUTER JOIN
XXCCHR.HR_DEPARTMENT_SECURITY HR_DEPARTMENT_SECURITY
ON
HR_EMPLOYEE_MASTER_1.EMPLOYEE_ID=HR_DEPARTMENT_SECURITY.EMPLOYEE_ID)
LEFT OUTER JOIN
XXCCHR.HR_EMPLOYEE_MASTER HR_EMPLOYEE_MASTER
ON
-- HR_DEPARTMENT_SECURITY.DEPARTMENT_SECURITY=HR_EMPLOYEE_MASTER.HR_DEPARTMENT_ID
(HR_DEPARTMENT_SECURITY.DEPARTMENT_SECURITY=HR_EMPLOYEE_MASTER.HR_DEPARTMENT_ID
or
HR_DEPARTMENT_SECURITY.DEPARTMENT_SECURITY in ('DPALL','DPCAG009'))
WHERE
HR_EMPLOYEE_MASTER_1.LAN_ID=upper(zid) and
(compCode = 'All' or HR_EMPLOYEE_MASTER.COMPANY IN compCode)
(jobCode = 'All' or HR_EMPLOYEE_MASTER.JOB_CODE IN (jobCode) ) ) ;
dbms_output.put_line('END OF SELECT for counter number : ' || counter ||' Cursor row count : '|| l_cursor%ROWCOUNT || ' with Job Code : ' || (jobCode));
dbms_output.put_line('Company Code is:' || compCode);
COMMIT;
dbms_output.put_line('Data has been Output with session id:' || sesId);
--delete from XXCCHRWEB.hr_web_sessionid_tmp where parameter_20= sesId;
dbms_output.put_line('Data should have been DELETED, please check the session temp table');
commit;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('AN EXCEPTION HAS BEEN CAUGHT for counter number : ' || counter ||' Cursor row count : '|| l_cursor%ROWCOUNT || ' from session id : ' || sesId);
dbms_output.put_line('The error code is ' || SQLERRM);
END GETEMPLOYEEDATA;
Edited by: user10384134 on Nov 4, 2009 8:37 AMThis seems to work for me:
define param="'ABC','XYZ'"; --- Set up a test in clause
--- Test data
with test as
(select 'ABC' fld from dual union all
select 'DEF' from dual union all
select 'PQR' from dual union all
select 'XYZ' from dual)
--- Query starts here.
select fld
from test,
table (sys.ODCIVarchar2List (¶m)) p
where fld = p.column_valueOr Using an actual "IN" clause:
define param="'ABC','XYZ'";
with test as
(select 'ABC' fld from dual union all
select 'DEF' from dual union all
select 'PQR' from dual union all
select 'XYZ' from dual
p as
(select column_value from table (sys.ODCIVarchar2List (¶m))
select fld
from test
where fld in (select column_value from p)Edited by: AlanWms on Nov 4, 2009 9:08 AM -
PL/SQL Using SQL%NOTFOUND to raise a user defined exception in a function
I have written the following function for finding the number of items in stock in the item table.
CREATE OR REPLACE function getAmount (ItemID IN NUMBER)
RETURN NUMBER
AS
invalid_id EXCEPTION;
returnedQty number;
BEGIN
Select qty
Into returnedQty
From item
Where itemNo = ItemID;
RETURN (returnedQty);
IF SQL%NOTFOUND THEN
RAISE invalid_id;
END IF;
COMMIT;
Exception
WHEN invalid_id THEN
DBMS_OUTPUT.PUT_LINE('Invalid ID entered');
END getAmount;
The function compiles successfully, although there is a problem that Oracle is not handling my user-defined exception invalid_id
If I use the following for a valid itemID:
DECLARE
return_value number;
BEGIN
return_value := getAmount(1);
DBMS_OUTPUT.PUT_LINE (return_value);
END;
then the function returns the quantity of items in stock correctly.
However, if I enter an incorrect itemID, say 20
DECLARE
return_value number;
BEGIN
return_value := getAmount(20);
DBMS_OUTPUT.PUT_LINE (return_value);
END;
The invalid_id exception is not raised, and the Oracle errors says: no_data_found and the function has not returned a value. If I add a no_data_found exception, this works perfectly, but for this assignment I must write my own user-defined error.
Any help would be very much appreciated!
Thank you.What you're trying to do, is to use an implicit cursor. Implicit cursors will raise no_data_found and too_many_rows in case of an error. Explicit cursors will not.
Also, you have a small coding error ... a little rewrite and your code will do as you want to:
CREATE OR REPLACE function getAmount (ItemID IN NUMBER)
RETURN NUMBER
AS
invalid_id EXCEPTION;
returnedQty number;
cursor citem is
Select qty
From item
Where itemNo = ItemID;
fnd boolean;
BEGIN
open citem;
fetch citem Into returnedQty;
fnd := citem%found;
close citem;
if fnd then
RETURN (returnedQty);
else
RAISE invalid_id;
END IF;
/* Do not catch your own exception or the calling code will not receive it.
Exception
WHEN invalid_id THEN
DBMS_OUTPUT.PUT_LINE('Invalid ID entered');
END getAmount;
Your problem is, you're not using a package. This means, that the calling code has no way of catching this user-defined exeption. The correct way is to define a package, define the userdefined exception in the package and refer to it in your code:
create or replace package amt
is
invalid_id EXCEPTION;
function getAmount (ItemID IN NUMBER)
RETURN NUMBER;
end;
create or replace package body amt
is
function getAmount (ItemID IN NUMBER)
RETURN NUMBER
AS
returnedQty number;
cursor citem is
Select qty
From item
Where itemNo = ItemID;
fnd boolean;
BEGIN
open citem;
fetch citem Into returnedQty;
fnd := citem%found;
close citem;
if fnd then
RETURN (returnedQty);
else
RAISE invalid_id;
END IF;
end;
end; -- end package
To do a simple test, you'll do:
declare
a number;
begin
a := amt.getAmount(123);
dbms_output.put_line('The result is '||a);
exception
when amt.invalid_id then
dbms_output.put_line('ID not found');
end;
Other ways is to raise the exception in your no_data_found block.
But I'm REALLY puzzled if there's really someone out there who prefers a user-defined exception instead of the clearly defined NO_DATA_FOUND exception.
I can't be sure of course, but are you sure what they mean is they don't want ANY exception? That's a pretty common requirement.
In general - explicit cursors are a bit faster because Oracle does not have to do a second fetch to determine TOO_MANY_ROWS. And it's not too much additional writing. Explicit cursors will never raise exceptions - unless you use dynamic sql and your SQL is invalid.
Good luck -
Hello Gurus,
I have a problem with the Save Exceptions. I am using database 11g.
When I am doing bulk insert I would like to insert the error records into a new table. But when I am inserting
the error records I am getting the error "error:- ORA-00984: column not allowed here
ORA-24381: error(s) in array DML".
I am putting my code below.
DECLARE
CURSOR C_FRT2STORE IS
SELECT ROWID,
STORE_CD,
MNR_CD,
'FRT',
DT,
TO_DATE('31-DEC-2049'),
FRT_FAC,
TRUNC(SYSDATE),
'ADMINUSR'
FROM FRT2STORE;
CURSOR C_FRT2STORE_EXC_TAB IS
SELECT 'Y'
FROM ALL_TABLES
WHERE TABLE_NAME = 'FRT2STORE_EXC';
TYPE STORE$MNR2CST_REC_TYPE IS RECORD
(C_STORE$MNR2CST_ROWID VARCHAR2(100),
C_STORE_CD STORE$MNR2CST.STORE_CD%TYPE,
C_MNR_CD STORE$MNR2CST.MNR_CD%TYPE,
C_CST_CD STORE$MNR2CST.CST_CD%TYPE,
C_BEG_DT STORE$MNR2CST.BEG_DT%TYPE,
C_END_DT STORE$MNR2CST.END_DT%TYPE,
C_FAC NUMBER(13,3), --STORE$MNR2CST.FAC%TYPE,
C_AMT STORE$MNR2CST.AMT%TYPE,
C_CUBIC_AMT STORE$MNR2CST.CUBIC_AMT%TYPE,
C_LST_ACTN_DT STORE$MNR2CST.LST_ACTN_DT%TYPE,
C_EMP_CD STORE$MNR2CST.EMP_CD%TYPE
TYPE STORE$MNR2CST_TYPE IS TABLE OF STORE$MNR2CST_REC_TYPE
INDEX BY PLS_INTEGER;
STORE$MNR2CST_COL STORE$MNR2CST_TYPE;
V_TOT_REC PLS_INTEGER := 0;
V_FRT2STORE_EXC_TAB CHAR(1);
V_TOT_REC_IN_STORE$MNR2CST PLS_INTEGER;
V_ERR_REC PLS_INTEGER;
BULK_ERRORS EXCEPTION;
PRAGMA EXCEPTION_INIT (BULK_ERRORS, -24381);
BEGIN
--GETTING DATA FROM FRT2STORE TABLE AND INSERTING INTO THE STORE$MNR2CST TABLE
SELECT COUNT(1)
INTO V_TOT_REC_IN_STORE$MNR2CST
FROM STORE$MNR2CST ;
IF V_TOT_REC_IN_STORE$MNR2CST = 0 THEN
OPEN C_FRT2STORE;
LOOP
FETCH C_FRT2STORE BULK COLLECT INTO STORE$MNR2CST_COL LIMIT 1000;
EXIT WHEN STORE$MNR2CST_COL.COUNT = 0;
V_TOT_REC := STORE$MNR2CST_COL.COUNT;
IF V_TOT_REC > 0 THEN
BEGIN
FORALL I IN STORE$MNR2CST_COL.FIRST..STORE$MNR2CST_COL.LAST SAVE EXCEPTIONS
INSERT INTO STORE$MNR2CST
(STORE_CD,
MNR_CD,
CST_CD,
BEG_DT,
END_DT,
FAC,
AMT,
CUBIC_AMT,
LST_ACTN_DT,
EMP_CD
VALUES
(STORE$MNR2CST_COL(I).C_STORE_CD,
STORE$MNR2CST_COL(I).C_MNR_CD,
STORE$MNR2CST_COL(I).C_CST_CD,
STORE$MNR2CST_COL(I).C_BEG_DT,
STORE$MNR2CST_COL(I).C_END_DT,
STORE$MNR2CST_COL(I).C_FAC,
STORE$MNR2CST_COL(I).C_AMT,
STORE$MNR2CST_COL(I).C_CUBIC_AMT,
STORE$MNR2CST_COL(I).C_LST_ACTN_DT,
STORE$MNR2CST_COL(I).C_EMP_CD
COMMIT;
EXCEPTION WHEN BULK_ERRORS THEN
OPEN C_FRT2STORE_EXC_TAB;
FETCH C_FRT2STORE_EXC_TAB INTO V_FRT2STORE_EXC_TAB;
IF C_FRT2STORE_EXC_TAB%NOTFOUND THEN
EXECUTE IMMEDIATE ('CREATE TABLE FRT2STORE_EXC AS SELECT * FROM FRT2STORE WHERE 1 = 2');
END IF;
CLOSE C_FRT2STORE_EXC_TAB;
FOR J IN 1..SQL%BULK_EXCEPTIONS.COUNT
LOOP
V_ERR_REC := SQL%BULK_EXCEPTIONS(J).ERROR_INDEX;
EXECUTE IMMEDIATE 'INSERT INTO FRT2STORE_EXC (STORE_CD,MNR_CD,FRT_FAC,DT) VALUES ('
||STORE$MNR2CST_COL(V_ERR_REC).C_STORE_CD||','
||STORE$MNR2CST_COL(V_ERR_REC).C_MNR_CD||','
||STORE$MNR2CST_COL(V_ERR_REC).C_FAC||','
||STORE$MNR2CST_COL(V_ERR_REC).C_BEG_DT||')';
END LOOP;
COMMIT;
END;
STORE$MNR2CST_COL.DELETE;
END IF;
END LOOP;
CLOSE C_FRT2STORE;
END IF;
COMMIT;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('error:- '||SQLERRM);
END ;
Could any one tell me how to achive this requirment.
Thanks,
Sun1. Please format your code using the code tags.
2. You should never need to code create tables like this "EXECUTE IMMEDIATE ('CREATE TABLE FRT2STORE....". This is often seen when creating temporary tables in non-Oracle database but is a misunderstanding in how to do things in Oracle. You should create them outside of your plsql as permanent objects.
3. In your example, you should not need dynamic sql like this "EXECUTE IMMEDIATE 'INSERT INTO FRT2STORE_EXC...."
4. In 10gR2 / 11g, DML Error Logging might be a better solution
http://www.oracle.com/technology/oramag/oracle/06-mar/o26performance.html -
is this right way do to coding and exception handling
2 cases
if we get overwrite = 1 then update else insert.
I am not sure i have handled proper user defined exception.
Please advise.
create or replace procedure get_rc1(in_file_name in VARCHAR2, overwrite number) is
o_error_number number;
err_exception EXCEPTION;
begin
IF overwrite = 1 THEN
UPDATE store
SET uploaded_by = 'ram'
WHERE file_name = in_file_name;
dbms_output.put_line ('update');
IF (SQL%ROWCOUNT > 0)
THEN
history_log(p_key_id => '123',
desc => 'v_his_desc',
key_word => 'p1' ,
ser_id => 'ram',
status => NULL,
p_error_number => o_error_number);
IF o_error_number <> 0
THEN
RAISE err_exception;
END IF;
END IF;
ELSE
dbms_output.put_line ('insert');
INSERT
INTO store
ID
,FILE_LENGTH
,FILE_NAME
,DOCUMENT_IMAGE
,UPLOADED_DATE
,UPLOADED_BY
,MIME_TYPE
VALUES
1234,
12345,
'123',
NULL ,
sysdate,
'[email protected]',
'balaji'
IF (SQL%ROWCOUNT > 0)
THEN
history_log(p_key_id => '123',
desc => 'v_his_desc',
key_word => 'p2' ,
ser_id => 'ram',
status => NULL,
p_error_number => o_error_number);
IF o_error_number <> 0
THEN
RAISE err_exception;
END IF;
END IF;
END IF;
-- maintaining the history and setting the message
commit;
exception
when others then
dbms_output.put_line ( sqlerrm);
END;Hi,
user4485803 wrote:
is this right way do to coding and exception handling
2 cases
if we get overwrite = 1 then update else insert.
I am not sure i have handled proper user defined exception.
Please advise.When posting formatted text on this site, type these 6 characters:
\(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
create or replace procedure get_rc1(in_file_name in VARCHAR2, overwrite number) is
o_error_number number;
err_exception EXCEPTION;
begin
IF overwrite = 1 THEN
UPDATE store
SET uploaded_by = 'ram'
WHERE file_name = in_file_name;
dbms_output.put_line ('update');
IF (SQL%ROWCOUNT > 0)
THEN
history_log(p_key_id => '123',
desc => 'v_his_desc',
key_word => 'p1' ,
ser_id => 'ram',
status => NULL,
p_error_number => o_error_number);
IF o_error_number <> 0Did you mean IF o_error_number 1= 0
? This site doesn't like to display the <> inequality operator. Use the equivalent != operator when posting here.
THEN
RAISE err_exception;
END IF;
END IF;
ELSE
dbms_output.put_line ('insert');
INSERT
INTO store
ID
,FILE_LENGTH
,FILE_NAME
,DOCUMENT_IMAGE
,UPLOADED_DATE
,UPLOADED_BY
,MIME_TYPE
VALUES
1234,
12345,
'123',
NULL ,
sysdate,
'[email protected]',
'balaji'
IF (SQL%ROWCOUNT > 0)
THEN
history_log(p_key_id => '123',
desc => 'v_his_desc',
key_word => 'p2' ,
ser_id => 'ram',
status => NULL,
p_error_number => o_error_number);
IF o_error_number <> 0
THEN
RAISE err_exception;
END IF;
END IF;
END IF;
-- maintaining the history and setting the message
commit;
exception
when others then
dbms_output.put_line ( sqlerrm);
END;That looks like the correct way to raise an error.
If you don't have an EXCEPTION section, then PL/SQL will display an error message, including the line number where the error was detected. If the error occurred deep in a series of called procedures, the error message will include information about what procedures were called, and where. All of that is potentially very important information, and all of that is lost if you have your own EXCEPTION handler, like the one above. Acutally, it would be better to call the code above a exception *hider* , not a handler, because all it's really doing is hiding details about any error.
Use an EXCEPTION sedction only when you can improve on the default exception handling. Even then, you rarely want to use WHEN *OTHERS* ; you want to check for specific errors. For example...
EXCEPTION
WHEN err_exception
THEN
END;
If any exception other than err_exception occurs, this will not hide it. -
Manual Commit using Process Flows
Hi,
I have 2 mappings, each with commit control property set as 'Manual'. I created a process flow to run these mappings. Following the instructions in the OWB user guide, I added a single SQLPLUS activity in the process flow, and entered the following in the 'SCRIPT' parameter of the SQLPLUS activity :
DECLARE
status VARCHAR2(30);
BEGIN
SCHEDULER_TESTING.main(status);
IF status!='OK' THEN
ROLLBACK;
ELSE
ERROR_LOG_TESTING.main(status);
IF status!='OK' THEN
ROLLBACK;
ELSE
COMMIT;
END IF;
END IF;
END;
When I deploy and run this process flow, it shows the execution as successful (COMPLETE:OK) in the control center. But when I check the target tables, no records have been inserted.Also, when I check the execution job report in the repository browser, it shows the status as 'Complete:Failure' ,without displaying any error message.
There is no problem with the mappings, as executing them independantly gives the desired result.
Any idea what is going wrong?
Thanks and Regards,
AmitOK, well from the process flow perspective your script exited normally which is why it shows the sqlplus activity as having completed properly. You would need an exit variable in the script that the activity's outgoing transformation was checking to in order to have the process flow know that a failure occurred. Because whether the mappings succeed or not is not known to the process flow from this script.
But the other problem, of course, is why the script isn't running the process flows properly, but you haven't any way to determine this without doing some logging from the script.
Perhaps, as a quick and dirty testing idea you could create a table proc_log(msg varchar2(500) and amend your script to:
DECLARE
status1 VARCHAR2(30);
status2 VARCHAR2(30);
BEGIN
SCHEDULER_TESTING.main(status1);
IF status!='OK' THEN
ROLLBACK;
ELSE
ERROR_LOG_TESTING.main(status2);
IF status!='OK' THEN
ROLLBACK;
ELSE
COMMIT;
END IF;
END IF;
insert into yourSchema.proc_log('Status for scheduler_testing: '||status1);
insert into yourSchema.proc_log('Status for error_log_testing: '||status2);
commit;
EXCEPTION
when other then
rollback;
insert into yourSchema.proc_log('EXCEPTION: '||sqlerrm);
commit;
END;
just to try and see what is happening in there.
Now, to put an exit variable into your script you would need to do something like:
variable exec_return_code number;
DECLARE
-- we'll use 0 for success and 1 for failure
returncode number := 0;
status VARCHAR2(30);
BEGIN
SCHEDULER_TESTING.main(status);
IF status!='OK' THEN
returncode := 1;
ROLLBACK;
ELSE
ERROR_LOG_TESTING.main(status);
IF status!='OK' THEN
returncode := 1;
ROLLBACK;
ELSE
COMMIT;
END IF;
END IF;
:exec_return_code := returncode;
END;
exit :exec_return_code;
I haven't tried this yet, but it would be the only way I could think of to have any sort of success/failure returned from a sqlplus activity to the process flow.
Cheers,
Mike -
Hi All,
my procedure is like this ...
CREATE OR REPLACE PROCEDURE nested_proc
IS
CURSOR cur_TEMPVARRAY
IS
SELECT * FROM TEMPVARRAY;
TYPE typ_TEMPVARRAY IS TABLE OF cur_TEMPVARRAY%ROWTYPE;
r_TEMPVARRAY typ_TEMPVARRAY;
--v_TEMPVARRAY TEMPVARRAY%rowtype;
error_count number;
dml_error exception;
pragma exception_init(dml_error,-20902);
BEGIN
--pmytab ('inserted-1');
-- execute immediate 'truncate table cp_tempvarray';
OPEN cur_TEMPVARRAY;
LOOP
FETCH cur_TEMPVARRAY BULK COLLECT INTO r_TEMPVARRAY limit 10;
FORALL i_tp IN r_TEMPVARRAY.FIRST .. r_TEMPVARRAY.LAST save exceptions
-- INSERT INTO cp_tempvarray
-- VALUES r_TEMPVARRAY (i_tp);
INSERT INTO cp_tempvarray
VALUES (r_TEMPVARRAY (i_tp).a,
r_TEMPVARRAY (i_tp).b,
r_TEMPVARRAY (i_tp).c,
r_TEMPVARRAY (i_tp).d,
r_TEMPVARRAY (i_tp).e,
r_TEMPVARRAY (i_tp).f,
r_TEMPVARRAY (i_tp).g,
r_TEMPVARRAY (i_tp).h,
r_TEMPVARRAY (i_tp).i,
r_TEMPVARRAY (i_tp).j,
r_TEMPVARRAY (i_tp).j);
-- pmytab ('inserted1');
EXIT WHEN cur_TEMPVARRAY%NOTFOUND;
END LOOP;
COMMIT;
CLOSE cur_TEMPVARRAY;
COMMIT;
EXCEPTION
WHEN DML_ERROR THEN
error_count :=sql%bulk_exceptions.count;
DBMS_OUTPUT.put_line('Number of failures: ' || error_count);
for bulk_err in 1 .. error_count
loop
dbms_output.put_line('error' || bulk_err ||
'array index'||sql%bulk_exceptions(bulk_err).error_index||
'Massage'||sqlerrm(-sql%bulk_exceptions(bulk_err).error_code));
end loop;
END nested_proc;
when i am executing this procedure, i am getting the below error+
SQL> execute nested_proc;
ERROR:
ORA-24381: error(s) in array DML
ORA-06512: at "VRESS.NESTED_PROC", line 18
ORA-06512: at line 1
can any body help me plzzz..
Thanks,
Krupa>
ORA-06512: at "VRESS.NESTED_PROC", line 18
>
One or more rows of your FORALL failed and you didn't trap the exception so your code blew up.
When bulk processing with FORALL you need to trap the bulk exception if you want processing to continue if an error is encountered with one of the records.
You are trapping AN exception
pragma exception_init(dml_error,-20902);but that is not the bulk exception that you need to trap. You need to trap ORA-24381.
>
Example 12-9 shows how you can perform a number of DML operations, without stopping if some operations encounter errors. In the example, EXCEPTION_INIT is used to associate the DML_ERRORS exception with the predefined error ORA-24381. ORA-24381 is raised if any exceptions are caught and saved after a bulk operation.
>
See Handling FORALL Exceptions in the PL/SQL Language Reference
http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/tuning.htm#i49099 -
Update statement will not commit changes
I'm having a problem in Forms 4.5. I have a stored procedure that updates a table. I can call the stored procedure from a trigger within a form and it will work perfectly. However, when I copy the code from the stored procedure into a program unit, and call that program unit instead of the stored procedure, it doesn't work. It executes without generating any error messages, but the database remains unchanged. If anyone has seen this before, please help.
Thanks in advance,
SteveIn my form I have a block with a button. Within the WHEN-BUTTON-PRESSED trigger of that button I have the following code that calls a stored procedure:
UPDATE_RECORDS(code, date, ord_id);
This is the code for the stored procedure:
PROCEDURE UPDATE_RECORDS (
in_code IN NUMBER(6)
,in_date IN DATE
,in_ord_id IN NUMBER(6)) IS
BEGIN
UPDATE
count_records
SET
ord_id = in_ord_id
WHERE
id IN (
SELECT
cr.id
FROM
count_records cr
,orders ord
,items itm
,work_locs wl
WHERE
wl.code = in_code
AND itm.wl_id = wl.id
AND ord.itm_id = itm.id
AND cr.ord_id = ord.id
AND cr.starting_time >= in_date
COMMIT;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Update of records has failed.');
END UPDATE_RECORDS;
When I click on the button the trigger fires and the stored procedure executes. I can then query the database to confirm that the changes have taken place in the count_records table.
However, I've taken the code in the stored procedure and placed it in a Program Unit. I've changed the WHEN-BUTTON-PRESSED trigger to call the program unit:
UPDATE_RECORDS_WITHIN_FORM(code, date, ord_id);
This is the code for the Program Unit:
PROCEDURE UPDATE_RECORDS_WITHIN_FORM (
in_code IN NUMBER(6)
,in_date IN DATE
,in_ord_id IN NUMBER(6)) IS
BEGIN
UPDATE
count_records
SET
ord_id = in_ord_id
WHERE
id IN (
SELECT
cr.id
FROM
count_records cr
,orders ord
,items itm
,work_locs wl
WHERE
wl.code = in_code
AND itm.wl_id = wl.id
AND ord.itm_id = itm.id
AND cr.ord_id = ord.id
AND cr.starting_time >= in_date
COMMIT;
EXCEPTION
WHEN OTHERS THEN
MESSAGE('Update of records has failed.', ACKNOWLEDGE);SYNCHRONIZE;
END UPDATE_RECORDS_WITHIN_FORM;
When I click on the button the trigger fires and the program unit executes. The error message never appears, but when I query the database, there are no changes to the count_records table.
This seems really strange and I would appreciate any help on this.
Thanks,
Steve -
FELX-SSV EXCEPTION Error while creating SIT through concurrent program
I am trying to create an SIT through concurrent program using API with all hard coded values for all API parameters, I am getting FLEX-SSV Exception error but the same code is working fine in TOAD.
Procedure :-
CREATEORREPLACEPROCEDURE XX_ABSENCE_TEST
P_ERR_BUF OUTVARCHAR2,
P_RETCODE OUTNUMBER
IS
L_ANALYSIS_CRITERIA_ID NUMBER;
L_OUT_PERSON_ANALYSIS_ID NUMBER;
L_PEA_OBJECT_VERSION_NUMBER NUMBER;
L_ERR_MESG varchar2(3000);
BEGIN
INSERTINTOXX_DEBUGVALUES('Starting',0,0);
HR_SIT_API.CREATE_SIT
(P_VALIDATE =>FALSE,
P_PERSON_ID =>59021,
P_BUSINESS_GROUP_ID =>3036,
P_ID_FLEX_NUM =>50320,
P_EFFECTIVE_DATE =>'02-APR-15',
P_DATE_FROM =>'02-APR-15',
P_SEGMENT1 =>'Annual Leave',
P_SEGMENT3 =>'02-APR-15',
P_SEGMENT5 =>'05-APR-15',
P_SEGMENT10 =>59021,--I.PERSON_ID,
P_SEGMENT15 =>'02-APR-15',
P_ANALYSIS_CRITERIA_ID => L_ANALYSIS_CRITERIA_ID,
P_PERSON_ANALYSIS_ID => L_OUT_PERSON_ANALYSIS_ID,
P_PEA_OBJECT_VERSION_NUMBER => L_PEA_OBJECT_VERSION_NUMBER
INSERTINTOXX_DEBUGVALUES('Created',NULL,NULL);
COMMIT;
EXCEPTION
WHENOTHERSTHEN
L_ERR_MESG :=
L_ERR_MESG || SUBSTR(SQLERRM,1,250)
|| CHR(10);
INSERTINTOXX_DEBUGVALUES('Exception',L_ERR_MESG,NULL);
commit;
END;
Regards,
PradeepIt looks like more of an issue with connecting to essbase, usually "java.lang.UnsatisfiedLinkError: no HspEssbaseEnv in java.library.path" means planning has not been installed or deployed correctly, what OS is it running on?
Cheers
John
http://john-goodwin.blogspot.com/ -
Hello,
I have a problem to catch exception in this proc :
create or replace procedure MAPROC (nom_snapshot in varchar2) is
ladate varchar2(20);
BEGIN
select sysdate into ladate from dual;
dbms_snapshot.refresh(nom_snapshot);
execute immediate 'UPDATE update_snapshot set DATE_REFRESH = to_date(''' || ladate || ''') where nom_snapshot = '''|| nom_snapshot || '''';
COMMIT;
EXCEPTION
WHEN OTHERS THEN
execute immediate 'UPDATE update_snapshot set ERREUR = ' || SQLERRM || ' where nom_snapshot = '''|| nom_snapshot || '''';
END;
the proc MAPROC is in called in :
DECLARE
nom_snapshot varchar2(50);
cursor c1 is select b.nom_snapshot from user_snapshots a
begin
open c1;
loop
fetch c1 into nom_snapshot;
exit when c1%NOTFOUND;
MAPROC(nom_snapshot) ;
end loop;
close c1;
end;
the second proc is in error because i can't catch the error in the exception step of MAPROC. However, the error is due to the following step in MAPROC :
dbms_snapshot.refresh(nom_snapshot);
How can i do to catch the exception in MAPROC, and not allow it to climb in the second proc.
ThanksThanks for all your answers.
I'm too busy today to test every remarks you've made.
however, i just want to explain the final goal of the procs. maybe it will be easier for you to find a solution, or a better way to do this :
i want to make a proc that refresh oracle snapshot.
so i put in a cursor the list of snapshot for the oracle user
(select name from user_snapshots)
then for each snapshot name, i have to do :
truncate trable "snapshot name"
dbms_snapshot.refresh("snapshot name")
update TABLE set date = "sysdate" where snapshot_name = "snapshot name"
if it fails, principally, the refresh step which it a source of pbs, i want to do :
update TABLE set error= "Oracle error" where snapshot_name = "snapshot name"
So to do this, i thougt it will be better to divide the work in 2 step (and procs) :
the first proc which select the list
the second proc, which is doing the refresh, etc ... for every snapshot.
so if you think my method is not the good one, I'm open to try another.
but, don't use something to hard, i'm not an PL/SQL expert, but you surely already know this.
J. -
Raise IGNORE_RECORD Exception
Hi All,
I have the following code. What I do not understand is when processing certain records, when the v_per = 100, record gets written to the "ct_vv_chargeback_actual" table but not to the other following tables like CT_ORIG_ORDER, CT_VV_CHARGEBACK etc.
Is it because of the raise IGNORE_RECORD? If so, can any one explain how the user defined exception works? (apologize for the long code)
Thanks,
DECLARE
CURSOR GET_TKT_CB_DETAILS IS
SELECT orh.order_no,
ssku.shipment,
ssku.sku,
orh.supplier,
sum(ssku.qty_expected) tkt_qty,
sum(ssku.qty_expected) tkt_cost,
ctt.qty_printed ctt_qty_printed,
ctt.qty_printed ctt_tkt_cost
FROM ordhead orh,
ct_chargeback_shipment shp,
shipsku ssku,
uda_item_lov uil,
(select order_no,pack_no,sum(qty_printed) qty_printed
from ct_tkt_ticket_print_hist
group by order_no,pack_no) ctt
WHERE shp.receive_date = (select trunc(vdate) from period)
AND shp.location = 930
AND shp.tkt_flag is null
AND shp.order_no = orh.order_no
AND orh.import_order_ind = 'N'
AND orh.written_date > to_date('31-MAY-03')
AND shp.shipment = ssku.shipment
AND ssku.sku = uil.item
AND uil.uda_id = 6
AND uil.uda_value <> 7
AND shp.order_no = ctt.order_no
AND ssku.sku = ctt.pack_no
group by orh.order_no,
ssku.shipment,
ssku.sku,
orh.supplier,
ctt.qty_printed ,
ctt.qty_printed ;
v_chk varchar2(1);
v_old_quantity number;
v_sku_qty number;
v_order_no number;
v_shipment number;
v_tkt_cost number;
v_pack_no number;
v_tkt_qty number;
v_orig_qty number;
v_supplier number;
v_cb_id number;
v_vdate date;
v_dept number;
v_tkt_dept number;
v_tkt_div varchar2(2);
v_per number(12,4);
v_orig_ord_qty number;
v_rate number(12,4);
v_yn varchar2(1);
v_err_desc varchar2(200);
v_mail_country_id varchar2(4);
v_pre_tick varchar2(1);
v_actual number;
IGNORE_RECORD EXCEPTION;
IGNORE_SUPPLIER EXCEPTION;
BEGIN
select vdate
into v_vdate
from period;
FOR get_tkt_cb IN get_tkt_cb_details LOOP
BEGIN
BEGIN
SELECT '1'
INTO v_chk
FROM CT_ORIG_ORDER
WHERE ORDER_NO = get_tkt_cb.order_no
AND PACK_NO = get_tkt_cb.sku;
RAISE IGNORE_RECORD;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
END;
v_old_quantity := 0;
v_sku_qty := 0;
v_order_no := null;
v_shipment := null;
v_tkt_cost := 0;
v_actual := 0;
v_err_desc := null;
v_chk := null;
v_pack_no := 0;
v_tkt_qty := 0;
v_orig_qty := 0;
v_supplier := 0;
v_cb_id := 0;
v_dept := 0;
v_tkt_dept := 0;
v_tkt_div := 0;
v_per := 0;
v_rate := 0;
v_yn := null;
v_pre_tick := null;
v_pack_no := get_tkt_cb.sku;
BEGIN
select sum(sku_qty)
into v_sku_qty
from packsku
where pack_no =v_pack_no;
EXCEPTION
WHEN NO_DATA_FOUND THEN
v_sku_qty := 1;
END;
select dept
into v_dept
from desc_look
where sku = v_pack_no;
v_supplier := get_tkt_cb.supplier;
v_order_no := get_tkt_cb.order_no;
BEGIN
select nvl(per,0),
nvl(rate,1)
into v_per,
v_rate
from AP_CB_EXCEPTIONS
where vendor_number = lpad(to_char(v_supplier),'6','0')
and nvl(div,'0') = decode(length(v_dept),4,substr(to_char(v_dept),1,1),'1')
and nvl(dept,0) = v_dept
and nvl(cb_no,410) = 410
and trunc(v_vdate) between trunc(start_date) and nvl(trunc(end_date),trunc(v_vdate));
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
select nvl(per,0),
nvl(rate,1)
into v_per,
v_rate
from AP_CB_EXCEPTIONS
where vendor_number = lpad(to_char(v_supplier),'6','0')
and nvl(div,'0') = decode(length(v_dept),4,substr(to_char(v_dept),1,1),'1')
and nvl(dept,0) = 0
and nvl(cb_no,410) = 410
and trunc(v_vdate) between trunc(start_date) and nvl(trunc(end_date),trunc(v_vdate));
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
select nvl(per,0),
nvl(rate,1)
into v_per,
v_rate
from AP_CB_EXCEPTIONS
where vendor_number = lpad(to_char(v_supplier),'6','0')
and nvl(div,'0') = '0'
and nvl(dept,0) = v_dept
and nvl(cb_no,410) = 410
and trunc(v_vdate) between trunc(start_date) and nvl(trunc(end_date),trunc(v_vdate));
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
select nvl(per,0),
nvl(rate,1)
into v_per,
v_rate
from AP_CB_EXCEPTIONS
where vendor_number = lpad(to_char(v_supplier),'6','0')
and nvl(div,'0') = '0'
and nvl(dept,0) = 0
and nvl(cb_no,410) = 410
and trunc(v_vdate) between trunc(start_date) and nvl(trunc(end_date),trunc(v_vdate));
EXCEPTION
WHEN NO_DATA_FOUND THEN
v_per := 0;
v_rate := .01;
--RAISE IGNORE_SUPPLIER;
END;
END;
END;
END;
BEGIN
select country_id
into v_mail_country_id
from addr
where key_value_1 = to_char(v_supplier)
and seq_no in (select mail_addr_type_seq_no
from ct_ordhead
where order_no = v_order_no)
and addr_type = 15;
IF v_mail_country_id <> 'US' THEN
Select import_rate
into v_rate
from ap_ticket_cb_rates;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE IGNORE_RECORD;
END;
BEGIN
select qty_ordered
into v_orig_ord_qty
from ct_po_log
where order_no = v_order_no
and sku = v_pack_no
and date_changed = (select min(date_changed)
from ct_po_log
where order_no = v_order_no
and sku = v_pack_no);
EXCEPTION
when others then
v_err_desc := substr(sqlerrm,1,100);
INSERT INTO IF_ERRORS VALUES (
'CT_TKTCHB.SQL',SYSDATE,'Order no ' || v_order_no || ' sku ' || v_pack_no || ' ',
v_err_desc);
commit;
RAISE IGNORE_RECORD;
END;
v_shipment := get_tkt_cb.shipment;
v_tkt_qty := get_tkt_cb.ctt_qty_printed;
v_orig_qty := get_tkt_cb.tkt_qty*v_sku_qty;
v_orig_ord_qty := v_orig_ord_qty * v_sku_qty;
v_tkt_cost := round(v_orig_ord_qty*v_rate*((100-v_per)/100)*1.15,2);
v_actual := round(v_orig_ord_qty*1.15,2);
IF v_per = 100 THEN
insert into ct_vv_chargeback_actual values (
null,
v_supplier,
v_order_no,
v_shipment,
v_pack_no,
'410',
v_actual,
1,
v_vdate);
COMMIT;
raise IGNORE_RECORD;
END IF;
select ct_vv_chargeback_seq.nextval
into v_cb_id
from dual;
INSERT INTO CT_ORIG_ORDER VALUES (
v_order_no,
v_shipment,
v_pack_no,
v_tkt_qty,
v_orig_qty,
v_orig_ord_qty,
'N',
v_supplier,
v_cb_id,
'N',
v_tkt_cost,
v_vdate);
INSERT INTO CT_VV_CHARGEBACK VALUES (
v_cb_id,
v_order_no,
'A',
v_supplier,
null,
null,
null,
null,
v_shipment);
INSERT INTO CT_VV_CHARGEBACK_DETAIL VALUES (
v_cb_id,
v_pack_no,
'410',
v_tkt_cost,
1);
IF v_tkt_cost <> v_actual THEN
insert into ct_vv_chargeback_actual values (
v_cb_id,
v_supplier,
v_order_no,
v_shipment,
v_pack_no,
'410',
v_actual,
1,
v_vdate);
END IF;
UPDATE CT_CHARGEBACK_SHIPMENT
SET TKT_FLAG = 'C'
WHERE shipment = get_tkt_cb.shipment;
COMMIT;
EXCEPTION
WHEN IGNORE_SUPPLIER THEN
NULL;
WHEN IGNORE_RECORD THEN
NULL;
WHEN NO_DATA_FOUND THEN
UPDATE CT_CHARGEBACK_SHIPMENT
SET TKT_FLAG = 'D'
WHERE shipment = get_tkt_cb.shipment;
COMMIT;
WHEN OTHERS THEN
rollback;
v_err_desc := substr(sqlerrm,1,200);
insert into if_errors values ('ct_tktchb.sql',
sysdate,
v_err_desc,
'Error while processing order - ' ||
to_char(v_order_no) ||
' shipment - ' || to_char(v_shipment));
commit;
END;
END LOOP;
Without analysing the code in detail, the
IGNORE_RECORD exception is raised in four places
within the BEGIN-END block that implements the loop.
When it's raised, processing drops to the exception
handler at the bottom, then the loop continues with
the next record. It's kind of a pre-11g CONTINUE.gotcha...thats what I wanted to know. Glad to know that it works as CONTINUE....couldn't figure out why some values are not showing up.
Thanks,
Chiru
Maybe you are looking for
-
Hello to everyone in the community. I have a problem for the jump menu. My problem is the following: When I click on the value of I he opens the menu page it returns the correct value most of the menu to the first position. I wonder how can the value
-
SharePoint BI in Windows Azure
Dear all I have setup a BI demo environment on Windows Azure to show PowerPivot, PerformancePoint Services, and Power View. The demo environment include 3 VMs: DC, SQL 2012 SP1, and SharePoint 2013. Every demo works fine when I use IE inside SharePoi
-
Thumbnails for XLS, DOC, etc
Hello, is it possible to have XLS file checked in and to have thumbnail for it? As far as I can see, one option is to use XLS -> PDF conversion with Inbound Refinery and then we will have thumbnail. I can agree that we need to have M$ Office installe
-
I know how to flatten the sdo_ordinates array... select * from table ( select a.geo.sdo_ordinates from states a where a.state = 'California'); But we now have a need to be able to flatten the sdo_ordinate array so that we can access the ordinates in
-
Order qty is in display mode in qty contract
HI GURU kapil & Raghavendra YN , I follow your instructions but it is not working. guru i want to put target qty & order qty both, say---target qty 1000 & order qty 200 like that . but in standard sap system order qty is in display mode . note- i s