• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exceptions don't work good in cursor

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for all tipps it works now)))
 
Popeye has his spinach. I have this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic