| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: saving username and sysdate on insert/update
On Mon, 19 Apr 1999 12:40:50 GMT, ToneCzar_at_erols.com (Chris Hamilton)
wrote:
>On insert, you don't need the trigger at all. Just set the DEFAULT
>value of the column to the value:
>
>alter table X modify (adddte default sysdate, addusr default
>rtrim(user));
>
>Note you should use rtrim(user) instead of simply the pseudo-column
>"user", since this column is blank-padded out to 30 characters.
On which release is this true? I've been using the "DEFAULT user" without any RTRIM on several different releases and haven't noticed the behaviour you described. I got a bit worried, so I just performed a test on Personal Oracle 7.3.2:
SCOTT_at_PO73> select length(user), user from dual;
LENGTH(USER) USER
------------ ------------------------------
5 SCOTT
SCOTT_at_PO73> create table t1 (c1 number, c2 varchar2(30) default user);
Table created.
SCOTT_at_PO73> insert into t1(c1) values(1);
1 row created.
SCOTT_at_PO73> select c1, c2, length(c2) from t1;
C1 C2 LENGTH(C2)
---------- ------------------------------ ----------
1 SCOTT 5
>Chris
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>Christopher Hamilton
>Oracle DBA -- Wall Street Sports
>chris_at_wallstreetsports.com
>http://www.wallstreetsports.com/
Regards,
Jurij Modic <jmodic_at_src.si>
Certified Oracle7 DBA (OCP)
![]() |
![]() |