Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stored Procedure question

 
Dan Gun
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • 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.
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic