🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #3752

Re: Problems with a querry in ADODataSet

#3752
From: Vassiliev V.V.
Date: Wed, 03 Jul 2002 07:35
116 lines
4989 bytes
Read this atricle from Books Online.

Regards,
Vassiliev V.V.
http://www.oledbdirect.com

Subqueries with Comparison Operators
Subqueries can be introduced with one of the comparison operators (=, < >,
>, > =, <, ! >, ! <, or < =).
A subquery introduced with an unmodified comparison operator (a comparison
operator not followed by ANY or ALL) must return a single value rather than
a list of values, like subqueries introduced with IN. If such a subquery
returns more than one value, Microsoft� SQL ServerT displays an error
message.
To use a subquery introduced with an unmodified comparison operator, you
must be familiar enough with your data and with the nature of the problem to
know that the subquery will return exactly one value.
For example, if you assume each publisher is located in only one city, and
you want to find the names of authors who live in the city in which Algodata
Infosystems is located, you can write a statement with a subquery introduced
with the simple = comparison operator.
USE pubs
SELECT au_lname, au_fname
FROM authors
WHERE city =
   (SELECT city
   FROM publishers
   WHERE pub_name = 'Algodata Infosystems')

Here is the result set:
au_lname      au_fname
--------      --------
Carson      Cheryl
Bennet      Abraham

(2 row(s) affected)

If, however, Algodata Infosystems was located in multiple cities, then an
error message would result. Instead of the = comparison operator, an IN
formulation could be used (= ANY also works).
Subqueries introduced with unmodified comparison operators often include
aggregate functions, because these return a single value. For example, this
statement finds the names of all books priced higher than the current
minimum price.
USE pubs
SELECT DISTINCT title
FROM titles
WHERE price >
   (SELECT MIN(price)
   FROM titles)

Here is the result set:
title
----------------------------------------------------------
But Is It User Friendly?
Computer Phobic and Non-Phobic Individuals: Behavior Variations
Cooking with Computers: Surreptitious Balance Sheets
Emotional Security: A New Algorithm
Fifty Years in Buckingham Palace Kitchens
Is Anger the Enemy?
Life Without Fear
Onions, Leeks, and Garlic: Cooking Secrets of the Mediterranean
Prolonged Data Deprivation: Four Case Studies
Secrets of Silicon Valley
Silicon Valley Gastronomic Treats
Straight Talk About Computers
Sushi, Anyone?
The Busy Executive's Database Guide

(14 row(s) affected)

Because subqueries introduced with unmodified comparison operators must
return a single value, they cannot include GROUP BY or HAVING clauses unless
you know the GROUP BY or HAVING clause itself returns a single value. For
example, this query finds the books priced higher than the lowest priced
book that has a type 'trad_cook'.
USE pubs
SELECT DISTINCT title
FROM titles
WHERE price >
   (SELECT MIN(price)
   FROM titles
   GROUP BY type
   HAVING type = 'trad_cook')

Here is the result set:
title
------------------------------------------------------------------------
But Is It User Friendly?
Computer Phobic AND Non-Phobic Individuals: Behavior Variations
Onions, Leeks, and Garlic: Cooking Secrets of the Mediterranean
Prolonged Data Deprivation: Four Case Studies
Secrets of Silicon Valley
Silicon Valley Gastronomic Treats
Straight Talk About Computers
Sushi, Anyone?
The Busy Executive's Database Guide

(9 row(s) affected)

�1988-2000 Microsoft Corporation. All Rights Reserved.

"Emilio Rodriguez" <sistemas@acisa.es> ???????/???????? ? ????????
?????????: news:3D2158A0.8033A3D6@acisa.es...
> Hello,
>
> I'm doing a programs with a database MSDE(SQL Server). I attack the
> database with ADOConection and ADODataSet. When I filter or conecct
> sometimes the programs throw this exceptions: "Subquerry returned more
> than 1 value. This is not permited when the subquerry follow
> =,!=,<,<=,>,>= or when the subquerry is used as and expresion". Someone
> know why the programs throw this exception?
>
> Thank you for all,
> Emilio
>
Technical Details
Message-ID: <3d22aea0_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-08!supernews.com!iad-peer.news.verio.net!news.verio.net!news.maxwell.syr.edu!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews
References: <3D2158A0.8033A3D6@acisa.es>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10698b,795126561202782
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2002-07-03 01:03:47 PST
From: "Vassiliev V.V." <news@vassilievvv.mtu-net.ru>
Newsgroups: borland.public.cppbuilder.database.ado
References: <3D2158A0.8033A3D6@acisa.es>
Subject: Re: Problems with a querry in ADODataSet
Date: Wed, 3 Jul 2002 11:35:12 +0400
Lines: 118
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 62.118.134.114
Message-ID: <3d22aea0_1@dnews>
X-Trace: dnews 1025683104 62.118.134.114 (3 Jul 2002 00:58:24 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-08!supernews.com!iad-peer.news.verio.net!news.verio.net!news.maxwell.syr.edu!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews