TMTOWTDI:  Since Perl is a procedural language, you can just fetch the first
row you
want.

   $dbh -> {RaiseError} = 1;
   my $uptime;
   my $sth -> prepare( "select uptime
                                   from uptime
                                   where hostname = ?
                                   order by startdate desc" );
   $sth -> execute( $host );
   ( $uptime ) = $sth -> fetchrow_array; # Just take the first row
   $sth -> finish;
--
Mac :})
** I normally forward private database questions to the DBI mail lists. **
Give a hobbit a fish and he'll eat fish for a day.
Give a hobbit a ring and he'll eat fish for an age.
----- Original Message -----
From: "Dan Hoover" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 15, 2001 1:12 PM
Subject: RE: single row query rteturn more than one row


> You could also..
>
>  sql=select up_time from uptime where
>              startdate = (select distinct startdate
>                                    from uptime where
>                                    hostname = 'twister'
>                                    order by startdate desc) ;
>
> Dan
>
> -----Original Message-----
> From: Ronald J Kimball [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 15, 2001 4:02 PM
> To: Xiaoxia Dong
> Cc: [EMAIL PROTECTED]
> Subject: Re: single row query rteturn more than one row
>
>
> On Thu, Mar 15, 2001 at 02:43:45PM -0500, Xiaoxia Dong wrote:
> > i got following message when i run sql statement as sql
> >
> > sql=select up_time from uptime where
> >              startdate = (select GREATEST(startdate)
> >                                   from uptime where
> >                                   hostname = 'twister')
> > DBD::Oracle::st execute failed: ORA-01427: single-row subquery returns
>
> > more than one row (DBD ERROR: OCIStmtExecute) at upget.pl line 35.
> >
> > ORA-01427: single-row subquery returns more than one row (DBD ERROR:
> > OCIStmtExecute)
> >
> > i only have one row under hostname 'twister' in the table and it runs
> > fine under oracle sql>.
>
> GREATEST() is the wrong function to use here.  I believe you want MAX()
> instead.
>
> Ronald
>
>


Reply via email to