Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Advice needed: Insert user in a field via TRIGGER
Just to add to this,
You could achieve the same result by:
alter table x modify (col_a varchar2(10) default substr(user,1,10));
This way you donot need a trigger at all.
Thomas Kyte wrote in message <36528227.2901932_at_192.86.155.100>...
>A copy of this was sent to Pablo.picasso_at_cyberdude.com (Pablo Picasso)
>(if that email address didn't require changing)
>On Tue, 17 Nov 1998 13:00:56 GMT, you wrote:
>
>>Hi all,
>>
>>can someon tell me please how to write a trigger which fires on
>>insert and writes the actual user-name in a field ?
>>
>>I wrote one which is inserted with compilation errors ..
>>
>>CREATE OR REPLACE TRIGGER BEFORE INSERT ON LEXIKON
>>BEGIN
>> SELECT USER INTO NEW.BENUTZER FROM DUAL;
>>END
>>
>>AND I tried this one :
>>
>>CREATE OR REPLACE TRIGGER BEFORE INSERT ON LEXIKON
>>DECLARE
>> dummy varchar)30);
>>BEGIN
>> SELECT USER INTO :dummy FROM DUAL;
>> NEW.BENUTZER = :dummy;
>>END
>>
>
>it would simply be:
>
>CREATE OR REPLACE TRIGGER
>BEFORE INSERT ON LEXIKON
>FOR EACH ROW
>BEGIN
> :new.benutzer := USER;
>end;
>
>
>the triggers needs to
>
>- be a BEFORE, FOR EACH ROW trigger
>- write to the variables :new.{fieldname}
>
>
>
>
>>
>>But both didn't work..
>>
>>Thanks in advance
>>
>>Oliver
>
>
>Thomas Kyte
>tkyte_at_us.oracle.com
>Oracle Government
>Herndon VA
>
>--
>http://govt.us.oracle.com/ -- downloadable utilities
>
>---------------------------------------------------------------------------
-
>Opinions are mine and do not necessarily reflect those of Oracle
Corporation
>
>Anti-Anti Spam Msg: if you want an answer emailed to you,
>you have to make it easy to get email to you. Any bounced
>email will be treated the same way i treat SPAM-- I delete it.
Received on Wed Nov 18 1998 - 09:16:27 CST