473,671 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3852
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****@sommarsk og.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_AllT ypes 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****@sommarsk og.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
2127
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 stored procedure we believe is at fault, after which no error check was being performed. Under certain conditions, this update is fired against the same record in the same table as the immediately preceding update statement within
6
16318
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 trouble optimizing things. So my question is, is there some way to have a subselect return multiple columns and break those out in the outer query? Something like: SELECT x,y,z,
3
7189
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 whenever a table is renamed with the AS keyword. Furthermore, in PostgreSQL when the result of a subselect is referenced in an outer select it is required that the subselect result be named, whereas this is not true in Oracle. I wonder what standard SQL...
1
6122
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
2744
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 makes them both keep running long enough that a communications error is the only result returned so far. This is a federated view computer ~160 k rows, computer_sys_id is PK . matched_sware ~ 18 million no PK , no index. Any suggestions on...
6
26534
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 regards
2
5450
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
5
1489
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 to distribute this application to clients. I definitely don't like them to look at my stored procedure. Is there a way I can protect the source code of my stored procedure? What
5
3766
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, P_ID_3=ID WHERE PARENT_ID IN (SELECT P_ID_2
0
8393
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8914
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8598
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6223
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5695
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4224
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2810
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1809
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.