Cannot figure out why "ORA-01000 Maximum open cursors" is shown...
Hello there ...
I am programming a PL/SQL Code that is throwing 0RA-01000 Maximum Open Cursors Exceeded.
Having already read quite a lot about ORA-01000 errors, I know I should be closing cursors, and have already tried setting OPEN_CURSORS parameter to a high number (1000).
I declared a lot of procedures in my pl/sql, each of which uses one cursor since i am working with a non-Oracle table linked by ODBC ... and each procedure sometimes does thousands of inserts -- but all WITHIN the explicit cursors. The explicit cursors are not declared within each loop.
I already checked the code many times, and made sure all open cursors are closed. In addition, I also verified the numberopen cursors generated by the PL/SQL by running the following SQL after every procedure i run... and outputting it... and it appears the value just keeps on increasing, even though I had explicitly closed all the cursors in all the earlier procedures.
What is funny is that the most number of cursors reported by the code below only hits 150+ cursors. Nowhere near the 1000 open_cursors limit per session.
select a.value into strtxt --, b.name
from v$mystat a, v$statname b
where a.statistic# = b.statistic#
and a.statistic#= 3;When I run the procedures separately though, all the procedures run smoothly (even when I had not yet updated the open_cursors parameter).
I was thinking of the following, but maybe you have some other ideas?
Does this have anything to do with my procedures not being stored procedures?
Or should i be committing records within my procedures instead of out of it?
I really have run into a wall and would really appreciate any tips or helps on this. Thanks in advance!
My basic pl/sql code looks like below. I did not give the actual details cause it will be too long (up to 5000 lines).
DECLARE
PROCEDURE proc1
IS
CURSOR cur_hca
is
select ...from..where;
TYPE cur_hca_fetch
Is TABLE OF cur_hca%ROWTYPE
INDEX BY PLS_INTEGER;
temp_collect cur_hca_fetch;
BEGIN
open cur_hca; --cur_hca is the cursor name.
--i use exactly the same cursor name in the other procedures
loop
fetch cur_hca bulk collect into temp_collect LIMIT 1000;
exit when temp_collect.count=0
for indx in 1 .. temp_collect.count
loop
...run some sql
end loop;
end loop;
close cur_hca;
END proc1;
PROCEDURE proc2 --almost the same as above the only changes are the query for the
-- cursor and the sql that happens for each record
IS
BEGIN
open cur_hca; --cur_hca is my cursor name
loop
end loop;
close cur_hca;
END proc2;
... up to 40 other very similar procedures
BEGIN
proc1;
commit;
select a.value into strtxt
from v$mystat a, v$statname b
where a.statistic# = b.statistic#
and a.statistic#= 3;
DBMS_OUTPUT.PUT_LINE('Number of Cursors After STATUSproc1: ' || strtxt);
proc2;
commit;
select a.value into strtxt
from v$mystat a, v$statname b
where a.statistic# = b.statistic#
and a.statistic#= 3;
DBMS_OUTPUT.PUT_LINE('Number of Cursors After STATUSproc2: ' || strtxt);
... 40 other procedures
END;Edited by: user4872285 on May 6, 2013 6:49 PM
Edited by: user4872285 on May 6, 2013 7:01 PM
Edited by: user4872285 on May 6, 2013 8:02 PM
Edited by: user4872285 on May 6, 2013 8:03 PM
PL/SQL code usually leaks reference cursors and DBMS_SQL cursors - as the ref cursor/DBMS_SQL interface used has a global (session static) scope.
PL/SQL has an intelligent garbage collector that will close local implicit and explicit cursors, when the cursor variable goes out of scope.
If you define an explicit cursor globally (package interface), then it can only be opened once. The 2nd attempt results in a ORA-06511: PL/SQL: cursor already open exception. So code cannot leak explicit cursors as code cannot reopen an existing opened explicit cursor.
I have never seen Oracle leaking cursors internally. So I would be hesitant to call what you are seeing, a bug. If your code is using explicit cursors (even static/global ones), your code cannot leak these cursors, even if your code does not close them. Worse case - the cursor remains open, however new copies cannot be created while it is open.
So I think your are looking at the wrong thing - explicit cursors. These are not the cursors that are leaking in my view (simply because code cannot reuse and open an already opened explicit cursor). Here is an example:
SQL> show parameter cursors
NAME TYPE VALUE
open_cursors integer 300
session_cached_cursors integer 50
// procedure that seems to "leak" an explicit cursor handle
// as it does not explicitly closes the handle
SQL> create or replace procedure CursorUse is
2 cursor c is select e.* from emp e;
3 empRow emp%RowType;
4 begin
5 open c;
6 fetch c into empRow;
7 --// not closing explicit cursor handle
8 --// and going out-of-scope
9 end;
10 /
Procedure created.
// current session stats
SQL> select b.name, a.value from v$mystat a, v$statname b where a.statistic# = b.statistic# and b.name like '%open%cursor%';
NAME VALUE
opened cursors cumulative 91
opened cursors current 2
// execute proc that "leaks" a cursor, 10000 times
SQL> begin
2 for i in 1..10000 loop
3 CursorUse;
4 end loop;
5 end;
6 /
PL/SQL procedure successfully completed.
// no errors due to cursor leakage
// session stats: no cursor leakage occurred as
// PL/SQL's garbage collector cleaned (and closed)
// cursor handles when these became out-of-scope
SQL> select b.name, a.value from v$mystat a, v$statname b where a.statistic# = b.statistic# and b.name like '%open%cursor%';
NAME VALUE
opened cursors cumulative 10,095
opened cursors current 2
SQL> So the cursor leakage you are seeing is caused by something else... so what else is part of the code, or the session, that you have not yet mentioned?
Similar Messages
-
ORA-01000: maximum open cursors exceeded (please help / JDBC guru needed)
ORA-01000: maximum open cursors exceeded
I am getting this error when trying to execute 2,500 Sql DDL statements. I am executing the statement with:
public boolean execute(String sql) ( like stmt.execute(sql); )
After each execute() I close the statement ( like stmt.close() )
I tried taking this a step further and decided to close and reopen the database connection after every 100 Sql statements processed and I still get this exception when continuing.
ORA-01000: maximum open cursors exceeded
Any help will be greatly appreciated. I need to figure how to close the cursors or how to finish processing all 2,500 statements. I do not have control over the init.ora file and can not increase the max cursors. I hope to figure out how to close the cursors so that no tweaking of the init.ora file is needed.
ChrisTDWhy dont you allocate dukes for this problem ???
am getting this error when trying to execute 2,500 Sql DDL statements. I am executing the statement with:
public boolean execute(String sql) ( like stmt.execute(sql); )
After each execute() I close the statement ( like stmt.close() )
What kind of DDL is that? are you using any cursor operations to fetch the data? What kind of query does this sql parameter contain?
Look there is only 3 solutions for this kind of problem.
1) shutdown the database and restart it.
I dont think closing connection will shutdown the database as you
told.
2) shutdown the database access init.ora and increase the
OPEN_CURSORS and then restart it.
You told that you dont have access to init.ora.
3) close every cursor that you open.(Probably you are not closing the cursor once you fetch the data). -
ORA-01000: maximum open cursors exceeded with Thin and OCI
Hi I have this ERROR :
ORA-01000: maximum open cursors exceeded
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at line 1
and all the connections show this error, I run the weblogic.Admin RESET_POOL utility
and the problem are fixed !!
Why show this error ?
why with RESET_POOL utility resolve the problem ?
the Oracle Version is Oracle 8.1.7.0 32bits on Solaris 8Mitesh:
I using testConnOnReserve=true and testReleasedConnections=true specify testTableName
when the errors appear , but increse the open_cusror value to 1200, i think is
not the solution, because the DB and Stored Procedure is used by Cold Fusion ,
is the same Application, in Cold Fusion not show this error u other errors with
380 users on the application.
I check to increse the open_cusror and test the application.
thanks
Roberto
Mitesh Patel <[email protected]> wrote:
You should do couple of things here.
First of all you can increse the open_cusror value to 1200 if it is ok
with you.
Secondly, make sure you are using testConnOnReserve=true and specify
testTableNAme
in your config.xml for your connection pool defination.
Thanks,
Mitesh
Roberto Hernandez wrote:
Mitesh Patel,
WLS 6.1 sp3 on Solaris 8, in init.ora file
session_cached_cursors = 30 and Open_Cursors = 600
Any Idea to resolve the Error and not use manual RESET_POOL utility?
thanks
Mitesh Patel <[email protected]> wrote:
This is know bug from oracle.
XAResource.recover repeatedly returns the same set of in-doubt
Xids irrespective of the input flag. According to the XA spec, the
Transaction Manager should initially call XAResource.recover with
TMSTARTRSCAN and then call XAResource.recover with
TMNOFLAGS repeatedly until no Xids are returned. This Oracle
bug could lead to infinite recursion and subsequent running out
of Oracle cursors with error "ORA-01000: maximum open cursors
exceeded."
What version of weblogic are you using? What is value for max cursors
in init.ora file
in your dbserver?
Resets the named database ConnectionPool by shutting down and
reestablishing all the allocated connections. This method should
only be called when the connection pool is known to be in a bad
state, for example when the database has been restarted.
By using Reset you are cleaning all bad connections and associated
cursors
with it. That
is why it resolves ora-1000 for you.
Mitesh
Roberto Hernandez wrote:
Hi I have this ERROR :
ORA-01000: maximum open cursors exceeded
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at line 1
and all the connections show this error, I run the weblogic.Admin
RESET_POOL
utility
and the problem are fixed !!
Why show this error ?
why with RESET_POOL utility resolve the problem ?
the Oracle Version is Oracle 8.1.7.0 32bits on Solaris 8 -
Error During Delete Of Application:ORA-01000: maximum open cursors exceeded
Hello All.
I am using Apex version 3.2.0.00.27. I am trying to delete an existing application (App_ID 116). I am continually getting ORA-01000: maximum open cursors exceeded.
Prior to deleting this application, I attempted to, instead, import (that is, replace) this app with a previously saved Apex app (APP_ID 116). This previously saved app is also at the same version. I get the same error. At that point, I figured that I would delete the app and then import my previously saved app, only to get the same error.
I then attempted to import the previously saved app as a new APP_ID (256). This time, the app imported without error.
Does anyone know what is going on? Could it be that my existing app 116 is "corrupted" (whatever that means)? Why can't I delete or import over my existing app 116?
Any help would be appreciated.
Thank you.
EliePost Author: amr_foci
CA Forum: Information OnDemand
its a database related Error and it can be fixed
please check this link
http://publib.boulder.ibm.com/infocenter/wasinfo/v4r0/index.jsp?topic=/com.ibm.support.was.doc/html/EJB_Container/1040875.html
good luck
Amr -
Error ORA-01000: maximum open cursors exceeded
Why Oracle return this error. When I change the OPEN_CURSORS in init.ora from 100 to 1000 without this error.
I want to keep Minimum cursors value. How can I change the Java program ?
96 er_write_asp('W349','HK','50112','USD',3.99)
97 er_write_asp('W349','HK','10112','USD',5.22)
98 er_write_asp('W349','HK','60112','EUR',13.07)
99 er_write_asp('W349','HK','50112','USD',3.9)
100 er_write_asp('W349','HK','40112','USD',5.65)
101 er_write_asp('W349','HK','90112','USD',2.75)
java.sql.SQLException: ORA-01000: maximum open cursors exceeded
ORA-06512: at "POSTCAL.ER_WRITE_ASP", line 10
ORA-06512: at line 1
java Program list.
eric.leung 2003/12/02
set CLASSPATH include C:\Oracle\Ora81\jdbc\lib\classes12.zip
Purpose
===============
Read text file, write into Oracle Database
import java.io.*;
import java.util.StringTokenizer;
import java.sql.*;
import java.lang.*;
import java.math.BigDecimal;
import java.util.Date;
public class writeASP {
// Login Information
static String user = "x";
static String passwd = "x";
static String ip = "x";
static String getfile = "c:\\temp\\asp.csv";
public static void main(String[] args) throws IOException {
String line;
int i = 0;
int cnt = 0;
int port = 0;
Connection conn;
Statement stmt;
String query = "";
String strone = "";
String arry[] = {"","","","","","","","","","","","","","",
// start to connection
chkArgs(args);
FileReader inFile = new FileReader(getfile);
BufferedReader in = new BufferedReader(inFile);
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@" + ip + ":1521:lcdx",
user,passwd);
stmt = conn.createStatement();
while((line= in.readLine()) != null)
cnt = cnt + 1;
StringTokenizer mot = new StringTokenizer(line,",");
if (mot.countTokens() > 0) {
for (i = 0; 0 < mot.countTokens() ;i++) {
arry[i+1] = "";
arry[i] = mot.nextToken();
} /* for */
} /* if */
strone = arry[0].substring(0,1);
if (strone.equals("W")) {
//abc(arry);
query = "er_write_asp(" +
quote(arry[0],',') +
quote(arry[1],',') +
quote(arry[2],',') +
quote(arry[3],',') ;
query = query + arry[4] + ")";
System.out.println(cnt + " " + query);
CallableStatement cs = conn.prepareCall
("{call er_write_asp(?,?,?,?,?)}");
cs.setString(1,arry[0]);
cs.setString(2,arry[1]);
cs.setString(3,arry[2]);
cs.setString(4,arry[3]);
try {cs.setBigDecimal(5, new BigDecimal(arry[4])); } /*pur_cost */
catch(NumberFormatException e) {cs.setDouble(5,0);}
// System.out.println("Call string: "+ cs.getString());
boolean flag = cs.execute();
// ResultSet rs = cs.executeQuery();
// stmt.executeUpdate();
} /* if */
} /* while */
conn.close();
} /* try */
catch (Exception e) {
System.err.println(e.toString());
} /* Catch */
in.close();
} /* main */
public static void abc(String g[])
System.out.print(g[0] + " " + g[1] + " "
+ g[2] + " " + g[3] + " " + g[4] + " "
+ g[5] + " " + g[6] + " " + g[7] + " "
+ g[8] );
System.out.println();
private static String quote(String s)
return "'" + s + "'";
private static String quote(String s,char j)
return "'" + s + "'" + j;
public static void chkArgs(String[] args) {
for (int j=0 ; j < args.length;j++) {
if (args[j].trim().equals("-u")) {
if (j + 1 < args.length) {
try { user = args[j+1];}
catch ( Exception e) {}
} /* if */
if (args[j].trim().equals("-p")) {
if (j + 1 < args.length) {
try { passwd = args[j+1];}
catch ( Exception e) {}
} /* if */
if (args[j].trim().equals("-i")) {
if (j + 1 < args.length) {
try { ip = args[j+1];}
catch ( Exception e) {}
} /* if */
if (args[j].trim().equals("-f")) {
if (j + 1 < args.length) {
try { getfile = args[j+1];}
catch ( Exception e) {}
} /* if */
if (args[j].trim().equals("-h")) {
help();
System.exit(0);
} /* if */
} /* for */
} /* chkArgs */
public static void help() {
System.out.println("\nWrite ASP Price Version 1.0 2003/12/02\n");
System.out.println("Option:");
System.out.println("\t-i IP Address");
System.out.println("\t-u User name");
System.out.println("\t-p Password");
System.out.println("\t-f File name");
System.out.println("\t-h Help");
System.out.println("\nCall Oracle Stored Procdure");
System.out.println("er_write_ASP(,,,,)");
} /* help () */
} /* Class */Don't create a new callable statement each pass through the loop. Create it outside the loop and set the parameters & exec inside the loop. Close the resultset each time. Close statement after loop.
-
In java/jsp got Error,ORA-01000: maximum open cursors exceeded,
Dear ALL,
We are facing a problem of in java/jsp. ORA-01000: maximum open cursors exceeded,We are using referance Cursor for returing the Record in java file.
The Code is given below.
import java.sql.*;
import javax.sql.*;
import com.india.trade.dbConnection.*;
import oracle.jdbc.driver.*;
import java.util.Vector ;
public class IntRmsActivity
private static JDBCConnection instance = null;
private static Connection con = null;
private static CallableStatement stmt_admin_getadmins = null;
private static String str_admin_getadmins = "{ call Admin_conf.RMS_ADMIN_GETALLADMINS(?,?) }";
static
try
instance = new JDBCConnection();
con = instance.getConnection();
stmt_admin_getadmins = con.prepareCall(str_admin_getadmins);
}catch(Exception se){se.printStackTrace();}
public static Vector admin_getAdmins() throws Exception
checkconnection();
String message = null;
Vector v_admins = new Vector();
ResultSet rs_admins = null;
stmt_admin_getadmins.registerOutParameter(1 , OracleTypes.CURSOR);
stmt_admin_getadmins.registerOutParameter(2 , Types.VARCHAR);
stmt_admin_getadmins.execute();
message = stmt_admin_getadmins.getString(2);
System.out.println("message " + message);
rs_admins = ((OracleCallableStatement)stmt_admin_getadmins).getCursor(1);
while (rs_admins.next())
v_admins.addElement(rs_admins.getString("adminid"));
rs_admins.close();
return v_admins;
CREATE OR REPLACE PACKAGE Admin_conf IS
TYPE REF_CRSR IS REF CURSOR; /* OUTPUT CURSOR VARIABLE TYPE */
PROCEDURE RMS_ADMIN_GETALLADMINS(RESULTS OUT REF_CRSR,
OUT_MESSAGE OUT VARCHAR2);
END Admin_conf;
CREATE OR REPLACE PACKAGE BODY Admin_conf
IS
PROCEDURE RMS_ADMIN_GETALLADMINS(RESULTS OUT REF_CRSR,
OUT_MESSAGE OUT VARCHAR2)
IS
l_ref_out_crsr REF_CRSR;
BEGIN
OPEN l_ref_out_crsr FOR
SELECT EXECUTIVE_ID adminid
FROM MASTER_EXECUTIVE_ID
ORDER BY EXECUTIVE_ID;
OUT_MESSAGE := 'ADMIN IDS FETCHED SUCCESSFULLY';
RESULTS := l_ref_out_crsr;
EXCEPTION WHEN OTHERS THEN
OUT_MESSAGE := 'ERROR ' || SUBSTR(SQLERRM, 1, 60);
END RMS_ADMIN_GETALLADMINS;
END Admin_conf;
Regards
Ajay Singh RathodAre you actually closing the connections, resultsets in all cases?
From what you've posted you call
rs_admins.close();but in that method, you propagate any exceptions that occur out to the caller method, which in turn just prints a stack trace.
So if an exception occurs before you call the rs_admin.close() the result set will never be closed as the statement won't be reached.
I'd add a speific exception handling routine to the admin_getAdmins() method and include a finally clause to close the result set in all cases. You can still onthrow the exception if you want.
cheers
-steve- -
ORA-01000: maximum open cursors exceeded ORA-06512
Hi,
An exception error ccurred as below while trying to map a column.
Exception oracle.apps.bne.exception.BneSQLException: SQL Exception in BneFlex.validateSegs: java.sql.SQLException: ORA-01000: maximum open cursors exceeded ORA-06512: at "APPS.FND_MESSAGE", line 525 ORA-06512: at "APPS.FND_MESSAGE", line 565 ORA-06512: at "APPS.FND_MESSAGE", line 654 ORA-06512: at "APPS.FND_MESSAGE", line 766 ORA-06512: at "APPS.FND_MESSAGE", line 741 ORA-06512: at "APPS.FND_FLEX_KEYVAL", line 324 ORA-06512: at line 1 occurred trying to map column: Expense Account.
In alert log file:
Errors in file /vol01/oracle/SIT/db/tech_st/10.2.0/admin/SIT_sit/udump/sit_ora_7
04744.trc:
ORA-07445: exception encountered: core dump [] [] [] [] [] []
ORA-00604: error occurred at recursive SQL level 1
ORA-01000: maximum open cursors exceeded
ORA-01000: maximum open cursors exceeded
Thanks
Edited by: userpat on Aug 15, 2010 5:32 AMHi,
The issue is different this time after restarting application and database find below.
An exception occured trying to map a column
Exception java.lang.ArrayIndexOutOfBoundsException:Array index out of range:1
occured trying to map column:Category
in bne.log
8/18/10 12:08 PM AJPRequestHandler-ApplicationServerThread-2 ERROR BneP
arentMenuResolver.getMenuItem() MENU 101:BUDGET_NOTE - Menu item excluded becaus
e IntegratorAppId and Code does not match that of the Top-Most Menu Item or curr
ent Integrator: 140:FA_MASS_ADDITIONSThe same error is reported in Note: 954462.1 (which is referenced above).
And also let me clear one doubt. v$open_cursors view is used for what?. The total number of count v$open_cursors is 60,000 whereas the parameter is defined only 2000 in the Instance.Cursors Remain Open (in V$OPEN_CURSOR View) after being Closed [ID 1020427.102]
Monitoring Open Cursors & Troubleshooting ORA-1000 Errors [ID 76684.1]
V$OPEN_CURSOR
http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2008.htm#REFRN30166
Thanks,
Hussein -
JDBC Error: ORA-01000: maximum open cursors exceeded
Post Author: prashant
CA Forum: Information OnDemand
I successfully created reports using CR4E on windows, deployed JSPS to Websphere running on windows and was able to view a large reports for a using JNDI connection resources to Oracle 10g.
Every time report is called, it consume 12 cursors from of the database. Open_cursors count is 300. After 24 or 25 iteration of this report, it throws ORA-01000: maximum open cursors exceeded error.
Has anyone seen this problem, and if so where can I find a hot fix/patch. Any help would very much be appreciated.The following code reproduces the problem for me. I thought this was just related to when an exception occurs, and close occurs immediately afterwards. Close finds the exception that occured, and throws it without releasing the resources.
It's a pain in the ass, that's for sure.
public void go() {
try{
long startTime = System.currentTimeMillis();
String sql = "Select number_7_0__, char_10__, varchar_5__, varchar2_10__, number_10_5__, float_126__, date_, clob_, blob_ FROM lotsofrows";
Properties connectProps = new Properties();
Driver drv = new oracle.jdbc.driver.OracleDriver();
connectProps.put("user", "borg");
connectProps.put("catalog", "test");
connectProps.put("password", "borgborg");
Connection conn = drv.connect("jdbc:oracle:thin:@142.176.134.166:1521:test", connectProps);
int cnt = 0;
while (true) {
try {
System.out.print("\nTest " + ++cnt + " ");
Statement stmt = conn.createStatement();
System.out.print("execute ");
ResultSet rs = stmt.executeQuery(sql);
System.out.print("cancel ");
stmt.cancel();
try {
System.out.print("close.");
stmt.close();
} catch (SQLException se) {
if (se.getMessage().indexOf("requested cancel") != -1) {
System.out.print("URC:Close");
try {
stmt.close();
} catch (Exception ee) {
System.out.println(ee.getMessage());
ee.printStackTrace();
} else {
throw se;
stmt = null;
}catch(Exception se) {
System.out.println(se.getMessage());
se.printStackTrace();
}catch(Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
null -
How to resolve the issue of ORA-01000: maximum open cursors exceeded
Hi all,
I'm new to Oracle, currently I write a simple java class to retrieve records form Oracle DB, but following error occurs:
java.sql.SQLException: ORA-01000: maximum open cursors exceeded
String sql = "select * from......";
prepStmt = conn.prepareStatement(sql);
prepStmt.setString(1, this.getId());
rlt = prepStmt.executeQuery();
while (rlt.next()) {
try {
rlt.getString("severity");
rlt.getTimestamp("time_stamp");
violationList.add(viol);
} catch (Exception e) {
When there are only few records in the table, it is ok, but if the result is large, occur the exception.
Why and how to resolve?
Thanks.
JaneIt is better to close statement using try...catch...finally , e.g.
PreparedStatement objStmt = null;
try
objStmt = conn.prepareStatement(...);
// ... do anything
catch (Exception e)
// ... exception handling
finally
// another try...catch block to handle exception during statement close
try { objStmt.close(); } catch (Exception e) { }
objStmt = null;
This would guarantee that statment object is being closed even though exception is thrown. (Don't wait for connection release by garbage collector) -
Help needed, getting ORA-01000: maximum open cursors exceeded
CJ or anyone that may have come across this problem in the past, I hope that you may be able to help me
I am trying to implement a function from the Salesforce PHP tool kit that runs against a class that returns a object of ID's that have been updated in a given time frame.
This is a lot of code. I am sorry for that:
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
//Keep the SOAP cache clean
ini_set("soap.wsdl_cache_enabled","0");
$delete_count = 0;
$oracle_deleted = 0;
//Setup array for local ID's'
$opportunity_data = array();
$deleted_data = array();
//start setup for PL SQL statement
$strsql = "begin mapsapp.sforce_opp_insert(";
$strsql .= ":pm_id,";
$strsql .= ":pm_accountid,";
$strsql .= ":pm_name,";
$strsql .= ":pm_description,";
$strsql .= ":pm_stagename,";
$strsql .= ":pm_amount,";
$strsql .= ":pm_probability,";
$strsql .= ":pm_expectedrevenue,";
$strsql .= ":pm_closedate,";
$strsql .= ":pm_type,";
$strsql .= ":pm_nextstep,";
$strsql .= ":pm_leadsource,";
$strsql .= ":pm_isclosed,";
$strsql .= ":pm_iswon,";
$strsql .= ":pm_forecastcategory,";
$strsql .= ":pm_campaignid,";
$strsql .= ":pm_hasopportunitylineitem,";
$strsql .= ":pm_pricebook2id,";
$strsql .= ":pm_ownerid,";
$strsql .= ":pm_createddate,";
$strsql .= ":pm_createdbyid,";
$strsql .= ":pm_lastmodifieddate,";
$strsql .= ":pm_lastmodifiedbyid,";
$strsql .= ":pm_systemmodstamp,";
$strsql .= ":pm_rsm_project_id_score__c,";
$strsql .= ":pm_lead_fae__c,";
$strsql .= ":pm_avg_annual_volume__c,";
$strsql .= ":pm_priority__c,";
$strsql .= ":pm_design_start_date__c,";
$strsql .= ":pm_design_proto_date__c,";
$strsql .= ":pm_production_years__c,";
$strsql .= ":pm_production_life_months__c,";
$strsql .= ":pm_production_months__c,";
$strsql .= ":pm_design_freeze_date__c,";
$strsql .= ":pm_production_proto_date__c,";
$strsql .= ":pm_mass_production_date__c,";
$strsql .= ":pm_fae_status__c,";
$strsql .= ":pm_fae_assigned_date__c,";
$strsql .= ":pm_fae_accepted_date__c,";
$strsql .= ":pm_potential__c,";
$strsql .= ":pm_fae_reject_reason__c,";
$strsql .= ":pm_fae_project_complexity__c,";
$strsql .= ":pm_design_phase__c,";
$strsql .= ":pm_maxim_id__c,";
$strsql .= ":pm_project_number__c,";
$strsql .= ":pm_active__c,";
$strsql .= ":pm_pivotal_created_by__c,";
$strsql .= ":pm_manufactured_by__c,";
$strsql .= ":pm_isdeleted,";
$strsql .= ":pm_lastactivitydate";
$strsql .= "); end;";
//end setup for PL SQL statement
//include common files
require_once ('/users/msimonds/public_html/includes/sfdc.inc');
include_once ('adodb.inc.php');
$db = ADONewConnection("oci8");
//connect to Oracle
$db->Connect('',"database_user","password","dev2");
//$db->BeginTrans();
$db->SetFetchMode(ADODB_FETCH_ASSOC);
if ($db)
try
//Set current time to get records from Salesforce
$currentTime = mktime();
// assume that update occured within the last 24 hrs.
$startTime = $currentTime - (60 * 60 * 36); //(seconds * minutes * hours)
$endTime = $currentTime;
echo "***** Get Updated Opportunities from the last 24 hours *****<br />";
$getUpdateddResponse = $client->getUpdated('Opportunity',$startTime,$endTime);
//$getUpdateddResponse->ids = "";
//echo '<pre>'.print_r($getUpdateddResponse,true).'</pre>';
//exit;
$opportunity_data = $getUpdateddResponse->ids;
if (is_array($opportunity_data) || is_object($opportunity_data))
set_time_limit(0);
ini_set("memory_limit","512M");
//copy data from Object to local array
//count the number of records coming in from Salesforce
$record_count = count($opportunity_data);
echo $record_count;
exit;
//echo '<pre>'.print_r($opportunity_data,true).'</pre>';
//exit;
//loop through the records
for ($i = 0; $i < $record_count; $i++)
$id = $opportunity_data[$i];
//SQL query for Salesforce
$soql = "Select Id, IsDeleted, AccountId, Name, Description, StageName, Amount, Probability, ExpectedRevenue, CloseDate, Type, NextStep, LeadSource, IsClosed, IsWon, ForecastCategory, CampaignId, HasOpportunityLineItem, Pricebook2Id, OwnerId, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, LastActivityDate, RSM_Original_Project_ID_Score__c, Lead_FAE__c, Avg_Annual_Volume__c, Priority__c, Design_Start_Date__c, Design_Proto_Date__c, Production_Years__c, Production_Life_months__c, Production_Months__c, Design_Freeze_Date__c, Production_Proto_Date__c, Mass_Production_Date__c, FAE_Status__c, FAE_Assigned_Date__c, FAE_Accepted_Date__c, Project_Potential__c, FAE_Reject_Reason__c, FAE_Project_Complexity__c, Design_Phase__c, maxim_id__c, Project_Number__c, Active__c, Project_Comments__c, Pivotal_Created_By__c, Manufactured_By__c FROM Opportunity WHERE Id = '{$id}'";
//setup query to local Oracle MAPS database
$get_oracle_record = query_db($id,$db);
if ($get_oracle_record)
$sql = "DELETE FROM sforce_opportunity WHERE ID = '{$id}'";
if ($db->Execute($sql)) ;
$insert_records = get_records($client,$soql);
else
$insert_records = get_records($client,$soql);
foreach ($insert_records as $r)
$pass_this['id'] = $id;
$pass_this['accountid'] = (string )$r->fields->AccountId;
$pass_this['name'] = (string )$r->fields->Name;
$pass_this['description'] = (string )$r->fields->Description;
$pass_this['stagename'] = (string )$r->fields->StageName;
$pass_this['amount'] = (int)$r->fields->Amount;
$pass_this['probability'] = (int)$r->fields->Probability;
$pass_this['expectedrevenue'] = (int)$r->fields->ExpectedRevenue;
$pass_this['closedate'] = (string )$r->fields->CloseDate;
$pass_this['type'] = (string )$r->fields->Type;
$pass_this['nextstep'] = (string )$r->fields->NextStep;
$pass_this['leadsource'] = (string )$r->fields->LeadSource;
$pass_this['isclosed'] = (string )$r->fields->IsClosed;
$pass_this['iswon'] = (string )$r->fields->IsWon;
$pass_this['forecastcategory'] = (string )$r->fields->ForecastCategory;
$pass_this['campaignid'] = (string )$r->fields->CampaignId;
$pass_this['hasopportunitylineitem'] = (string )$r->fields->HasOpportunityLineItem;
$pass_this['pricebook2id'] = $r->fields->Pricebook2Id;
$pass_this['ownerid'] = $r->fields->OwnerId;
$pass_this['createddate'] = (string )$r->fields->CreatedDate;
$pass_this['createdbyid'] = (string )$r->fields->CreatedById;
$pass_this['lastmodifieddate'] = (string )$r->fields->LastModifiedDate;
$pass_this['lastmodifiedbyid'] = (string )$r->fields->LastModifiedById;
$pass_this['systemmodstamp'] = (string )$r->fields->SystemModstamp;
$pass_this['rsm_project_id_score__c'] = (int)$r->fields->RSM_Original_Project_ID_Score__c;
$pass_this['lead_fae__c'] = (string )$r->fields->Lead_FAE__c;
$pass_this['avg_annual_volume__c'] = (int)$r->fields->Avg_Annual_Volume__c;
$pass_this['priority__c'] = (string )$r->fields->Priority__c;
$pass_this['design_start_date__c'] = (string )$r->fields->Design_Start_Date__c;
$pass_this['design_proto_date__c'] = (string )$r->fields->Design_Proto_Date__c;
$pass_this['production_years__c'] = (int)$r->fields->Production_Years__c;
$pass_this['production_life_months__c'] = (int)$r->fields->Production_Life_months__c;
$pass_this['production_months__c'] = (int)$r->fields->Production_Months__c;
$pass_this['design_freeze_date__c'] = (string )$r->fields->Design_Freeze_Date__c;
$pass_this['production_proto_date__c'] = (string )$r->fields->Production_Proto_Date__c;
$pass_this['mass_production_date__c'] = (string )$r->fields->Mass_Production_Date__c;
$pass_this['fae_status__c'] = (string )$r->fields->FAE_Status__c;
$pass_this['fae_assigned_date__c'] = (string )$r->fields->FAE_Assigned_Date__c;
$pass_this['fae_accepted_date__c'] = (string )$r->fields->FAE_Accepted_Date__c;
$pass_this['project_potential__c'] = (int)$r->fields->Project_Potential__c;
$pass_this['fae_reject_reason__c'] = (string )$r->fields->FAE_Reject_Reason__c;
$pass_this['fae_project_complexity__c'] = (string )$r->fields->FAE_Project_Complexity__c;
$pass_this['design_phase__c'] = (string )$r->fields->Design_Phase__c;
$pass_this['maxim_id__c'] = (string )$r->fields->maxim_id__c;
$pass_this['objective_status_next_qtr__c'] = (string )$r->fields->Objective_Status_Next_Qtr__c;
$pass_this['quality_of_relationship__c'] = (string )$r->fields->Quality_of_Relationship__c;
$pass_this['targeted_po_date__c'] = (string )$r->fields->Targeted_PO_Date__c;
$pass_this['part_no_involved__c'] = (string )$r->fields->Part_No_Involved__c;
$pass_this['first_po_number__c'] = (string )$r->fields->First_PO_Number__c;
$pass_this['lost_reason__c'] = (string )$r->fields->Lost_Reason__c;
$pass_this['fae_estimate_of_business__c'] = (string )$r->fields->FAE_Estimate_of_Business__c;
$pass_this['digital_processor__c'] = (string )$r->fields->Digital_Processor__c;
$pass_this['project_number__c'] = (string )$r->fields->Project_Number__c;
$pass_this['active__c'] = (string )$r->fields->Active__c;
$pass_this['pivotal_created_by__c'] = (string )$r->fields->Pivotal_Created_By__c;
$pass_this['manufactured_by__c'] = (string )$r->fields->Manufactured_By__c;
$pass_this['isdeleted'] = (string )$r->fields->IsDeleted;
$pass_this['lastactivitydate'] = (string )$r->fields->LastActivityDate;
$pass_this['optocon_id__c'] = (string )$r->fields->OptoCon_ID__c;
if (strlen($pass_this['description']) == 0)
$pass_this['description'] = "No Description Posted";
else
$pass_this['description'] = $pass_this['description'];
//echo '<pre>'.print_r($pass_this,true).'</pre>';
//exit;
$record_inserted = insert_record($pass_this,$strsql,$db);
if (!$record_inserted)
//mail('[email protected]','insert error','There was a proble trying to insert a record into the database');
else
echo "Nothing here";
//exit;
//add back in once replication is done
//get deleted records from the Opportunity
$getDeletedResponse = $client->getDeleted('Opportunity',$startTime,$endTime);
//echo '<pre>'.print_r($getDeletedResponse,true).'</pre>';
//exit;
$deleted_ids = $getDeletedResponse->deletedRecords;
//echo '<pre>'.print_r($deleted_ids,true).'</pre>';
if (is_object($deleted_ids))
$temp_array[] = $deleted_ids;
unset($deleted_ids);
$deleted_ids = $temp_array;
$delete_count = count($deleted_ids);
//echo $delete_count;
for ($i = 0; $i < $delete_count; $i++)
$d_id = $deleted_ids[$i];
$id = $d_id->id;
if (query_db($id,$db))
$delete_sql = "Delete from sforce_opportunity WHERE ID = '{$id}'";
$oracle_deleted++;
if ($db->Execute($delete_sql))
echo "<font color=\"#0000FF\">".$id." was removed from the Oracle database</font><br />";
else
echo $id." is not in the Oracle database<br />";
echo $oracle_deleted." records were deleted from Oracle";
catch (exception $e)
$error = '<pre>'.print_r($e,true).'</pre>';
mail('[email protected]','insert error',$error);
$db->CommitTrans();
$db->Close();
exit;
function insert_record($pass_this,$strsql,&$db)
//Prepares PL/SQL Statement
$stmt = $db->Prepare($strsql);
$db->InParameter($stmt,$pass_this['id'],'pm_id');
$db->InParameter($stmt,$pass_this['accountid'],'pm_accountid');
$db->InParameter($stmt,$pass_this['name'],'pm_name');
$db->InParameter($stmt,$pass_this['description'],'pm_description',-1,OCI_B_CLOB);
$db->InParameter($stmt,$pass_this['stagename'],'pm_stagename');
$db->InParameter($stmt,$pass_this['amount'],'pm_amount');
$db->InParameter($stmt,$pass_this['probability'],'pm_probability');
$db->InParameter($stmt,$pass_this['expectedrevenue'],'pm_expectedrevenue');
$db->InParameter($stmt,$pass_this['closedate'],'pm_closedate');
$db->InParameter($stmt,$pass_this['type'],'pm_type');
$db->InParameter($stmt,$pass_this['nextstep'],'pm_nextstep');
$db->InParameter($stmt,$pass_this['leadsource'],'pm_leadsource');
$db->InParameter($stmt,$pass_this['isclosed'],'pm_isclosed');
$db->InParameter($stmt,$pass_this['iswon'],'pm_iswon');
$db->InParameter($stmt,$pass_this['forecastcategory'],'pm_forecastcategory');
$db->InParameter($stmt,$pass_this['campaignid'],'pm_campaignid');
$db->InParameter($stmt,$pass_this['hasopportunitylineitem'],'pm_hasopportunitylineitem');
$db->InParameter($stmt,$pass_this['pricebook2id'],'pm_pricebook2id');
$db->InParameter($stmt,$pass_this['ownerid'],'pm_ownerid');
$db->InParameter($stmt,$pass_this['createddate'],'pm_createddate');
$db->InParameter($stmt,$pass_this['createdbyid'],'pm_createdbyid');
$db->InParameter($stmt,$pass_this['lastmodifieddate'],'pm_lastmodifieddate');
$db->InParameter($stmt,$pass_this['lastmodifiedbyid'],'pm_lastmodifiedbyid');
$db->InParameter($stmt,$pass_this['systemmodstamp'],'pm_systemmodstamp');
$db->InParameter($stmt,$pass_this['rsm_project_id_score__c'],'pm_rsm_project_id_score__c');
$db->InParameter($stmt,$pass_this['lead_fae__c'],'pm_lead_fae__c');
$db->InParameter($stmt,$pass_this['avg_annual_volume__c'],'pm_avg_annual_volume__c');
$db->InParameter($stmt,$pass_this['priority__c'],'pm_priority__c');
$db->InParameter($stmt,$pass_this['design_start_date__c'],'pm_design_start_date__c');
$db->InParameter($stmt,$pass_this['design_proto_date__c'],'pm_design_proto_date__c');
$db->InParameter($stmt,$pass_this['production_years__c'],'pm_production_years__c');
$db->InParameter($stmt,$pass_this['production_life_months__c'],'pm_production_life_months__c');
$db->InParameter($stmt,$pass_this['production_months__c'],'pm_production_months__c');
$db->InParameter($stmt,$pass_this['design_freeze_date__c'],'pm_design_freeze_date__c');
$db->InParameter($stmt,$pass_this['production_proto_date__c'],'pm_production_proto_date__c');
$db->InParameter($stmt,$pass_this['mass_production_date__c'],'pm_mass_production_date__c');
$db->InParameter($stmt,$pass_this['fae_status__c'],'pm_fae_status__c');
$db->InParameter($stmt,$pass_this['fae_assigned_date__c'],'pm_fae_assigned_date__c');
$db->InParameter($stmt,$pass_this['fae_accepted_date__c'],'pm_fae_accepted_date__c');
$db->InParameter($stmt,$pass_this['project_potential__c'],'pm_potential__c');
$db->InParameter($stmt,$pass_this['fae_reject_reason__c'],'pm_fae_reject_reason__c');
$db->InParameter($stmt,$pass_this['fae_project_complexity__c'],'pm_fae_project_complexity__c');
$db->InParameter($stmt,$pass_this['design_phase__c'],'pm_design_phase__c');
$db->InParameter($stmt,$pass_this['maxim_id__c'],'pm_maxim_id__c');
$db->InParameter($stmt,$pass_this['project_number__c'],'pm_project_number__c');
$db->InParameter($stmt,$pass_this['active__c'],'pm_active__c');
$db->InParameter($stmt,$pass_this['pivotal_created_by__c'],'pm_pivotal_created_by__c');
$db->InParameter($stmt,$pass_this['manufactured_by__c'],'pm_manufactured_by__c');
$db->InParameter($stmt,$pass_this['isdeleted'],'pm_isdeleted');
$db->InParameter($stmt,$pass_this['lastactivitydate'],'pm_lastactivitydate');
//executes and loads data coming from salesforce into table
if ($db->Execute($stmt))
echo $pass_this['id']." was inserted into the database<br />";
flush();
unset($pass_this);
unset($stmt);
return true;
else
echo $db->ErrorMsg()."<br>";
mail('[email protected]','database error',$db->ErrorMsg());
return false;
//Get the data from Salesforce to populate Oracle
function get_records(&$connection,&$query)
$queryOptions = new QueryOptions(2000);
$response = new QueryResult($connection->query($query));
// if the size is zero, where done
if ($response->size > 0)
$products = $response->records;
// Cycles through additional responses if the number of records
// exceeds the batch size
while (!$response->done)
set_time_limit(100);
$response = $connection->queryMore($response->queryLocator);
$products = array_merge($products,$response->records);
return $products;
function query_db($id,&$db)
global $db;
$sql = "SELECT *
FROM sforce_opportunity
Where id = '{$id}'";
$rs = $db->Execute($sql);
if ($rs && $rs->_numOfRows > 0)
return true;
else
return false;
exit;
?>the code runs fine and I do not commit my inserts until after I am done retrieving all the records, but I am getting the oracle error: ORA-01000: maximum open cursors exceeded
I am not using any cursors in my PL SQL
CREATE OR REPLACE PROCEDURE MAPSAPP.sforce_opp_insert (
pm_id IN VARCHAR2,
pm_accountid IN VARCHAR2,
pm_name IN VARCHAR2,
pm_description IN VARCHAR2,
pm_stagename IN VARCHAR2,
pm_amount IN NUMBER,
pm_probability IN NUMBER,
pm_expectedrevenue IN NUMBER,
pm_closedate IN VARCHAR2,
pm_type IN VARCHAR2,
pm_nextstep IN VARCHAR2,
pm_leadsource IN VARCHAR2,
pm_isclosed IN VARCHAR2,
pm_iswon IN VARCHAR2,
pm_forecastcategory IN VARCHAR2,
pm_campaignid IN VARCHAR2,
pm_hasopportunitylineitem IN VARCHAR2,
pm_pricebook2id IN VARCHAR2,
pm_ownerid IN VARCHAR2,
pm_createddate IN VARCHAR2,
pm_createdbyid IN VARCHAR2,
pm_lastmodifieddate IN VARCHAR2,
pm_lastmodifiedbyid IN VARCHAR2,
pm_systemmodstamp IN VARCHAR2,
pm_rsm_project_id_score__c IN VARCHAR2,
pm_lead_fae__c IN VARCHAR2,
pm_avg_annual_volume__c IN VARCHAR2,
pm_priority__c IN VARCHAR2,
pm_design_start_date__c IN VARCHAR2,
pm_design_proto_date__c IN VARCHAR2,
pm_production_years__c IN NUMBER,
pm_production_life_months__c IN NUMBER,
pm_production_months__c IN NUMBER,
pm_design_freeze_date__c IN VARCHAR2,
pm_production_proto_date__c IN VARCHAR2,
pm_mass_production_date__c IN VARCHAR2,
pm_fae_status__c IN VARCHAR2,
pm_fae_assigned_date__c IN VARCHAR2,
pm_fae_accepted_date__c IN VARCHAR2,
pm_potential__c IN NUMBER,
pm_fae_reject_reason__c IN VARCHAR2,
pm_fae_project_complexity__c IN VARCHAR2,
pm_design_phase__c IN VARCHAR2,
pm_maxim_id__c IN VARCHAR2,
pm_project_number__c IN VARCHAR2,
pm_active__c IN VARCHAR2,
pm_pivotal_created_by__c IN VARCHAR2,
pm_manufactured_by__c IN VARCHAR2,
pm_isdeleted IN VARCHAR2,
pm_lastactivitydate IN VARCHAR2
IS
BEGIN
INSERT INTO SFORCE_OPPORTUNITY
(id,
accountid,
name,
description,
stagename,
amount,
probability,
expectedrevenue,
closedate,
type,
nextstep,
leadsource,
isclosed,
iswon,
forecastcategory,
campaignid,
hasopportunitylineitem,
pricebook2id,
ownerid,
createddate,
createdbyid,
lastmodifieddate,
lastmodifiedbyid,
systemmodstamp,
rsm_project_id_score__c,
lead_fae__c,
avg_annual_volume__c,
priority__c,
design_start_date__c,
design_proto_date__c,
production_years__c,
production_life_months__c,
production_months__c,
design_freeze_date__c,
production_proto_date__c,
mass_production_date__c,
fae_status__c,
fae_assigned_date__c,
fae_accepted_date__c,
project_potential__c,
fae_reject_reason__c,
fae_project_complexity__c,
design_phase__c,
maxim_id__c,
project_number__c,
active__c,
pivotal_created_by__c,
manufactured_by__c,
isdeleted,
lastactivitydate
VALUES (pm_id,
pm_accountid,
pm_name,
pm_description,
pm_stagename,
pm_amount,
pm_probability,
pm_expectedrevenue,
TO_DATE (SUBSTR (REPLACE (pm_closedate, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
pm_type,
pm_nextstep,
pm_leadsource,
pm_isclosed,
pm_iswon,
pm_forecastcategory,
pm_campaignid,
pm_hasopportunitylineitem,
pm_pricebook2id,
pm_ownerid,
TO_DATE (SUBSTR (REPLACE (pm_createddate, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
pm_createdbyid,
TO_DATE (SUBSTR (REPLACE (pm_lastmodifieddate, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
pm_lastmodifiedbyid,
TO_DATE (SUBSTR (REPLACE (pm_systemmodstamp, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
pm_rsm_project_id_score__c,
pm_lead_fae__c,
pm_avg_annual_volume__c,
pm_priority__c,
TO_DATE (SUBSTR (REPLACE (pm_design_start_date__c, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
TO_DATE (SUBSTR (REPLACE (pm_design_proto_date__c, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
pm_production_years__c,
pm_production_life_months__c,
pm_production_months__c,
TO_DATE (SUBSTR (REPLACE (pm_design_freeze_date__c, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
TO_DATE (SUBSTR (REPLACE (pm_production_proto_date__c, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
TO_DATE (SUBSTR (REPLACE (pm_mass_production_date__c, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
pm_fae_status__c,
TO_DATE (SUBSTR (REPLACE (pm_fae_assigned_date__c, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
TO_DATE (SUBSTR (REPLACE (pm_fae_accepted_date__c, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS'),
pm_potential__c,
pm_fae_reject_reason__c,
pm_fae_project_complexity__c,
pm_design_phase__c,
pm_maxim_id__c,
pm_project_number__c,
pm_active__c,
pm_pivotal_created_by__c,
pm_manufactured_by__c,
pm_isdeleted,
TO_DATE (SUBSTR (REPLACE (pm_lastactivitydate, 'T', ' '), 1, 19),'YYYY-MM-DD HH24:MI:SS')
END sforce_opp_insert;
/I was wondering anyone has seen this before
TIA,
MikeThe code below is deleting fine. Check your $id is valid. I wonder if ADOdb has some quirks with binding and variable creation/destruction, similar to #1 in http://www.oracle.com/technology/tech/php/htdocs/php_troubleshooting_faq.html#bindvars
<?php
See ADOdb Tutorial for Oracle: http://phplens.com/lens/adodb/docs-oracle.htm
drop table mytab;
create table mytab (city varchar2(20), country_id varchar2(20));
insert into mytab values ('SF', 'US');
insert into mytab values ('Sydney', 'AU');
insert into mytab values ('London', 'UK');
commit;
require_once("/home/cjones/public_html/php/adodb5/adodb.inc.php");
$db = ADONewConnection("oci8");
$db->Connect("//localhost/XE", "hr", "hrpwd");
echo "Before:\n";
$rs = $db->Execute("select city from mytab");
while ($arr = $rs->FetchRow()) {
echo $arr['CITY'] . "\n";
$s = $db->Prepare("delete from mytab where country_id = :ci");
$db->Parameter($s, $ci, 'ci');
foreach (array('US', 'AU') as $ci) {
$db->Execute($s);
echo "After:\n";
$rs = $db->Execute("select city from mytab");
while ($arr = $rs->FetchRow()) {
echo $arr['CITY'] . "\n";
?>There's another sample in the ADOdb OCI8 driver:
Usage:
$stmt = $DB->Prepare("insert into table (col0, col1, col2) values (:0, :1, :2)");
$DB->Bind($stmt, $p1);
$DB->Bind($stmt, $p2);
$DB->Bind($stmt, $p3);
for ($i = 0; $i < $max; $i++) {
$p1 = ?; $p2 = ?; $p3 = ?;
$DB->Execute($stmt);
}For queries I know this works. I haven't seen any examples that prepare once.
$rs = $db->Execute("select city from mytab where country_id = :ci", array('ci' => 'UK'));
while ($arr = $rs->FetchRow()) {
echo $arr['CITY'] . "<br>\n";
} -
ORA-01000 maximum open cursors exceeded with XA driver
We are getting ORA-01000 maximum open cursors exceeded error from Oracle database
agian and again.We are usimg XA driver.
What is the weblogic's work around to handle this error?How we can handle this?We
tried doing "grant select on DBA_PENDING_TRANSACTIONS to public ;" ,this also
works for some time only.Again the same error starts coming.
Help please.
Thanx in advance.Thanks for your reply.
I have increased my cursor size to 2000(default 300).We are using weblogic6.1
and Oracle9i.Yes I was little aware about this bug so I tried doing "grant select
on DBA_PENDING_TRANSACTIONS to public " from sys and no of open cursors reduced
drastically but aftter some time increased again.We are using combination of thin,XA,non
XA and oci drivers.
We are using weblogic security framework also in our application and I think that
consumes maximum no. of cursors.
Kindly advice.
Thanx a lot.
Pinky
Mitesh Patel <[email protected]> wrote:
What is the size of cusror set in your oracle init.ora file?
What version of oracle thin driver and weblogic are you using?
Please read the following note:
There is a bug with Oracle 817 driver's XAResource.recover implementation:
it
ignores the flag and always return all in-doubt Xids. After initially
calling a resource's recover with TMSTARTRSCAN, TM subsequently calls
the
resource's recover with TMNOFLAGS until no more Xid is returned. Thus,
Oracle driver's XAResource.recover is called infinitely until eventually
it
returns XAER_RMERR. Subsequent XAResource.start then returns ORA-01000
exception (looks like all their XAResource methods internally uses prepared
statements to execute some stored procedure.)
Is this the case wth you?
Mitesh
Pinky Arora wrote:
We are getting ORA-01000 maximum open cursors exceeded error from Oracledatabase
agian and again.We are usimg XA driver.
What is the weblogic's work around to handle this error?How we canhandle this?We
tried doing "grant select on DBA_PENDING_TRANSACTIONS to public ;",this also
works for some time only.Again the same error starts coming.
Help please.
Thanx in advance. -
Please help me for resolving this Error.
I got This Error while Web Load TEsting.
java.sql.SQLException: ORA-01000: maximum open cursors exceeded ORA-06512: at "IADMIN.ADM_ADMIN_ISMART_PCK", line 269 ORA-06512: at line 1I also faced similar problem - and solved as following:
java.sql.PreparedStatement pStmt = null;
ResultSet rs, rs_opr;
try {
query = "select ..."
pStmt = conn.prepareStatement (query); // first instance of the PreparedStatement
pStmt.setInt (1, rq_count);
pStmt.setString (2, rqid);
rs = pStmt.executeQuery ();
if (rs.next()) {
plant_nm = rs.getString("PLANT_NM");
rs.close();
pStmt.close(); // this was done only at the last time (added here and solved)
query = "select ..."
pStmt = conn.prepareStatement (query); // second instance of the PreparedStatement
pStmt.setInt (1, rq_count);
pStmt.setString (2, rqid);
rs = pStmt.executeQuery ();
if (rs.next()) {
Var2 = rs.getString("Vari1ble_2");
rs.close();
pStmt.close(); // this was done only at the last time (added here and solved)
query = "select ..."
pStmt = conn.prepareStatement (query); // third instance of the PreparedStatement
pStmt.setInt (1, rq_count);
pStmt.setString (2, rqid);
rs = pStmt.executeQuery ();
if (rs.next()) {
Var3 = rs.getString("Variable_3");
rs.close();
pStmt.close(); // this was done only here -- added 2 times as above
} -
ORA-01000: maximum open cursors exceeded In a Package
I have a package that is utilizing cursors, This program is for a data conversion project. I have Ten procedures and functions in this package, about 4 of them are public. Within my main program I call these functions and procedures as needed. After about the processing of 30 records, i get this 'ORA-01000: maximum open cursors exceeded' error. the curosr parameter on the database is 300, I am not sure what to do, the cursors are closed, because I am usuing the cursor for loop. I have changed these cursors from ref to regular cursors, but the problem persist. Could someone please help! Thanks.
there are about 6000 lines of code here is an example. I have checked all cursors and they are closed after processing.
-- Package Spec
Package MainPac Is
Procedure c1;
End MainPac;
-- Package Body
Package MainPac Is
Procecudure P2( InputP ) is
Cursor c2 is select * from SiteRec
Where NJSKey = InputP;
For c2Rec In C2 Loop
Process c2Rec;
For C3Rec in (Select Remart Text from all_remarks
Where remark_Key = C3Rec.Key) Loop
Load into tem table;
End loop;
end Procedure P2;
Procecudure P3( InputP ) is
Cursor C4 is select * from SolutuinsTab
Where NJSKey = InputP;
For C4Rec In C4 Loop
Process C4Rec;
For C5Rec in (Select Remart Text from all_remarks
Where remark_Key = C4Rec.Key) Loop
Load into tem table;
End loop;
end Procedure P3;
Procedure c1 is
Cursor c1 is Select * from NJS;
begin
For c1rec in c1 loop
process c1rec;
call procecudure P2(NJSKey);
call procecudure P3 (NJSKey);
call procecudure P4(NJSKey);
call procecudure P5(NJSKey);
call procecudure P6(NJSKey);
end loop;
End MainPack ; -
ORA-01000: maximum open cursors exceeded--Error
Hi
What is "ORA-01000: maximum open cursors exceeded" error,How to solve.
Thanks
MisebaHi
ORA-01000: maximum open cursors exceeded
Other terms
Oracle, open cursors, exchange infrastructure
Reason and Prerequisites
The parameter "open_cursors" is set too low. Long transactions, such as imports, may use up all available cursors and fail.
Solution :
THIS NOTE APPLIES TO XI 3.0 SP2 ONLY **
if you encounter an exception that reports "ORA-01000: maximum open cursors exceeded" please adjust the open_cursors parameter as follows:
If the BR*Tools exist on your system:
1] directory: /usr/sap/<SID>/SYS/exe/run
2] "brspace -c force -f dbparam -a change -p open_cursors -v 100000"
3] directory: $ORACLE_HOME/dbs (Unix) or %ORACLE_HOME%/database (Win)
4] change open_cursors parameter in init<SID>.ora to 100000
If the BR*Tools are not available (2] above - command not found)
1] change the open_cursors parameter as in 4] above
2] restart DB, for changes to take effect. _ NOTE: This problem has been fixed with XI 3.0 SP3 (see note 735078)
Plz asign points if helpfull.
Regards
Padmanabha -
ORA-01000: maximum open cursors exceeded in R12
Hi,
In which Middle Tier log we see "ORA-01000: maximum open cursors exceeded" error, we have EBS R12 version.937828 wrote:
Hi,
In which Middle Tier log we see "ORA-01000: maximum open cursors exceeded" error, we have EBS R12 version.
Increase the value of OPEN_CURSORS init parameter -- https://community.oracle.com/search.jspa?peopleEnabled=true&userID=&containerType=&container=&q=ORA-01000
Database Initialization Parameters for Oracle E-Business Suite Release 12 (Doc ID 396009.1)
Thanks,
Hussein
Maybe you are looking for
-
Variable updating when another variable changes. How to keep it static?
I'm missing something very basic here I think. What's happening is that I'm looping through a list. I also need to update that list, but since I don't want to update the list I'm looping through, I created a temporary list to hold the new values. The
-
How can I delete a song that I bought by mistake?
I bought a song by mistake. Although I would love to " return" it, I can understand why that might not be possible. At this point, I just want to delete it off my phone, laptop, etc. Help!
-
How can I share my music with other account users
Hello I would like to know how I can share my Itunes library with other user accounts on my mackbook? Thanks
-
Isight stating the other viewer is "already in a conference"
Just purchased two isights for christmas. One is on a Powerbook G4 and the other is on a new Imac. Whenever we try to connect, I am getting the response of "that person is already in a conference". Also we cannot IM each other. One mac has a .mac acc
-
Hi, i m using DWR to populate the combo box based on the selection of value of the first combo box. When i submit , i come to same page...so i want the previous values to be there. So the 2nd combo (whch is populated by DWR) should also have the prev