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: Problem with Check Constraint

Re: Problem with Check Constraint

From: Sanjay Jain <jaint_at_worldnet.att.net>
Date: 5 Aug 1998 23:56:17 GMT
Message-ID: <6qarf1$mab@bgtnsc02.worldnet.att.net>


try using this as the check constraint condition to_char(logdatetime,'HH24:MI') between '09:30' and '16:40'

justvrk_at_my-dejanews.com wrote in message <6q43id$j3l$1_at_nnrp1.dejanews.com>...
>I have designed a table containing a Date column(LogDateTime) required to
>store date and time together. I want to ensure that the time values stored
in
>this column are between 09:30 and 16:40 (HH24 format).
>
>For this I tried the following:
>
>alter table logdata
> add constraint cons_logtimechk
> check(to_date(to_char(LogDateTime,'DD-MON-YYYY HH24:MI')
> ,'DD-MON-YYYY HH24:MI') >= to_date('09:30','HH24:MI')
> and to_date(to_char(LogDateTime,'DD-MON-YYYY HH24:MI'),
> 'DD-MON-YYYY HH24:MI') <= to_date('16:30','HH24:MI'))
>/
>
>To Which Oracle Server responded with :
>
>ORA-02436: date or system variable wrongly specified in CHECK constraint
>
>** My Idea about using to_char and back to_date is that it should check
time
>irrespective of the date. By doing so imply that the date defaults to DB
date
>on both sides of the relational operator.
>
>I am working on Oracle 8 loaded on Solaris 2.6
>
>Can anybody explain me where I am going wrong
>
>Thanks in Advance,
>Vinayak.
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
Received on Wed Aug 05 1998 - 18:56:17 CDT

Original text of this message

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