Re: Trigger HELP

"Tony Andrews" <[email protected]> Thu, 24 Apr 2003 10:41:41
Newsgroups gmane.comp.db.oracle.devel
Message-ID <LYRIS-1796914-958250-2003.04.24-10.20.49--gcdod-oracle#[email protected]>
> Yes it works like this, but want it like to_char(sysdate, 'DD-MON-YYYY 
HH24:MI:SS')

No, you don't.  If you follow c.r.farmer's correct advice you WILL be 
storing the date and time that you want.  By using TO_CHAR you are causing 
Oracle to convert the character string back to a DATE before assigning it 
to the column.  Oracle will use the default format mask (probably DD-MON-
RR) which does NOT have a time component and so will get an error like:

ORA-01830: date format picture ends before converting entire input string

From: [email protected] 
Reply-To: "Oracle" 
To: "Oracle" 
Subject: [oracle] Re: Trigger HELP 
Date: Thu, 24 Apr 2003 09:44:39 +0100 


If you have defined date_created as a date then you should be able to set 

:new.date_created = sysdate; 

I have a table in which I will want a date and time to be stored when a 
visitor visits my site and fills the form. I have a trigger that 
automatically inserts the date, but the time. 
http://www.netikka.net/leo 
Here is my code 

create or replace trigger visitor_date_created 
before insert on visitors 
for each row 
begin 
:new.date_created := to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS'); 
end; 

But this returns an error. 

---
Change your mail options at http://p2p.wrox.com/manager.asp or 
to unsubscribe send a blank email to [email protected].