Question

ORA-01000: maximum open cursors exceeded

Asked by: graham_ball

The attached code is part of a stored procedure, which is where I'm getting the eeror.
Max cursors is set at 1024 and I just can't see how I'm going anywhere near that.

thanks for your help.

select TFF.FACTFIND_ID
				, SUBMISSIONS.SUBMISSION_NUMBER
			   , parties.cust1
			   , parties.cust2
			   , TFF.AGENT_ID
			   , null
			   , TFF.LEAD_ID
				, TFF.FACTFIND_DATE
			   , TFF.STATUS_DATE
			   , DECODE(SUBMISSIONS.SUBMISSION_NUMBER, 1,'Y','N') rft_flag
			   , needs.ip
			   , needs.ci
			   , needs.lcc
			   , needs.lci
			   , needs.savings
			   , needs.investment
			   , needs.pension
			   , needs.annuities
			   , sales.ip
			   , sales.ci
			   , sales.lcc
			   , sales.lci
			   , sales.savings
			   , sales.investment
			   , sales.pension
			   , sales.annuities
			   , EXPENDITURE.DECLINED_FLAG disclosed_expenditure
			   , ASSETS.DECLINED_FLAG disclosed_assets
			   , LIABILITIES.DECLINED_FLAG disclosed_liabilities
			   , OCCBEN.DECLINED_FLAG disclosed_occbens
			   , protection.DECLINED_FLAG disclosed_protection
			   , savings.DECLINED_FLAG disclosed_savings
			   , pensions.DECLINED_FLAG disclosed_pensions
			   , investments.DECLINED_FLAG disclosed_investments
			   , TFF.BUILDINGS_RENEWAL_DATE
			   , TFF.BUILDINGS_PROVIDER_TEXT
			   , TFF.CONTENTS_RENEWAL_DATE
			   , TFF.CONTENTS_PROVIDER_TEXT
			   , b_and_c_premium.premium
			   , atr.cust1_protection_level
			   , atr.cust1_savings_level
			   , atr.cust1_investment_level
			   , atr.cust1_pension_level
			   , cust_ni.cust1_ip_ni
			   , cust_ni.cust1_ci_ni
			   , cust_ni.cust1_lcc_ni
			   , cust_ni.cust1_lci_ni
			   , cust_ni.cust1_savings_ni
			   , cust_ni.cust1_investments_ni
			   , cust_na.cust1_ip_na
			   , cust_na.cust1_ci_na
			   , cust_na.cust1_lcc_na
			   , cust_na.cust1_lci_na
			   , cust_na.cust1_savings_na
			   , cust_na.cust1_investments_na
			   , atr.cust2_protection_level
			   , atr.cust2_savings_level
			   , atr.cust2_investment_level
			   , atr.cust2_pension_level
			   , cust_ni.cust2_ip_ni
			   , cust_ni.cust2_ci_ni
			   , cust_ni.cust2_lcc_ni
			   , cust_ni.cust2_lci_ni
			   , cust_ni.cust2_savings_ni
			   , cust_ni.cust2_investments_ni
			   , cust_na.cust2_ip_na
			   , cust_na.cust2_ci_na
			   , cust_na.cust2_lcc_na
			   , cust_na.cust2_lci_na
			   , cust_na.cust2_savings_na
			   , cust_na.cust2_investments_na
			   , TFF.STATUS_DATE
			from salex.t_ff_factfind@util.world tff
				,(
			      select TNLD.FACTFIND_ID
			      , MAX(TNLD.SUBMISSION_NUMBER) submission_number
			      from salex.t_nbmu_log_detail@util.world tnld
			      group by TNLD.FACTFIND_ID
			    ) submissions
				,(
			      select TFR.FACTFIND_ID
			         , MAX(DECODE(TFR.ROLE_TYPE_CODE_ID,1008513,TFR.PARTY_ID )) cust1
			         , MAX(DECODE(TFR.ROLE_TYPE_CODE_ID,1008514,TFR.PARTY_ID )) cust2
			      from salex.t_ff_role@util.world tfr
			      group by TFR.FACTFIND_ID
			    )  parties
				,(
				   select tna.factfind_id
						, NVL(SUM(DECODE(TNND.NEED_ID,341,1)),0) ip
						, NVL(SUM(DECODE(TNND.NEED_ID,342,1)),0) ci
						, NVL(SUM(DECODE(TNND.NEED_ID,343,1,8,1)),0) lcc
						, NVL(SUM(DECODE(TNND.NEED_ID,340,1)),0) lci
						, NVL(SUM(DECODE(TNND.NEED_ID,346,1)),0) annuities
						, NVL(SUM(DECODE(TNND.NEED_ID,347,1,348,1)),0) savings
						, NVL(SUM(DECODE(TNND.NEED_ID,349,1,350,1)),0) investment
						, NVL(SUM(DECODE(TNND.NEED_ID,344,1,345,1)),0) pension
					from salex.t_na_needs@util.world tna
						, salex.t_na_needs_detail@util.world tnnd
					where TNA.NA_NEED_ID = TNND.NA_NEED_ID
					group by tna.factfind_id
				 ) needs
				,(
					select tr.factfind_id
						, NVL(SUM(DECODE(tr.NEED_ID,341,1)),0) ip
						, NVL(SUM(DECODE(tr.NEED_ID,342,1)),0) ci
						, NVL(SUM(DECODE(tr.NEED_ID,343,1,8,1)),0) lcc
						, NVL(SUM(DECODE(tr.NEED_ID,340,1)),0) lci
						, NVL(SUM(DECODE(tr.NEED_ID,346,1)),0) annuities
						, NVL(SUM(DECODE(tr.NEED_ID,347,1,348,1)),0) savings
						, NVL(SUM(DECODE(tr.NEED_ID,349,1,350,1)),0) investment
						, NVL(SUM(DECODE(tr.NEED_ID,344,1,345,1)),0) pension
					from salex.t_recommendations@util.world tr
					where TR.FACTFIND_ID is not null
					and TR.ACCEPTED_CODE_ID = 590
					group by tr.factfind_id
				 ) sales
			   ,(
			      select distinct TFIE.FACTFIND_ID
			            , TFIE.DECLINED_FLAG
			      from salex.t_ff_income_expenditure@util.world tfie
				 ) expenditure
			   ,(
			      select distinct TFA.FACTFIND_ID
			            , TFA.DECLINED_FLAG
			      from salex.t_ff_assets@util.world tfa
				 ) assets
			   ,(
					select distinct TFL.FACTFIND_ID
			            , TFL.DECLINED_FLAG
			      from salex.t_ff_liabilities@util.world tfl
				 ) liabilities
			   ,(
			      select distinct TFOB.FACTFIND_ID
			            , TFOB.DECLINED_FLAG
			      from salex.t_ff_occupational_benefits@util.world tfob
				 ) occben
			   ,(
			      select distinct TFEB.FACTFIND_ID
			            , MAX(TFEB.DECLINED_FLAG) DECLINED_FLAG
			      from salex.t_ff_existing_business@util.world tfeb
			      where TFEB.NEED_AREA_CODE_ID = 1008499
			      group by tfeb.factfind_id
				 ) protection
			   ,(
			      select distinct TFEB1.FACTFIND_ID
			            , MAX(TFEB1.DECLINED_FLAG) DECLINED_FLAG
			      from salex.t_ff_existing_business@util.world tfeb1
			      where TFEB1.NEED_AREA_CODE_ID = 1008500
			      group by tfeb1.factfind_id
				 ) savings
			   ,(
			      select distinct TFEB2.FACTFIND_ID
			            , MAX(TFEB2.DECLINED_FLAG) DECLINED_FLAG
			      from salex.t_ff_existing_business@util.world tfeb2
			      where TFEB2.NEED_AREA_CODE_ID = 1008501
			      group by tfeb2.factfind_id
				 ) pensions
			   ,(
			      select distinct TFEB3.FACTFIND_ID
			            , MAX(TFEB3.DECLINED_FLAG) DECLINED_FLAG
			      from salex.t_ff_existing_business@util.world tfeb3
			      where TFEB3.NEED_AREA_CODE_ID = 1008502
			      group by tfeb3.factfind_id
				 ) investments
			   ,(
			      select TFIE1.FACTFIND_ID
			         , SUM(TFIED1.IE_AMT) premium
			      from salex.t_ff_income_expenditure@util.world tfie1
			         , salex.t_ff_income_exp_detail@util.world tfied1
			      where TFIE1.IE_ID = TFIED1.IE_ID
			      and TFIE1.DECLINED_FLAG = 'N'
			      and TFIED1.IE_CODE_ID = 1008556
			      group by TFIE1.FACTFIND_ID
			   ) b_and_c_premium
			   ,(
			      select factfind_id
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||ni_type,'1008513IP','Y')) cust1_ip_ni
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||ni_type,'1008513CI','Y')) cust1_ci_ni
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||ni_type,'1008513LCC','Y')) cust1_lcc_ni
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||ni_type,'1008513LCI','Y')) cust1_lci_ni
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||ni_type,'1008513Savings','Y')) cust1_savings_ni
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||ni_type,'1008513Investments','Y')) cust1_investments_ni
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||ni_type,'1008514IP','Y')) cust2_ip_ni
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||ni_type,'1008514CI','Y')) cust2_ci_ni
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||ni_type,'1008514LCC','Y')) cust2_lcc_ni
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||ni_type,'1008514LCI','Y')) cust2_lci_ni
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||ni_type,'1008514Savings','Y')) cust2_savings_ni
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||ni_type,'1008514Investments','Y')) cust2_investments_ni
			      from 
			      (
			              select 'IP' ni_type  
			                  , tnipp.FACTFIND_ID
			                  , tfr1.ROLE_TYPE_CODE_ID
			              from salex.t_na_ipp@util.world tnipp
			                  , salex.t_ff_role@util.world tfr1  
			              where tnipp.not_important_flag = 'Y'
			              and TNIPP.FACTFIND_INDIVIDUAL_ID = tfr1.FACTFIND_INDIVIDUAL_ID  
			              union  
			              select 'CI'  
			                  , tnci.FACTFIND_ID  
			                  , tfr1.ROLE_TYPE_CODE_ID
			              from salex.t_na_cic@util.world tnci  
			                  , salex.t_ff_role@util.world tfr1  
			              where tnci.not_important_flag = 'Y'  
			              and tnci.FACTFIND_INDIVIDUAL_ID = tfr1.FACTFIND_INDIVIDUAL_ID  
			              union  
			              select 'LCC'  
			                  , tnc.FACTFIND_ID  
			                  , tfr1.ROLE_TYPE_CODE_ID
			              from salex.t_na_capital@util.world tnc  
			                  , salex.t_ff_role@util.world tfr1  
			              where tnc.not_important_flag = 'Y' 
			              and tnc.FACTFIND_INDIVIDUAL_ID = tfr1.FACTFIND_INDIVIDUAL_ID  
			              union  
			              select 'LCI'  
			                  , tnlc.FACTFIND_ID  
			                  , tfr1.ROLE_TYPE_CODE_ID
			              from salex.t_na_life_cover@util.world tnlc  
			                  , salex.t_ff_role@util.world tfr1  
			              where tnlc.not_important_flag = 'Y'  
			              and tnlc.FACTFIND_INDIVIDUAL_ID = tfr1.FACTFIND_INDIVIDUAL_ID  
			              union  
			              select 'Savings'  
			                  , tns.FACTFIND_ID  
			                  , tfr1.ROLE_TYPE_CODE_ID
			              from salex.t_na_savings@util.world tns  
			                  , salex.t_ff_role@util.world tfr1  
			              where tns.not_important_flag = 'Y'  
			              and tns.FACTFIND_INDIVIDUAL_ID = tfr1.FACTFIND_INDIVIDUAL_ID  
			              union  
			              select 'Investments'  
			                  , tni.FACTFIND_ID  
			                  , tfr1.ROLE_TYPE_CODE_ID
			              from salex.t_na_investments@util.world tni  
			                  , salex.t_ff_role@util.world tfr1  
			              where tni.not_important_flag = 'Y' 
			              and tni.FACTFIND_INDIVIDUAL_ID = tfr1.FACTFIND_INDIVIDUAL_ID  
			      )
			      group by factfind_id
			  	 ) cust_ni
			   ,(
			      select factfind_id
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||na_type,'1008513IP','Y')) cust1_ip_na
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||na_type,'1008513CI','Y')) cust1_ci_na
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||na_type,'1008513LCC','Y')) cust1_lcc_na
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||na_type,'1008513LCI','Y')) cust1_lci_na
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||na_type,'1008513Savings','Y')) cust1_savings_na
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||na_type,'1008513Investments','Y')) cust1_investments_na
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||na_type,'1008514IP','Y')) cust2_ip_na
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||na_type,'1008514CI','Y')) cust2_ci_na
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||na_type,'1008514LCC','Y')) cust2_lcc_na
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||na_type,'1008514LCI','Y')) cust2_lci_na
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||na_type,'1008514Savings','Y')) cust2_savings_na
			            , MAX(DECODE(ROLE_TYPE_CODE_ID||na_type,'1008514Investments','Y')) cust2_investments_na
			      from 
			      (
			              select 'IP' na_type  
			                  , tnipp1.FACTFIND_ID
			                  , tfr2.ROLE_TYPE_CODE_ID
			              from salex.t_na_ipp@util.world tnipp1
			                  , salex.t_ff_role@util.world tfr2
			              where tnipp1.NOT_APPLICABLE_FLAG = 'Y'
			              and tnipp1.FACTFIND_INDIVIDUAL_ID = tfr2.FACTFIND_INDIVIDUAL_ID  
			              union  
			              select 'CI'  
			                  , tnci1.FACTFIND_ID  
			                  , tfr2.ROLE_TYPE_CODE_ID
			              from salex.t_na_cic@util.world tnci1 
			                  , salex.t_ff_role@util.world tfr2 
			              where tnci1.NOT_APPLICABLE_FLAG = 'Y'  
			              and tnci1.FACTFIND_INDIVIDUAL_ID = tfr2.FACTFIND_INDIVIDUAL_ID  
			              union  
			              select 'LCC'  
			                  , tnc1.FACTFIND_ID  
			                  , tfr2.ROLE_TYPE_CODE_ID
			              from salex.t_na_capital@util.world tnc1 
			                  , salex.t_ff_role@util.world tfr2
			              where tnc1.NOT_APPLICABLE_FLAG = 'Y' 
			              and tnc1.FACTFIND_INDIVIDUAL_ID = tfr2.FACTFIND_INDIVIDUAL_ID  
			              union  
			              select 'LCI'  
			                  , tnlc1.FACTFIND_ID  
			                  , tfr2.ROLE_TYPE_CODE_ID
			              from salex.t_na_life_cover@util.world tnlc1 
			                  , salex.t_ff_role@util.world tfr2
			              where tnlc1.NOT_APPLICABLE_FLAG = 'Y'  
			              and tnlc1.FACTFIND_INDIVIDUAL_ID = tfr2.FACTFIND_INDIVIDUAL_ID  
			              union  
			              select 'Savings'  
			                  , tns1.FACTFIND_ID  
			                  , tfr2.ROLE_TYPE_CODE_ID
			              from salex.t_na_savings@util.world tns1 
			                  , salex.t_ff_role@util.world tfr2 
			              where tns1.NOT_APPLICABLE_FLAG = 'Y'  
			              and tns1.FACTFIND_INDIVIDUAL_ID = tfr2.FACTFIND_INDIVIDUAL_ID  
			              union  
			              select 'Investments'  
			                  , tni1.FACTFIND_ID  
			                  , tfr2.ROLE_TYPE_CODE_ID
			              from salex.t_na_investments@util.world tni1 
			                  , salex.t_ff_role@util.world tfr2 
			              where tni1.NOT_APPLICABLE_FLAG = 'Y' 
			              and tni1.FACTFIND_INDIVIDUAL_ID = tfr2.FACTFIND_INDIVIDUAL_ID  
			      )
			      group by factfind_id
			  	 ) cust_na
			   ,(
			      select TNA2.FACTFIND_ID
			         , MAX(DECODE(TFR2.ROLE_TYPE_CODE_ID||TNA2.ATR_PRODUCT_TYPE_CODE_ID,10085131008768, TNA2.ATR_LEVEL)) cust1_protection_level
			         , MAX(DECODE(TFR2.ROLE_TYPE_CODE_ID||TNA2.ATR_PRODUCT_TYPE_CODE_ID,10085131008769, TNA2.ATR_LEVEL)) cust1_savings_level
			         , MAX(DECODE(TFR2.ROLE_TYPE_CODE_ID||TNA2.ATR_PRODUCT_TYPE_CODE_ID,10085131008770, TNA2.ATR_LEVEL)) cust1_investment_level
			         , MAX(DECODE(TFR2.ROLE_TYPE_CODE_ID||TNA2.ATR_PRODUCT_TYPE_CODE_ID,10085131008771, TNA2.ATR_LEVEL)) cust1_pension_level
			         , MAX(DECODE(TFR2.ROLE_TYPE_CODE_ID||TNA2.ATR_PRODUCT_TYPE_CODE_ID,10085141008768, TNA2.ATR_LEVEL)) cust2_protection_level
			         , MAX(DECODE(TFR2.ROLE_TYPE_CODE_ID||TNA2.ATR_PRODUCT_TYPE_CODE_ID,10085141008769, TNA2.ATR_LEVEL)) cust2_savings_level
			         , MAX(DECODE(TFR2.ROLE_TYPE_CODE_ID||TNA2.ATR_PRODUCT_TYPE_CODE_ID,10085141008770, TNA2.ATR_LEVEL)) cust2_investment_level
			         , MAX(DECODE(TFR2.ROLE_TYPE_CODE_ID||TNA2.ATR_PRODUCT_TYPE_CODE_ID,10085141008771, TNA2.ATR_LEVEL)) cust2_pension_level
			      from salex.t_na_atr@util.world tna2
			         , salex.t_ff_role@util.world tfr2
			      where TFR2.FACTFIND_INDIVIDUAL_ID = TNA2.FACTFIND_INDIVIDUAL_ID
			      group by TNA2.FACTFIND_ID
			  	 ) atr
			where TFF.STATUS_CODE_ID = 1008521
			and TFF.FACTFIND_ID = submissions.FACTFIND_ID
			and TFF.FACTFIND_ID = parties.FACTFIND_ID
			and TFF.FACTFIND_ID = expenditure.FACTFIND_ID
			and TFF.FACTFIND_ID = assets.FACTFIND_ID
			and TFF.FACTFIND_ID = liabilities.FACTFIND_ID
			and TFF.FACTFIND_ID = occben.FACTFIND_ID
			and TFF.FACTFIND_ID = protection.FACTFIND_ID(+)
			and TFF.FACTFIND_ID = savings.FACTFIND_ID(+)
			and TFF.FACTFIND_ID = pensions.FACTFIND_ID(+)
			and TFF.FACTFIND_ID = investments.FACTFIND_ID(+)
			and TFF.FACTFIND_ID = atr.FACTFIND_ID(+)
			and TFF.FACTFIND_ID = cust_ni.FACTFIND_ID(+)
			and TFF.FACTFIND_ID = cust_na.FACTFIND_ID(+)
			and TFF.FACTFIND_ID = b_and_c_premium.FACTFIND_ID(+)
			and TFF.FACTFIND_ID = needs.FACTFIND_ID(+)
			and TFF.FACTFIND_ID = sales.FACTFIND_ID(+);

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2008-06-13 at 08:07:46ID23482986
Tags

