Sequence & DEFAULT klauzule (ORA 8.0.5)
Andrey Lukichev
anw na jet.msk.su
Pondělí Leden 17 18:10:08 CET 2000
>Omlouvám se, ten jedem řádek jsem přehlédl...
>Ovšem tím triggerem jsem původně začal, ale nějak jsem jej nepřekonal:
>
> create or replace trigger trigger_name before insert on tabulka for each
>row
> begin
> :new.column_name := sequence_name.NEXTVAL;
> end;
Khm. Sorry again my czech, but this trigger work fine:
create or replace trigger syslog_trg
before insert on syscon.syslog
for each row
declare
new_id NUMERIC;
begin
select syscon_seq.NEXTVAL into new_id from dual;
-- ALTERNATE way ;)
-- s_cursor :=DBMS_SQL.OPEN_CURSOR;
-- DBMS_SQL.PARSE(s_cursor,'SELECT syscon_seq.NEXTVAL from dual',1);
-- DBMS_SQL.DEFINE_COLUMN(s_cursor,1,num);
-- r_processed := DBMS_SQL.EXECUTE_AND_FETCH(s_cursor);
-- DBMS_SQL.COLUMN_VALUE(s_cursor,1,num);
-- DBMS_SQL.CLOSE_CURSOR(s_cursor);
-- DBMS_OUTPUT.enable;
-- :new.node_name := upper(:new.node_name);
-- :new.fac := rpad(:new.fac,7,' ');
-- :new.priority := lpad(:new.priority,7,' ');
:new.msg_id := new_id;
exception
WHEN OTHERS THEN
BEGIN
status := SQLCODE;
END;
END;
Další informace o konferenci Test