Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: newbie SQL question
"Thomas J. Kyte" wrote:
>
> In article <393D6762.58E845D5_at_Unforgetable.com>,
> Walter T Rejuney <BlueSax_at_Unforgetable.com> wrote:
> > > Halim Setiyawan wrote:
> > >
> > > Can anyone tell me a sql command in Oracle 8i that selects/updates
> > > only the first entry if there are multiple entries to be return?
> > >
> > > Any help will be appreciated.
> > >
> > > Halim.
> >
> > Ever heard of writing a program? You can't do what you want with just
a
> > single select statement most likely but it would be a breeze to handle
> > in a pl/sql,pro-c or VB program.
> >
>
> kcs as wtr--
>
> this is easy:
>
> update T
> set ....
> where ....
> AND ROWNUM = 1;
>
> or
>
> select * from ( select * from T where ... )
> where rownum = 1;
>
Didn't take long for you to catch on. I had to make the change for a couple different reasons.
The solution you give is fine except that it makes several assumptions that cannot be generalized - particularly it might give unpredictable result depending on indexes and if an order-by clause is used. Received on Wed Jun 07 2000 - 00:00:00 CDT
![]() |
![]() |