pl/sql

,

ORA-01000: maximum open cursors exceeded

Topics

Oracle Database

,

PL / SQL

Participating Experts
5
Points
500
Comments
18

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. ora-01000 max open cursors
    Hi, I'm getting those lines in the alert log ORA-00604: error occurred at recursive SQL level 1 ORA-01000: maximum open cursors exceeded ORA-01000: maximum open cursors exceeded I know what it means but frankly I don't know how to approach this problem. I'm never n...
  2. Regarding ORA-01000: maximum open cursors exceed
    Hi, Recently i get error: ORA-01000: maximum open cursors exceed when i tried to updating records in many times. Here is the general documentation what i get: Cause: A host language program attempted to open too many cursors. The initialization parameter OPEN_CURSORS det...
  3. ORA-01000: maximum open cursors exceed
    I am doing servlet programming and having this error ORA-01000: maximum open cursors exceed. I have read something about closing the recordset. I have a connection pool to manage the sql connections. My question is by closing the connection "connection.close()", doe...
  4. ora-1000 max cursors open exceed problem
    hi, guys: I saw someone post their problem like this, but it's no use to me. please help, thanks. before we change our server, it work fine, but after that, it appears ora-1000 message when the cursors reach the max numbers. our environment is below: before: Plat...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: angelIIIPosted on 2008-06-13 at 08:14:50ID: 21779828

