473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Is a subselect possible on a stored procedure

kjc

I have a stored procedure what produces N number of rows.
The rows are ordered by a cataegoryType as follows

catA
catB
catC
What is needed to do on the C++ code side is break these out into
their respective categories by iterating through the rows and checking
the category type. Is there a way to let the DB do this via some sort of
subselect on the rows returned via the stored procedure.

Thanks in advance.

Jul 20 '05 #1
3 3833
kjc (ks*****@elp.rr.com) writes:
I have a stored procedure what produces N number of rows.
The rows are ordered by a cataegoryType as follows

catA
catB
catC
What is needed to do on the C++ code side is break these out into
their respective categories by iterating through the rows and checking
the category type. Is there a way to let the DB do this via some sort of
subselect on the rows returned via the stored procedure.


I'm sorry, but I don't understand the question. Maybe you could clarify
with an example?

(I do suspect though, that whatever you are trying to do, you should do it
on the the C++ side.)
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
kjc
Thanks for the reply.
I guess what I'm trying to say is that the stored procedure returns
what amounts to a heterogeneous collection. If I made three separate
calls to the DB I would not have this problem ie..

call stored_proc_for_typeA
call stored_proc_for_typeB
call stored_proc_for_typeC
But, this is inefficient, so I'm making one call to a stored procedure
to like
call stored_proc_for_AllTypes

But, on the C++ side, these still must be broken out based on the type.


Erland Sommarskog wrote:
kjc (ks*****@elp.rr.com) writes:
I have a stored procedure what produces N number of rows.
The rows are ordered by a cataegoryType as follows

catA
catB
catC
What is needed to do on the C++ code side is break these out into
their respective categories by iterating through the rows and checking
the category type. Is there a way to let the DB do this via some sort of
subselect on the rows returned via the stored procedure.

I'm sorry, but I don't understand the question. Maybe you could clarify
with an example?

(I do suspect though, that whatever you are trying to do, you should do it
on the the C++ side.)


Jul 20 '05 #3
kjc (ks*****@elp.rr.com) writes:
I guess what I'm trying to say is that the stored procedure returns
what amounts to a heterogeneous collection. If I made three separate
calls to the DB I would not have this problem ie..

call stored_proc_for_typeA
call stored_proc_for_typeB
call stored_proc_for_typeC
But, this is inefficient, so I'm making one call to a stored procedure
to like
call stored_proc_for_AllTypes

But, on the C++ side, these still must be broken out based on the type.


I still don't understand what you are after.

Obviously you stored_for_AllTypes can say:

SELECT * FROM tbl WHRE type = 'typeA'
SELECT * FROM tbl WHRE type = 'typeB'
SELECT * FROM tbl WHRE type = 'typeC'

But that is not very much more efficient than making three stored procedure
calls.

But I don't see the problem for the C++ code. You get the data into some
data structure, depending on which client library you use. Using an
ORDER BY clause in the SQL makes it a little simpler for the C++ code
to find the boundaries.

(Actually there is a way to produce more than one result set from query,
by using the COMPUTE BY clause. But I would recommend use of this
deprecated feature.)

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: M Wells | last post by:
Hi All, Further to my previous long-winded question about a situation in which we appear to be mysteriously losing data from our mssql2k server. We discovered an update statement, in the...
6
by: Greg Stark | last post by:
So I have a query in which some of the select values are subqueries. The subqueries are aggregates so I don't want to turn this into a join, it would become too complex and postgres would have...
3
by: Neil Zanella | last post by:
Hello, I would like to ask the about the following... PostgreSQL allows tables resulting from subselects to be renamed with an optional AS keyword whereas Oracle 9 will report an error...
1
by: Mike L. Bell | last post by:
Query: update table1 t1 set end_time = ( select end_time from table2 t2 where t2.key1 = t1.key1 and t2.key2 = t1.key2 ) where exists
4
by: James | last post by:
I have a performance problem with the following query and variations on the subselect. The EXISTS version of the first example will complete in ~10 minutes. The NOT logic in both the examples...
6
by: Terentius Neo | last post by:
Is it possible to combine (in DB2 UDB 8.1) a stored procedure and a select statement? I mean something like this: Select c.number, call procedure( c.number ) as list from table c With best...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
5
by: Guoqi Zheng | last post by:
Dear sir, I am about to finish a new asp.net application, I used a lot of ms sql stored procedure. Those stored procudure I think is the most important part of the application. Now I am about...
5
by: Bart op de grote markt | last post by:
Hello, I have a problem with a subselect I use in a stored procedure: UPDATE #TEMP_TABLE SET P_ID_1=(SELECT top 1 b.P_ID_1 from #TEMP_TABLE b where b.ID=PARENT_ID), P_ID_2=PARENT_ID,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.