Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Exceptions don't work good in cursor

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I need to write for a cursor who dispay a list of employees selected mit paramaters from_employee and to_employee two exceptions. First need to work when there is no rows were selected and another one when just one row was selected. My code just blocks all the time sqldeveloper and it starts to nerve. I need a help!!!
 
Bartender
Posts: 598
26
Oracle Notepad Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is this even a Stored Procedure? It ought to be a VIEW. But, anyway, a number of comments (and personal preferences):

1) When declaring variable, you correctly use %TYPE. That should also be used in the declaration of parameters. Something like:

2) What exactly does this procedure do? It just outputs to the console? If so, just use a VIEW, it is faster and simpler. If it is to return to the caller, there are going to be issues when there is more than one record. Nonetheless, if you want to print out each record separately, just use a FOR with an implicit CURSOR and move the parameters into the query itself:

3) If you need to know how many records were returned, just use a counter variable. Declare it on top and set it to 0. Then increment it in the loop.

(I do not think i have Oracle installed at home. So, this is completely untested.)
 
niki viki
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for all tipps it works now)))
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!