the problem is eventually not your code (alone), but all the users/applications using (ie opening) cursors with not closing them...
this is one of the "problematic" situations where your code might not be the culprit, but for example some legacy application.

you might try to increase the setting to allow more open cursors, but if there is a leak in some legacy application, only correcting the actual source of the problem will help ultimately.

 

by: graham_ballPosted on 2008-06-13 at 08:20:25ID: 21779877

I was going to increase the max open cursors as a last resort, but I wanted to eliminate any other cause first.
I'm running this on a test database, where I am the only user.

 

by: rolutolaPosted on 2008-06-13 at 08:25:57ID: 21779923

What about your OPEN_CURSORS parameter?

R.

 

by: graham_ballPosted on 2008-06-13 at 08:28:42ID: 21779948

That's 1024, as I said above.

 

by: rolutolaPosted on 2008-06-13 at 08:41:57ID: 21780081

 

by: johnsonePosted on 2008-06-13 at 09:07:02ID: 21780308

Below is the description of the OPEN_CURSORS parameter from the Oracle documentation.  It is a session level parameter, not a database level parameter.  You must be exceeding 1024 cursors in your session, not database wide.

Also, it may not be just one query that is causing the problem.  That is where the problem manifests itself.  Quite commonly I have seen processes explicitly open cursors and not close them assuming the database will do it when the process diconnects.  A bad practice, but some people do it.

OPEN_CURSORS specifies the maximum number of open cursors (handles to private SQL areas) a session can have at once. You can use this parameter to prevent a session from opening an excessive number of cursors. This parameter also constrains the size of the PL/SQL cursor cache which PL/SQL uses to avoid having to reparse as statements are reexecuted by a user.
 
It is important to set the value of OPEN_CURSORS high enough to prevent your application from running out of open cursors. The number will vary from one application to another. Assuming that a session does not open the number of cursors specified by OPEN_CURSORS, there is no added overhead to setting this value higher than actually needed.

                                              
1:
2:
3:

Select allOpen in new window

 

by: angelIIIPosted on 2008-06-13 at 09:53:44ID: 21780701

side note:
* replace UNION by UNION ALL whenever possible (UNION performs a implicit DISTINCT ...)
* use JOIN  / LEFT JOIN syntax instead of the "old" (+) method
* try to create a (materialized) view on the (remote) server, running/returning some data pre-worked, to reduce the network traffic between the 2

I did not see any function call in the sql, which might open a hidden cursor...

 

by: schwertnerPosted on 2008-06-14 at 00:19:15ID: 21784410

Your code also can do this.
Your program has to have EXCEPTION section and by error to close the opened cursors and release all resources. Possibly not onlythe code  you paste, but also others units running under the same account.

To investigate

set trimspool on
set linesize 1000
break on report
comp sum of curs on report
select SUBSTR(User_Name,1,20) User_Name, SID, count(*) Curs from v$open_cursor group by User_Name,
SID order by User_Name, SID;


I have answered such question and this is the summary of my answers:

You have a JDBC application which runs for several hours.  It then returns the following error:
 ORA-1000 Maximum open cursors exceeded

The open_cursors parameter in init.ora is currently set to a number in excess of the maximum number of cursors you expect your application to have open at any one time.  Increasing open_cursors extends the period of time before failure, but does not resolve the issue.
Solution Description
--------------------
Typically, in Java, when an object goes out of scope, it is automatically garbage collected, but the Java specification does not place any specific requirements on the JVM regarding when (or even if) this will occur for any
particular object.  Therefore, do not rely on finalizers to close your cursors.

Explicity close all cursors ResultSet.close() and Statement.close() when you no longer need the cursor.  This ensures that the corresponding server-side cursors are closed, preventing the ORA-1000 error.

You can query the SQL_TEXT column in V$OPEN_CURSOR view from the schema to determine which cursors are not being closed.  For example:

  select sql_text from v$open_cursor;


Reference
---------

"Oracle8i JDBC Developer's Guide and Reference", Chapter 3 'Basic Features',
Section 'First Steps in JDBC'  

