Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Oracle/PHP Question
I've just been working on the "auto" aspect - a trigger. matbe this example will help you a bit? I just cut'n'paste the bits into PL/SQL. An an insert thereafter behaves properly.
drop table english_month_names;
drop sequence seq_english_month_names;
drop trigger english_month_names_trigger;
create table english_month_names(
k_english_month_names number default 0 not null primary key
,dt_create varchar2(40)
,dt_updated varchar2(40)
,flg_deleted NUMBER default 0
,str_month_name VARCHAR2(50) not null
);
create sequence seq_english_month_names
increment by 1 start with 1 nomaxvalue;
CREATE TRIGGER english_month_names_trigger
before INSERT ON english_month_names
for each row
declare
temp_var number; temp_dt varchar2(40); Begin select seq_english_month_names.NEXTVAL into temp_var from dual; select to_char(sysdate, 'YYYY-MM-DD HH24:MI:SS') into temp_dt from dual; :new.k_english_month_names := temp_var; :new.dt_create := temp_dt; :new.dt_updated := temp_dt; :new.flg_deleted := 0;
![]() |
![]() |