Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Timestamp SQL question

Re: Timestamp SQL question

From: DA Morgan <damorgan_at_psoug.org>
Date: Mon, 18 Jul 2005 09:25:48 -0700
Message-ID: <1121703952.762784@yasure>


Oxnard wrote:

> Sorry if I did not make myself clear.
> The query
>
> select username, sid, serial#, logon_time, to_timestamp(logon_time)
> from v$session
> where to_timestamp(logon_time) = (select to_timestamp(logon_time)
> from v$session where
> username = 'SYS')
> order by logon_time
>
> should only be returning one row assuming there is one connection as SYS and
> no other user logged on at the same time as SYS. However I find all rows are
> returned. That is what I am wondering why.

You were very clear but that is not what your query is written to do. And the difference, I thought, would be clear if you ran my modification of your SQL statement. So lets do this in words rather than pictures.

  1. Subquery gets a logon_time that relates to the user SYS but is not exclusive to a single longon.
  2. Query returns each and every session that logged on at the same time as SYS.

Run the query I provided you again and it should be very obvious that what you have written does not do what you want. As I tell my students: Computers do what you ask them to do ... not what you want them to do.

-- 
Daniel A. Morgan
http://www.psoug.org
damorgan_at_x.washington.edu
(replace x with u to respond)
Received on Mon Jul 18 2005 - 11:25:48 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US