1. You should not use the finally block to reliably close cursors.
2. You should design your code to ensure that the resultSet/cursor and staements go out of scope after the close() method is invoked. This is necessary in order to execute garbage collection and reclaim the memory allocated for cursors



The problem arises often and appear to only have open cursors when using stored procedures and functions.
Try two stragies to resolve the problem:

1) Increase the value for open_cursors in our init.ora file from the default of 50 to 200

2) Have a thread running in our connectionpool class which looks for idle connections older than XX minutes, and then closes them and replaces them by new connections.

The effect of 2) should be to reduce the number of cursors open concurrently. By staggering the open and close we shouldn't put a significant overhead on Oracle or our web splication.
 
-----------
I think Connection.close() will close the resultset of the connection and will help to clear the memory as in the example below



public class JDBCLeak
{
 static
 {
     new oracle.jdbc.driver.OracleDriver();
 }

 public static void main(String args[])
 {
     while (true)
     {
         // replace url, uid, and pwd with valid data.
         Connection dbConnection =
              DriverManager.getConnection(
             url, uid, pwd);
         dbConnection.close();
         System.gc();
     }
 }
}


The following code snippet is always a good coding pattern to follow when using Statement, PreparedStatement and ResultSet.
--------------

Connection conn = getConnection();
PreparedStatement ps = null;
ResultSet rs = null;

