• 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

Stored Procedure question

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hope this is the right forum..

I'm using sybase and my question relates to the possibility of using a stored procedure for two different queries. At the moment I have two stored procedures:





How to exactly combine the two stored procedures and use the correct WHERE statement depending on a parameter say.

Sorry if I'm not really clear.
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dan,
The code you have posted is for two queries -- not two stored procedures.


Sorry if I'm not really clear.


Unfortunately, your question is not clear (to me, at least).
I suggest you supply an example of the data in the "dbo.Table" database table,
and the desired output from your "combined" query. Then I might understand
what you mean by:


How to exactly combine the two stored procedures


Good Luck,
Avi.
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dan,

As Avi says, it's not very clear what you're trying to do as this is a lot of ambiguity.

If I understand you correctly you have two stored procedures that contain the two queries you've supplied (or do you just have two queries?).

Regardless, you want to combine them into one query (or do you just want to use one SP?). The main problem is that one query uses "=" and the other uses "<>" so you can't easily combine them.

Let's say your full set of statuses is "OK", "MAYBE" and "NO". You could then change your queries to read as follows:

The queries are now in the same format and could be combined programmatically, but I can't see any advantage of doing it and thus complicating what were otherwise two very clear and concise queries.

I have a lot of experience of relational databases and I don't see anything wrong with having two separate stored procedures for the two separate queries that you've defined.

I hope this helps to answer your question.

Regards

Jules
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic