File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Stored Procedure question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Stored Procedure question" Watch "Stored Procedure question" New topic

Stored Procedure question

Dan Gun

Joined: Aug 06, 2003
Posts: 26
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.

SCJP 1.4
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1141

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,
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
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.


I agree. Here's the link:
subject: Stored Procedure question
It's not a secret anymore!