Collection with bulk collect , statement is not executed..
DECLARE
CURSOR cur_upt IS SELECT ts.user_id, ts.lot_id, ts.ml_ac_no, ts.td_prs_dt, ts.unit_cost, ts.cost_basis
FROM tb_xop_sharelot_frac_snap fs, tb_xop_sharelot ts
WHERE fs.lot_id=ts.lot_id AND fs.user_id=ts.user_id;
TYPE tx_tab IS TABLE OF tb_xop_sharelot.user_id%TYPE;
ltab tx_tab;
TYPE tx_tab1 IS TABLE OF tb_xop_sharelot.lot_id%TYPE;
ltab1 tx_tab1;
TYPE tx_tab2 IS TABLE OF tb_xop_sharelot.ml_ac_no%TYPE;
ltab2 tx_tab2;
TYPE tx_tab3 IS TABLE OF tb_xop_sharelot.td_prs_dt%TYPE;
ltab3 tx_tab3;
TYPE tx_tab4 IS TABLE OF tb_xop_sharelot.unit_cost%TYPE;
ltab4 tx_tab4;
TYPE tx_tab5 IS TABLE OF tb_xop_sharelot.cost_basis%TYPE;
ltab5 tx_tab5;
BEGIN
INSERT INTO tb_xop_sharelot_frac_snap (lot_id, jemq_num, lot_qy, activity_type, LOT_SL_CREATE_DT,
LOT_SL_CLOSE_DT, lot_status, frac_recon, hist_flag, create_dt, user_id)
(SELECT lot_id, jemq_num, lot_qy, activity_type, LOT_SL_CREATE_DT,
LOT_SL_CLOSE_DT,lot_status, frac_recon, hist_flag, create_dt, user_id FROM tb_xop_sharelot_fraction);
OPEN Cur_upt;
LOOP
FETCH Cur_upt BULK COLLECT INTO ltab, ltab1, ltab2, ltab3, ltab4, ltab5 LIMIT 5000;
EXIT WHEN cur_upt%NOTFOUND;
END LOOP;
CLOSE cur_upt;
FORALL i IN ltab.FIRST..ltab.LAST
UPDATE tb_xop_sharelot_frac_snap SET ml_ac_no=ltab2(i)/*, td_prs_dt=ltab3(i),
unit_cost=ltab4(i), cost_basis=ltab5(i)*/ WHERE user_id=ltab(i) AND lot_id=ltab1(i);
COMMIT;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLCODE|| ' ' ||SQLERRM);
END;
This is the third question you have posted just putting one short subject and only posting code not formatted.
I suggest you to read SQL and PL/SQL FAQ and avoid posting your question in this way as they will be ignored.
Please:
a) post sample data
b) post your code formatted
i.e.:
{noformat}{noformat}
SELECT ...
{noformat}{noformat}
c) explain what problem you are facing in details (including oracle errors)
d) explain the logic you want to have
e) post your expected output.
Regards.
Al
Similar Messages
-
Recently started getting these 6398 errors with SharePoint 2013 Single Farm and haven't been able to fix with any google results. Everything seems to run fine. They usually appear overnight. Average 5-9 daily event logs. See
Errors below.
Get-CacheHost
always reports UP
Have already tried:
- Upgrading to AppFabric CU5
- Restart-Service AppFabricCachingService
- Clear Configuration Cache
- habaneroconsulting Distributed Cache Bug
- nobadthing Unexpected exception in feedcacheservice
- mmman itgroove fixing the appfabric cache cluster
- Microsoft unable to start appfabriccachingservice
- dhasalprashantsharepoint lets-troubleshoot-sharepoint
...and many other readings. (sorry I cant post links even though I verified my account 100 times)
Errors:
The Execute method of job definition Microsoft.Office.Server.UserProfiles.LMTRepopulationJob (ID 414cbbe9-cdb1-4f7a-beed-85fbfd8a10c7) threw an exception. More information is included below.
Unexpected exception in FeedCacheService.IsRepopulationNeeded: Cache cluster is down, restart the cache cluster and Retry.
The Execute method of job definition Microsoft.Office.Server.UserProfiles.LMTRepopulationJob (ID 414cbbe9-cdb1-4f7a-beed-85fbfd8a10c7) threw an exception. More information is included below.
Unexpected exception in FeedCacheService.IsRepopulationNeeded: Connection to the server terminated,check if the cache host(s) is running .
The Execute method of job definition Microsoft.SharePoint.Administration.SPProductVersionJobDefinition (ID 95aee52d-88a1-4355-b6b6-9d43d753414e) threw an exception. More information is included below.
Collection was modified; enumeration operation may not execute.Hi,
Please firstly go to Central Administration > Application Management > Manage Services on server, make sure the Distributed Cache service has been started on all servers.
If you execute Get-CacheHost and Get-Cache in SharePoint 2013 Management Shell, is it return the expected information? If it returns the red error message, please refer to the article below to remove SPDistributedCacheServiceInstance and add SPDistributedCacheServiceInstance.:
http://blogs.technet.com/b/saantil/archive/2013/03/31/distributed-cache-in-sharepoint-2013-quot-unexpected-exception-in-feedcacheservice-isrepopulationneeded-cache-cluster-is-down-restart-the-cache-cluster-and-retry-quot.aspx
Regards,
Rebecca Tu
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
Oracle Error - statement handle not executed state
Hello,
A BCA scheduled job has failed and returned with the following error. Does anyone have an idea to fix this error.
Connection or SQL sentence error: (DA0005): [Exception: DBD, ORA-24338: statement handle not executed State: N/A] The following data providers have not been successfully refreshed
Thanks
-GopiPlease provide more information on what Crystal Reports or Business Objects product you are using. The more details you can provide, the quicker the resolution...
Ludek -
Urgent: ORA-24338: statement handle not executed
Hello,
/*===================================================*/
PL/SQL code:
SQL> create or replace package p3 is
2 type t_c is ref cursor;
3 procedure p(p_c out t_c);
4 end p3;
5 /
Package created.
SQL> show errors;
No errors.
SQL>
SQL>
SQL> create or replace package body p3 is
2
3 procedure p(p_c out t_c)
4 is
5 v_c t_c;
6 begin
7 open v_c for
8 select job_number
9 from rep_adhoc_invoices
10 where rownum<5;
11 end p;
12 end p3;
13 /
Package body created.
SQL> show errors;
No errors.
/*===================================================*/
C# code:
OracleConnection dbConnection = null; /* see finalize{} */
OracleCommand dbCommand = null;
OracleDataAdapter dbAdapter = null;
try
dbConnection = new OracleConnection(GetConnectionString());
dbConnection.Open();
dbCommand = new OracleCommand();
dbCommand.Connection = dbConnection;
dbCommand.CommandText = "p3.p"; dbCommand.CommandType = CommandType.StoredProcedure;
dbCommand.Parameters.Add("p_c", OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Output);
dbAdapter = new OracleDataAdapter(dbCommand);
System.Data.DataSet ds = new DataSet();
dbAdapter.Fill(ds);
return(ds);
catch (Exception e)
Console.WriteLine(e.Message);
/*===================================================*/
Problem:
When code executes:
dbAdapter.Fill(ds);
I constantly get the ORA-24338.
The same result if I try from console with "set autoprint on" (v_c is defined beforehand):
SQL> execute p3.p(:v_c)
PL/SQL procedure successfully completed.
ERROR:
ORA-24338: statement handle not executed
It seems to me, that the problem is on the server.
Does anyone know, WHAT is the problem?
Thanks a lot beforehand!
Edgar.In your procedure implementation (below), you forgot to assign the local variable v_c to the out parameter p_c before exiting the rountine. This means that the ref cursor parameter is never opened.
The error you got occurs because when ODP.NET gets back the ref cursor it tries to fetch from it without checking whether it's open or not. If you look up the ORA-24338 error code in the documentation, it'll tell you as much. Typcially, when I get an error I don't understand, I head straight for the docs. They not only tell me what it means, but often suggest a solution.
This behaviour of ODP must be for performance reasons, since doing the check everytime would be wasted most of the time. Still, it would have been nice if they'd emulated MSDAORA, which DOES check.
3 procedure p(p_c out t_c)
4 is
5 v_c t_c;
6 begin
7 open v_c for
8 select job_number
9 from rep_adhoc_invoices
10 where rownum<5;
11 end p;
12 end p3;
13
Frankly, I'm surprised you didn't get ORA-3113: end of communication channel. This is what happened to me when I exited a function without assigning the ref cursor. To solve it, I'd changed the declaration of the PL/SQL function and OracleCommand parameters to IN OUT instead of just OUT. THEN, I got ORA-24338. Anyway, watch out for these things as you progress.
Happy coding.
Clarence -
Java.sql.SQLException: statement handle not executed
hello,
i am calling a stored procedure and its returns a REF CURSOR and i am getting intermittent exceptions below,
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [{call
xxxx_pkg(?,?)}]; SQL state [99999]; error code [17144]; statement handle not executed; nested exception is java.sql.SQLException: statement handle not executed
and
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [{call
xxxx_pkg(?,?,?)}]; SQL state [99999]; error code [17009]; Closed Statement; nested exception is java.sql.SQLException: Closed Statement
any clue what could be the issue,
Regards
GGits pretty simple have a java class calling hibernateTemplate's findByNamedQueryAndNamedParam method by passing the procedure name and binding parameters/values, and here is the stack
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [{call
xxx_pkg(?,?)}]; SQL state [99999]; error code [17144]; statement handle not executed; nested exception is java.sql.SQLException: statement handle not executed
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:410)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQueryAndNamedParam(HibernateTemplate.java:1006)
Caused by: java.sql.SQLException: statement handle not executed
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:229)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:403)
at oracle.jdbc.driver.T4CStatement.doDescribe(T4CStatement.java:701)
at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3355)
at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:2009)
at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:494)
at org.hibernate.type.StringType.get(StringType.java:18)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2091)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1380)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1308)
at org.hibernate.loader.Loader.getRow(Loader.java:1206)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580)
at org.hibernate.loader.Loader.doQuery(Loader.java:701)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2217)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2108)
at org.hibernate.loader.Loader.list(Loader.java:2103)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1696)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
at org.springframework.orm.hibernate3.HibernateTemplate$34.doInHibernate(HibernateTemplate.java:1015)
at org.springframework.orm.hibernate3.HibernateTemplate$34.doInHibernate(HibernateTemplate.java:1)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406) -
Insert statement is not executing.....
From below procedure the insert statement is not executing....
update statement is working perfectly but insert......
create or replace PROCEDURE PAYMENT(AMT NUMBER,UID NUMBER) IS
AMT1 NUMBER;
AMT NUMBER;
PD VARCHAR2(100);
C1 NUMBER;
PER NUMBER;
ACC1 VARCHAR2(15);
CF NUMBER;
CRF NUMBER;
ACC2 VARCHAR2(15);
begin
SELECT PAY_DESC INTO PD FROM SUB.PAYMENT_TY WHERE ORD=0;
SELECT NVL(AMOUNT,0) INTO C1 FROM FOOD.MEMBER WHERE LTRIM(RTRIM(UPPER(NAME))) LIKE
LTRIM(RTRIM(UPPER(PD)))
AND USER_ID=UID;
IF NVL(C1,0)>AMT THEN /*CASH*/
C1:=C1-AMT;
SELECT ACCOUNT_CODE INTO ACC1 FROM SUB.MASTER WHERE PAY_CODE=2;
INSERT INTO ACC(AMOUNT_TD,ACC_CODE,EN_DATE,FO_TYPE,PART) VALUES(AMT,ACC1,SYSDATE,'JV','CASH
PERCENTAGE FOR '||45457);
STANDARD.COMMIT;STANDARD.COMMIT;STANDARD.COMMIT;
UPDATE FOOD.MEMBER_DET SET AMOUNT=C1 WHERE USER_ID=UIDAND C_COD=2;
STANDARD.COMMIT;STANDARD.COMMIT;STANDARD.COMMIT;
END IF;
end;the values receiving in insert statement is correct values.
how to resolve this?
Thanks skud...Check for too many rows or no data found exception.
And also check the number of rows either inserted or updated.
Something like this:
create or replace PROCEDURE PAYMENT(AMT NUMBER,UID NUMBER) IS
AMT1 NUMBER;
AMT NUMBER;
PD VARCHAR2(100);
C1 NUMBER;
PER NUMBER;
ACC1 VARCHAR2(15);
CF NUMBER;
CRF NUMBER;
ACC2 VARCHAR2(15);
begin
begin
SELECT PAY_DESC
INTO PD
FROM SUB.PAYMENT_TY
WHERE ORD=0;
exception
when too_many_rows then
dbms_output.put_line('Too many rows in first SELECT');
when no_data_found then
dbms_output.put_line('No data found in first select');
end;
begin
SELECT NVL(AMOUNT,0)
INTO C1
FROM FOOD.MEMBER
WHERE LTRIM(RTRIM(UPPER(NAME))) LIKE LTRIM(RTRIM(UPPER(PD)))
AND USER_ID=UID;
exception
when too_many_rows then
dbms_output.put_line('Too many rows in second SELECT');
when no_data_found then
dbms_output.put_line('No data found in second select');
end;
IF NVL(C1,0)>AMT THEN /*CASH*/
C1:=C1-AMT;
begin
SELECT ACCOUNT_CODE
INTO ACC1
FROM SUB.MASTER
WHERE PAY_CODE=2;
exception
when too_many_rows then
dbms_output.put_line('Too many rows in third SELECT');
when no_data_found then
dbms_output.put_line('No data found in third select');
end;
INSERT INTO ACC(AMOUNT_TD,ACC_CODE,EN_DATE,FO_TYPE,PART) VALUES(AMT,ACC1,SYSDATE,'JV','CASH PERCENTAGE FOR '||45457);
dbms_output.put_line('Insert ' || sql%rowcount);
COMMIT;
UPDATE FOOD.MEMBER_DET SET AMOUNT=C1 WHERE USER_ID=UIDAND C_COD=2;
dbms_output.put_line('Update ' || sql%rowcount);
commit;
END IF;
end;
/UNTESTED!! -
ORA-24338: statement handle not executed
Hi,
My front end programming platform is .NET. Oracle DataBase is 10g.
I have written this package:
CREATE OR REPLACE package body USER_NAME.PACKAGE_TEST1 as
procedure getname(id1 number,tb_cursor out md_cursor)
as
begin
open tb_cursor for select name from testtable1 where id1=id;
close tb_cursor;
end getname;
end package_test1;In the front end i am using DataReader to fetch data.
But while Executing reader an error occurs that is "ORA-24338: statement handle not executed".
But when i remove "close tb_cursor" programm runs successfully.
What is the reason for that error ?user12222356 wrote:
Tubby wrote:
A ref cursor is nothing more than a pointer to a statement (query).
So no, you do not want to make 1000 procedure calls. You want your ref cursor to be opened for a query that contains 1000 rows. The client calls your procedure ONE TIME and processes the entirety of the ref cursor (1000 rows), then closes the cursor that your procedure so graciously opened for them.But according to .NET(my front end platform) documentation DataReader fetches data from database row by row .each row at a time.That means when the procedure was first called REF CURSOR was opened and was open till all data are fetched.Means at the begining itself query was executed and all data was fetched and stored temporarily in the database, and then DataReader fetched those data row by row..i.e., after first call to procedure only fetching of data is done. NO opening,NO closing ,NO select query execution (that was referenced by REf CURSOR). And when all rows are fetched that open cursor is closed . Is my concept right here ?YOU opened the cursor (in your procedure).
The select query execution IS the ref cursor being processed by your DataReader.
The data is not temporarily stored in the database ... it persists there (unless someone deletes it) ... so that statement wasn't really correct. DataReader would just be reading the rows from the database (via the ref cursor)
I would assume DataReader will close the cursor for you, but i really don't know ... you'd have to ask a .not person about that. -
Err 62007: SQL Error: 99999 ORA-24338: Statement Handle not Executed
Hi,
I am facing a problem while adding a new parameter n my JSP Report JDBC query based on a ref-cursor from a stored procedure define in a package in database.
No problem at database level, I have added the new parameter in package specification and Package body for that procedure and compile my package, it complies without any error and warning.
but when I open the report and add parameter in the report JDBC query window, then it is generating a error message,
"Err 62007: SQL Error: 99999 ORA-24338: Statement Handle not Executed "
and I am unable to add the new parameter in report.
e.g.
Actual which was working is:
My-package.My-procedure(:P1,:P2,:P3 ,:P4,:P5,:P6,:P7)
I want to do this:
My-package.My-procedure(:P1,:P2,:P3 ,:P4,:P5,:P6,:P7,:P8)
but unable to do due to this error message:
("Err 62007: SQL Error: 99999 ORA-24338: Statement Handle not Executed ")
Reports Builder 10g:
Database 10g:
Operating system windows XP:
using JDBC Query base on ref-cursor coming from the stored procedure define in the Package.
Regards,
Khanand compile my package, it complies without any error and warning.That doesn't mean anything in this case. You are getting a runtime error, not a compilation error. The error is coming when you execute your procedure.
Did you test your modified procedure in sqlplus or SQL Developer? -
ORA-24338: statement handle not executed -- error in returning refcursor
My packaged procedure has Ref cursor as out variable.
Calling the packaged procedure from Cognos 8. while trying to access the packaged procedure , getting the below error.
ORA-24338: statement handle not executed
Please provide a solution...Welcome to the forum!
Whenever you post provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
Confirm that the procedure works properly when called from sql*plus.
For example here is some code that tests a package procedure I have in the SCOTT schema
SET SERVEROUTPUT ON SIZE 1000000
DECLARE
l_cursor test_refcursor_pkg.my_ref_cursor;
l_ename emp.ename%TYPE;
l_empno emp.empno%TYPE;
BEGIN
test_refcursor_pkg.test_proc (l_cursor);
LOOP
FETCH l_cursor
INTO l_empno, l_ename;
EXIT WHEN l_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(l_ename || ' | ' || l_empno);
END LOOP;
CLOSE l_cursor;
END;
/ -
Statement handle not executed error
Hi,
I have a package which have a statement as follows.
OPEN p_out_provider_w_POSAccess FOR
SELECT DISTINCT claim.cert_no, claim.rec_code,
prov.ghi_prov_num, prov.irs_number tax_id,
prov.full_name, prov.lastname, prov.firstname
FROM hmo.hmo_medical_claim claim,
ipd2.i_provider prov,
ipd2.i_provider_top pt,
ops_arw.phr_top top,
ops_arw.provider_pin pin
WHERE claim.cert_no =hmo_conv_num_to_letter (p_in_cert_no)
AND claim.rec_code = p_in_rec_code
AND claim.ghi_prov_num = prov.ghi_prov_num
AND claim.ghi_prov_num = pt.ghi_prov_num
AND claim.ghi_prov_num = pin.ghi_prov_num
AND pt.top_code = top.top_code
ORDER BY prov.lastname, prov.firstname;
when I execute the package ,I get
dweb1:ops_arw> PRINT p_out_provider_w_POSAccess
ERROR:
ORA-24338: statement handle not executed
SP2-0625: Error printing variable "p_out_provider_w_POSAccess"Thanksuser11253970 wrote:
No I am not closing it.Just now I noticed that when I input values which are in Database it returns the result without any failure.But when I try to input values which are not in database ,Instead of returning zero rows it gives the error message.Then your SP logic branches in such way that values which are not in the database bypass open cursor statement:
SQL> create or replace
2 procedure p1(p_cur in out sys_refcursor,p_ind number)
3 is
4 begin
5 if p_ind = 1
6 then
7 open p_cur for select ename from emp where deptno = 10;
8 end if;
9 end;
10 /
Procedure created.
SQL> exec p1(:p_cur,1)
PL/SQL procedure successfully completed.
SQL> print p_cur
ENAME
CLARK
KING
MILLER
SQL> exec p1(:p_cur,0)
PL/SQL procedure successfully completed.
SQL> print p_cur
ERROR:
ORA-24338: statement handle not executed
SP2-0625: Error printing variable "p_cur"
SQL> SY. -
I have problems with photoshop CS5, it is not executed, it remains looking for plugi
I have problems with photoshop CS5, it is not executed, it remains looking for plugin
Please read these and proceed accordingly (restoring Preferences after making sure all customized presets like Actions, Patterns, Brushes etc. have been saved might be of special interest):
http://blogs.adobe.com/crawlspace/2012/07/photoshop-basic-troubleshooting-steps-to-fix-mos t-issues.html
http://forums.adobe.com/docs/DOC-2325 -
How can I see error when execute UPDATE with BULK COLLECT
Hi
I have a code
CURSOR c_renov_eleg IS
SELECT t2.ROWID
FROM mytable t2
WHERE BLA BLA BLA
OPEN c_renov_eleg;
LOOP
FETCH c_renov_eleg BULK COLLECT
INTO w_rowid LIMIT 1000;
FORALL i IN 1 .. w_rowid.COUNT
UPDATE mytable
SET id_baixa_elegibilidade = K_SCNOB_BXA_RENOVACAO,
column01 = arr_ciclo(1),
dt_ultima_atualizacao = SYSDATE,
cd_usuario_atualizacao = USER
WHERE ROWID = w_rowid(i);
COMMIT;
EXIT WHEN c_renov_eleg%NOTFOUND;
END LOOP;How can I to sse when and where have some error ? , in Exception return what record ?How can I to sse when and where have some error
?Have a look at
[url=http://download.oracle.com/docs/cd/B28359_01/appd
ev.111/b28370/tuning.htm#i49099]Handling FORALL
Exceptions (%BULK_EXCEPTIONS Attribute).btw. just never ever commit in a for loop ;)
(Tubby is just too fast ;))
Hi , thank all
btw. just never ever commit in a for loopWhen I must to COMMIT using BULK COLLECT ? -
Problem with Bulk Collect ... FORALL
I've written following code to bulk collect records from a cursor into a collection and insert it into a table using FORALL loop
OPEN x;
LOOP
FETCH x BULK COLLECT INTO v_collection LIMIT 1000;
FORALL i IN 1..v_collection.count
INSERT INTO tablename(column1, column2) VALUES(v_collection(i).val1, v_collection(i).val2);
COMMIT;
EXIT WHEN x%NOTFOUND;
END LOOP;I have verified that query which is executed by cursor returns records but when my procedure is executed the insert statement inside the FORALL loop never executes. Am I missing something over here?
Regards,
FahadYes, the cursor is returning a row.
I've found the solution myself. There was a trigger which was deleting data on commit. Due to this, the records were not inserting. -
Problem with BULK COLLECT with million rows - Oracle 9.0.1.4
We have a requirement where are supposed to load 58 millions of rows into a FACT Table in our DATA WAREHOUSE. We initially planned to use Oracle Warehouse Builder but due to performance reasons, decided to write custom code. We wrote a custome procedure which opens a simple cursor and reads all the 58 million rows from the SOURCE Table and in a loop processes the rows and inserts the records into a TARGET Table. The logic works fine but it took 20hrs to complete the load.
We then tried to leverage the BULK COLLECT and FORALL and PARALLEL options and modified our PL/SQL code completely to reflect these. Our code looks very simple.
1. We declared PL/SQL BINARY_INDEXed Tables to store the data in memory.
2. We used BULK COLLECT into FETCH the data.
3. We used FORALL statement while inserting the data.
We did not introduce any of our transformation logic yet.
We tried with the 600,000 records first and it completed in 1 min and 29 sec with no problems. We then doubled the no. of rows to 1.2 million and the program crashed with the following error:
ERROR at line 1:
ORA-04030: out of process memory when trying to allocate 16408 bytes (koh-kghu
call ,pmucalm coll)
ORA-06512: at "VVA.BULKLOAD", line 66
ORA-06512: at line 1
We got the same error even with 1 million rows.
We do have the following configuration:
SGA - 8.2 GB
PGA
- Aggregate Target - 3GB
- Current Allocated - 439444KB (439 MB)
- Maximum allocated - 2695753 KB (2.6 GB)
Temp Table Space - 60.9 GB (Total)
- 20 GB (Available approximately)
I think we do have more than enough memory to process the 1 million rows!!
Also, some times the same program results in the following error:
SQL> exec bulkload
BEGIN bulkload; END;
ERROR at line 1:
ORA-03113: end-of-file on communication channel
We did not even attempt the full load. Also, we are not using the PARALLEL option yet.
Are we hitting any bug here? Or PL/SQL is not capable of mass loads? I would appreciate any thoughts on this?
Thanks,
Haranadh
Following is the code:
set echo off
set timing on
create or replace procedure bulkload as
-- SOURCE --
TYPE src_cpd_dt IS TABLE OF ima_ama_acct.cpd_dt%TYPE;
TYPE src_acqr_ctry_cd IS TABLE OF ima_ama_acct.acqr_ctry_cd%TYPE;
TYPE src_acqr_pcr_ctry_cd IS TABLE OF ima_ama_acct.acqr_pcr_ctry_cd%TYPE;
TYPE src_issr_bin IS TABLE OF ima_ama_acct.issr_bin%TYPE;
TYPE src_mrch_locn_ref_id IS TABLE OF ima_ama_acct.mrch_locn_ref_id%TYPE;
TYPE src_ntwrk_id IS TABLE OF ima_ama_acct.ntwrk_id%TYPE;
TYPE src_stip_advc_cd IS TABLE OF ima_ama_acct.stip_advc_cd%TYPE;
TYPE src_authn_resp_cd IS TABLE OF ima_ama_acct.authn_resp_cd%TYPE;
TYPE src_authn_actvy_cd IS TABLE OF ima_ama_acct.authn_actvy_cd%TYPE;
TYPE src_resp_tm_id IS TABLE OF ima_ama_acct.resp_tm_id%TYPE;
TYPE src_mrch_ref_id IS TABLE OF ima_ama_acct.mrch_ref_id%TYPE;
TYPE src_issr_pcr IS TABLE OF ima_ama_acct.issr_pcr%TYPE;
TYPE src_issr_ctry_cd IS TABLE OF ima_ama_acct.issr_ctry_cd%TYPE;
TYPE src_acct_num IS TABLE OF ima_ama_acct.acct_num%TYPE;
TYPE src_tran_cnt IS TABLE OF ima_ama_acct.tran_cnt%TYPE;
TYPE src_usd_tran_amt IS TABLE OF ima_ama_acct.usd_tran_amt%TYPE;
src_cpd_dt_array src_cpd_dt;
src_acqr_ctry_cd_array src_acqr_ctry_cd;
src_acqr_pcr_ctry_cd_array src_acqr_pcr_ctry_cd;
src_issr_bin_array src_issr_bin;
src_mrch_locn_ref_id_array src_mrch_locn_ref_id;
src_ntwrk_id_array src_ntwrk_id;
src_stip_advc_cd_array src_stip_advc_cd;
src_authn_resp_cd_array src_authn_resp_cd;
src_authn_actvy_cd_array src_authn_actvy_cd;
src_resp_tm_id_array src_resp_tm_id;
src_mrch_ref_id_array src_mrch_ref_id;
src_issr_pcr_array src_issr_pcr;
src_issr_ctry_cd_array src_issr_ctry_cd;
src_acct_num_array src_acct_num;
src_tran_cnt_array src_tran_cnt;
src_usd_tran_amt_array src_usd_tran_amt;
j number := 1;
CURSOR c1 IS
SELECT
cpd_dt,
acqr_ctry_cd ,
acqr_pcr_ctry_cd,
issr_bin,
mrch_locn_ref_id,
ntwrk_id,
stip_advc_cd,
authn_resp_cd,
authn_actvy_cd,
resp_tm_id,
mrch_ref_id,
issr_pcr,
issr_ctry_cd,
acct_num,
tran_cnt,
usd_tran_amt
FROM ima_ama_acct ima_ama_acct
ORDER BY issr_bin;
BEGIN
OPEN c1;
FETCH c1 bulk collect into
src_cpd_dt_array ,
src_acqr_ctry_cd_array ,
src_acqr_pcr_ctry_cd_array,
src_issr_bin_array ,
src_mrch_locn_ref_id_array,
src_ntwrk_id_array ,
src_stip_advc_cd_array ,
src_authn_resp_cd_array ,
src_authn_actvy_cd_array ,
src_resp_tm_id_array ,
src_mrch_ref_id_array ,
src_issr_pcr_array ,
src_issr_ctry_cd_array ,
src_acct_num_array ,
src_tran_cnt_array ,
src_usd_tran_amt_array ;
CLOSE C1;
FORALL j in 1 .. src_cpd_dt_array.count
INSERT INTO ima_dly_acct (
CPD_DT,
ACQR_CTRY_CD,
ACQR_TIER_CD,
ACQR_PCR_CTRY_CD,
ACQR_PCR_TIER_CD,
ISSR_BIN,
OWNR_BUS_ID,
USER_BUS_ID,
MRCH_LOCN_REF_ID,
NTWRK_ID,
STIP_ADVC_CD,
AUTHN_RESP_CD,
AUTHN_ACTVY_CD,
RESP_TM_ID,
PROD_REF_ID,
MRCH_REF_ID,
ISSR_PCR,
ISSR_CTRY_CD,
ACCT_NUM,
TRAN_CNT,
USD_TRAN_AMT)
VALUES (
src_cpd_dt_array(j),
src_acqr_ctry_cd_array(j),
null,
src_acqr_pcr_ctry_cd_array(j),
null,
src_issr_bin_array(j),
null,
null,
src_mrch_locn_ref_id_array(j),
src_ntwrk_id_array(j),
src_stip_advc_cd_array(j),
src_authn_resp_cd_array(j),
src_authn_actvy_cd_array(j),
src_resp_tm_id_array(j),
null,
src_mrch_ref_id_array(j),
src_issr_pcr_array(j),
src_issr_ctry_cd_array(j),
src_acct_num_array(j),
src_tran_cnt_array(j),
src_usd_tran_amt_array(j));
COMMIT;
END bulkload;
SHOW ERRORS
-----------------------------------------------------------------------------do you have a unique key available in the rows you are fetching?
It seems a cursor with 20 million rows that is as wide as all the columnsyou want to work with is a lot of memory for the server to use at once. You may be able to do this with parallel processing (dop over 8) and a lot of memory for the warehouse box (and the box you are extracting data from)...but is this the most efficient (and thereby fastest) way to do it?
What if you used a cursor to select a unique key only, and then during the cursor loop fetch each record, transform it, and insert it into the target?
Its a different way to do a lot at once, but it cuts down on the overall memory overhead for the process.
I know this isnt as elegant as a single insert to do it all at once, but sometimes trimming a process down so it takes less resources at any given moment is much faster than trying to do the whole thing at once.
My solution is probably biased by transaction systems, so I would be interested in what the data warehouse community thinks of this.
For example:
source table my_transactions (tx_seq_id number, tx_fact1 varchar2(10), tx_fact2 varchar2(20), tx_fact3 number, ...)
select a cursor of tx_seq_id only (even at 20 million rows this is not much)
you could then either use a for loop or even bulk collect into a plsql collection or table
then process individually like this:
procedure process_a_tx(p_tx_seq_id in number)
is
rTX my_transactions%rowtype;
begin
select * into rTX from my_transactions where tx_seq_id = p_tx_seq_id;
--modify values as needed
insert into my_target(a, b, c) values (rtx.fact_1, rtx.fact2, rtx.fact3);
commit;
exception
when others
rollback;
--write to a log or raise and exception
end process_a_tx;
procedure collect_tx
is
cursor tx is
select tx_seq_id from my_transactions;
begin
for rTx in cTx loop
process_a_tx(rtx.tx_seq_id);
end loop;
end collect_tx; -
Opening two cursors using open cursor with bulk collect on colections ..
Is it possible to have the implementatiion of using bulk collect with collections using two open cursors ..
first c1
second c2
open c1
loop
open c2
loop
end loop
close c2
end loop;
close c1
what i found is for every outer loop of cursor c1 , cursor c2 is open and closed for every record.
is this willl imporove the performace .?
EXAMPLE:-
NOTE: The relatoin between finc and minc is one to many ..finc is parent and minc is child
function chk_notnull_blank ( colname IN number ) return number is
BEGIN
if ( colname is NOT NULL and colname not in ( -8E14, -7E14, -6E14, -5E14, -4E14, -3E14, -2E14, -1E14, -1E9 )) then
RETURN colname ;
else
RETURN 0;
end if;
END chk_notnull_blank;
procedure Proc_AnnualFmlyTotIncSummary is
CURSOR c_cur_finc IS SELECT FAMID FROM FINC ;
CURSOR c_cur_minc IS SELECT FAMID, MEMBNO , ANFEDTX, ANGOVRTX, ANPRVPNX, ANRRDEDX, ANSLTX, SALARYX, SALARYBX, NONFARMX, NONFRMBX , FARMINCX, FRMINCBX, RRRETIRX, RRRETRBX, SOCRRX, INDRETX, JSSDEDX, SSIX, SSIBX from MINC minc WHERE FAMID IN ( SELECT FAMID FROM FINC finc WHERE minc.FAMID = finc.FAMID );
v_tot_fsalaryx number := 0;
v_tot_fnonfrmx number := 0;
v_tot_ffrmincx number := 0;
v_tot_frretirx number := 0;
v_tot_findretx number := 0;
v_tot_fjssdedx number := 0;
v_tot_fssix number := 0;
v_temp_sum_fsalaryx number := 0;
v_temp_sum_fnonfrmx number := 0;
v_temp_sum_ffrmincx number := 0;
v_temp_sum_frretirx number := 0;
v_temp_sum_findretx number := 0;
v_temp_sum_fjssdedx number := 0;
v_temp_sum_fssix number := 0;
TYPE minc_rec IS RECORD (FAMID MINC.FAMID%TYPE, MEMBNO MINC.MEMBNO%TYPE , ANFEDTX MINC.ANFEDTX%TYPE, ANGOVRTX MINC.ANGOVRTX%TYPE , ANPRVPNX MINC.ANPRVPNX%TYPE , ANRRDEDX MINC.ANRRDEDX%TYPE , ANSLTX MINC.ANSLTX%TYPE, SALARYX MINC.SALARYX%TYPE , SALARYBX MINC.SALARYBX%TYPE , NONFARMX MINC.NONFARMX%TYPE , NONFRMBX MINC.NONFRMBX%TYPE, FARMINCX MINC.FARMINCX%TYPE , FRMINCBX MINC.FRMINCBX%TYPE , RRRETIRX MINC.RRRETIRX%TYPE , RRRETRBX MINC.RRRETRBX%TYPE, SOCRRX MINC.SOCRRX%TYPE , INDRETX MINC.INDRETX%TYPE , JSSDEDX MINC.JSSDEDX%TYPE , SSIX MINC.SSIX%TYPE , SSIBX MINC.SSIBX%TYPE );
v_flag_boolean boolean := false;
v_famid number ;
v_stmt varchar2(3200) ;
v_limit number := 50;
v_temp_FAMTFEDX number := 0 ;
v_temp_FGOVRETX number := 0 ;
v_temp_FPRIVPENX number := 0 ;
v_temp_FRRDEDX number := 0 ;
v_temp_FSLTAXX number := 0 ;
v_temp_FSALARYX number := 0 ;
v_temp_FNONFRMX number := 0 ;
v_temp_FFRMINCX number := 0 ;
v_temp_FRRETIRX number := 0 ;
v_temp_FINDRETX number := 0 ;
v_temp_FJSSDEDX number := 0 ;
v_temp_FSSIX number := 0 ;
BEGIN
OPEN c_cur_finc ;
LOOP
FETCH c_cur_finc BULK COLLECT INTO famid_type_tbl LIMIT v_limit;
EXIT WHEN famid_type_tbl.COUNT = 0;
FOR i in famid_type_tbl.FIRST..famid_type_tbl.LAST
LOOP
OPEN c_cur_minc ;
LOOP
FETCH c_cur_minc BULK COLLECT INTO minc_rec_type_tbl LIMIT v_limit;
EXIT WHEN minc_rec_type_tbl.COUNT = 0;
FOR j IN minc_rec_type_tbl.FIRST..minc_rec_type_tbl.LAST
LOOP
if ( famid_type_tbl(i) = minc_rec_type_tbl(j).FAMID ) THEN
v_temp_FAMTFEDX := v_temp_FAMTFEDX + chk_notnull_blank(minc_rec_type_tbl(j).ANFEDTX );
v_temp_FGOVRETX := v_temp_FGOVRETX + chk_notnull_blank(minc_rec_type_tbl(j).ANGOVRTX);
v_temp_FPRIPENX := v_temp_FPRIPENX + chk_notnull_blank(minc_rec_type_tbl(j).ANPRVPNX);
v_temp_FRRDEDX := v_temp_FRRDEDX + chk_notnull_blank(minc_rec_type_tbl(j).ANRRDEDX);
v_temp_FSLTAXX := v_temp_FSLTAXX + chk_notnull_blank(minc_rec_type_tbl(j).ANSLTX );
v_temp_FSALARYX := v_temp_FSALARYX + chk_notnull_blank(minc_rec_type_tbl(j).SALARYX ) + chk_notnull_blank(minc_rec_type_tbl(j).SALARYBX);
v_temp_FNONFRMX := v_temp_FNONFRMX + chk_notnull_blank(minc_rec_type_tbl(j).NONFARMX) + chk_notnull_blank(minc_rec_type_tbl(j).NONFRMBX);
v_temp_FFRMINCX := v_temp_FFRMINCX + chk_notnull_blank(minc_rec_type_tbl(j).FARMINCX) + chk_notnull_blank(minc_rec_type_tbl(j).FRMINCBX );
v_temp_FRRETIRX := v_temp_FRRETIRX + chk_notnull_blank(minc_rec_type_tbl(j).RRRETIRX) + chk_notnull_blank(minc_rec_type_tbl(j).RRRETRBX ) + chk_notnull_blank(minc_rec_type_tbl(j).SOCRRX);
v_temp_FINDREXT := v_temp_FINDRETX + chk_notnull_blank(minc_rec_type_tbl(j).INDRETX);
v_temp_FJSSDEDX := v_temp_FJSSDEDX + chk_notnull_blank(minc_rec_type_tbl(j).JSSDEDX);
v_temp_FSSIX := v_temp_FSSIX + chk_notnull_blank(minc_rec_type_tbl(j).SSIX ) + chk_notnull_blank(minc_rec_type_tbl(j).SSIBX);
END IF;
END LOOP;
END LOOP ;
CLOSE c_cur_minc;
UPDATE FINC SET FAMTFEDX = v_temp_FAMTFEDX WHERE FAMID = famid_type_tbl(i);
END LOOP;
END LOOP;
CLOSE c_cur_finc;
END;
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
v_err_code := SQLCODE;
v_err_msg := substr(SQLERRM, 1, 200);
INSERT INTO audit_table (error_number, error_message) VALUES (v_err_code, v_err_msg);
error_logging(p_error_code => substr(sqlerrm,1,9), p_error_message => substr(sqlerrm,12), p_package =>'PKG_FCI_APP',p_procedure => 'Proc_Annual_Deductions_FromPay ' , p_location => v_location);
end Proc_AnnualFmlyTotIncSummary ;
Is the proga efficient and free from compilation errors ..?
thanks/kumar
Edited by: kumar73 on Sep 22, 2010 12:48 PMfunction chk_notnull_blank ( colname IN number ) return number is Maybe this function should have its own forum:
how to use case in this program
Re: how to declare a formal parameter in a function of type record and access ?
Re: how to define a function with table type parameter
Re: creation of db trigger with error ..
Re: How to write a trigger for the below scenario
how to improve the code using advanced methods
yours advice in improving the coding ..
How to use bulk in multiple cursors !!
;-)
Maybe you are looking for
-
After updating my iPhone4s to the lastest update my photostream stopped updated onto my comuter. From my phone it looks like pictures have been moved into the photostream folder... but they are not showing up on my computer. Help! I have signed out
-
How to use structure in ABAP program
I developing a report in smartforms but i want some fields to be display on the report but unable to find the relvent table as the field is show in structure.i can not find the actual table . is there any specfic way to find the table .or is there an
-
EBusiness Suite User "Auto-provisioning" and "Self-Request" Problem
I have two types of OIM User, Staff and Contingent Staff (Role = Full-Time) Contingent (Role = Contractor / Role = Consultant) Resource Object: eBusiness Suite User Here's my RO configuration: Auto Pre-populate: true Allow Multiple: true Self Request
-
Export Sales Currency Conversion in INR
Hi All, Export Sales Order In the Export Sales Order Item Conditions,Condition Value (3rd column from the left) & Condition Currency (2nd column from the left) is Blank.Condition value should be converted in Rs. & Condition Currency should INR. What
-
Question to GUI 710 Patch-Level 17
Hi everyone,<br><br> so when I update my GUI installation server with PL 17 it says I have to reboot my server.<br> Is this <b>absolutely neccessary</b> so the users will get their update notification or gettin' the whole update process to work?<br><