try {
 ps = conn.prepareStatement(...);
 rs = ps.execute...

}
catch (SQLException sqe) {
 /* should I handle it? */
}
finally {
 if (rs != null) try { rs.close(); } catch (SQLException) { /* should I handle it? */ }
 if (ps != null) try { ps.close(); } catch (SQLException) { /* should I handle it? */ }
}

Thus, regardless of what happens, you will always correctly close the ResultSet and PreparedStatement. This of course only works if you don't need to pass the ResultSet back and can do all your work within the try {} block.


If you use Oracle 8.1.7:
Some colleagues solve this problem in 8.1.7 setting the init<sid>.ora parameter TIMED_STATICS = TRUE. Also try to use the latest version of 8.1.7 and patchset

Sincerely
Schwertner

 

by: graham_ballPosted on 2008-06-16 at 00:57:22ID: 21791501

What governs the number of cursors that get opened?
I have only got 29 select statements in that piece of code and can't see how it can get anywhere near 100 let alone 1024.
Interestingly, I only have to remove one cursor (any one) from the statement to get it to work.

 

by: schwertnerPosted on 2008-06-16 at 01:28:26ID: 21791658

The application and the procedures.
In many cases the WEB applications open a bunch of sessions with cursors
but do not close them if they are unused.
Also PL/SQL procedures without EXCEPTION handlers leave open cursors after failing.

 

by: graham_ballPosted on 2008-06-16 at 01:35:01ID: 21791693

This is not an application, neither is it expicilty opening cursors.
It is a single sql statement.

 

by: MilleniumairePosted on 2008-06-16 at 03:17:44ID: 21792171

I notice you are using db links to access all the tables.  Do you get the same error if you connect directly to the database referenced by the db links and remove the db links from the sql?

I'm wondering if this is an issue relating to remote database access with such a large, complicated statement.

 

by: MilleniumairePosted on 2008-06-16 at 03:19:53ID: 21792187

Following on from my previous post...

Although your maximum cursors is set high for your current local session, is this session value also applied to the remote session that will be created to satisfy the db links used by your query?

 

by: graham_ballPosted on 2008-06-16 at 03:26:50ID: 21792208

It runs fine on the 'linked' database even with an open cursors setting of 50.
So it looks as if it's the link that's the problem.

Is upping the limit on the linked database tthe answer then ?

 

by: MilleniumairePosted on 2008-06-16 at 03:39:42ID: 21792275

I read somewhere that cursors are allocated 64 at a time up to OPEN_CURSORS, so I would set it to at least 64.  There is no harm in setting a high value other than a little more memory being used for each session.

I confess I'm not exactly sure how cursors are allocated for remote connections, but based on your problem it obviously isn't done very effeciently!!!  If it isn't too much trouble then you should increase the open_cursors init.ora parameter on the remote database as I don't think you'll be able to change this value at the session level as you don't have control over the remote session setting.  Can't remember if this is a dynamic setting, so you may have to bounce the database for it to take effect.

 

by: schwertnerPosted on 2008-06-16 at 05:36:49ID: 21792942

seems your procedure has not Exception section.
You run and run and run the procedure and
it fails, fails , fails ...

As Milleniumaire mentioned there are cursors to remote DB, to local DB
and possibly the stay opened.

If you catch the error and gracefully close the procedure I hope
the cursors will be closed.

 

by: graham_ballPosted on 2008-06-16 at 05:38:28ID: 21792955

It is not a procedure.

 

by: graham_ballPosted on 2008-06-16 at 07:36:49ID: 31466958

It would certainly appear that the dblink uses up cursors. I changed the sql to point to our test database, which we had changed from 50 to 512 open cursors and it worked fine; somewhat faster too!
Thanks.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...