Oracle 10g problem with trigger
this is my first attempt with Oracle I would like use foreign key.
First I create some table, with autoincrement ID:
create table kruzky_tab(
kruzokid number primary key not null,
meno varchar2(50) not null,
pocet number not null
)
create sequence kruzky_tab_seq
start with 1
increment by 1
nomaxvalue;
create trigger kruzky_tab_trigger
before insert on kruzky_tab
for each row
begin
select kruzky_tab_seq.nextval into :new.kruzokid from dual;
开发者_JAVA百科 end;
Then I create second table with foreign key on table above:
create table studenti_tab(
studentid number primary key not null,
meno varchar2(50) not null,
priezvisko varchar2(50) not null,
email varchar2(50) not null,
kruzokid references kruzky_tab
)
I try create same autoincrement trigger for studentid:
create sequence stundenti_tab_seq
start with 1
increment by 1
nomaxvalue
create trigger studenti_tab_trigger
before insert on studenti_tab
for each row
begin
select studenti_tab_seq.nextval into :new.studnetid from dual;
end;
I get this error:
ERROR at line 2: PLS-00049: bad bind variable 'NEW.STUDNETID'
1. create trigger `studenti_tab_trigger`
2. before insert on `studenti_tab`
3. for each row
4. begin
Trigger has same logic as trigger in kruzky_tab
table on the top.
What is bad? Thanks.
Make sure to rule out all typos of the identifier names, it looks as if you have some wrong characters in your identifiers:
create sequence stundenti_tab_seq
(a "n" too much)
select studenti_tab_seq.nextval into :new.studnetid from dual;
(sequence name does not match, new.studnetid
is wrong)
精彩评论