Path: news.easynews.com!core-easynews!newsfeed3.easynews.com!easynews.com!easynews!news.glorb.com!news2.euro.net!postnews1.euro.net!news.wanadoo.nl!not-for-mail
From: Jaap W. van Dijk <j.w.vandijk.removethis@hetnet.nl>
Newsgroups: comp.databases.oracle.server
Subject: Re: Simple question ...
Date: Sun, 08 Aug 2004 10:52:54 +0200
Message-ID: <mspbh0penfl44h45vk7g9748p2403joell@4ax.com>
References: <cf005n$6os$1@balena.cs.interbusiness.it> <0it7h0lgpq0mehdid660929utqiht91i8o@4ax.com> <ips8h0d57h084qp3sblb96i0hljvj9q3r6@4ax.com>
X-Newsreader: Forte Free Agent 1.92/32.572
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 35
Organization: Wanadoo
NNTP-Posting-Date: 08 Aug 2004 08:52:55 GMT
NNTP-Posting-Host: p0794.nas3-asd6.dial.wanadoo.nl
X-Trace: 1091955175 snatched.euronet.nl 31045 62.234.219.31:1094
X-Complaints-To: abuse@wanadoo.nl
Xref: core-easynews comp.databases.oracle.server:227797
X-Received-Date: Sun, 08 Aug 2004 01:51:57 MST (news.easynews.com)

On Sat, 07 Aug 2004 08:15:35 +0200, Sybrand Bakker
<gooiditweg@sybrandb.verwijderdit.demon.nl> wrote:

>On Fri, 06 Aug 2004 23:25:15 +0200, Jaap W. van Dijk
><j.w.vandijk.removethis@hetnet.nl> wrote:
>
>>On Fri, 6 Aug 2004 15:13:24 +0200, "Ernest Morariu"
>><ernest@gesora.com> wrote:
>>
>>...
>>>
>>>SELECT myField INTO myVariable FROM myTable WHERE myCondition;
>>>
>>...
>>
>>You could alter this slightly:
>>
>>SELECT MAX(myField) INTO myVariable FROM myTable WHERE myCondition;
>>
>>In case of no records this will yield NULL
>>In case of one record this will yield myField
>>
>>But note: the case of more than one record will now not error.
>>
>>Jaap.
>
>It will also fetch all affected records and conduct an internal sort
>on them. A pretty inefficient solution.

The OP wants to retrieve 1 record, with the possibility that zero
records will be retrieved. So in this case 'all affected records' will
be one at the most. 

Jaap.

