|
-
Actually, the problem laid on the trigger that associate with the table, the part starting with
select nvl(keypart1_use,'nothing').....
if .......
If I comment out that section there is no problem, just that primary key platformid is not generated. So I'm not too sure if there is something wrong with it.
I was trying to do insert as:
INSERT INTO Platforms (Platform, DefAssignedToType, KeyPart1_Use, KeyPart2_Use, KeyPart3_Use, DistributedSystem, AllowNoCharge, SupportFac, VendorID)
VALUES ('Test Platform', 'n/a','User ID','Password',null,0, 0,0,560);
**************************
The trigger codes are:
create or replace trigger tri_platforms
before insert on platforms
for each row
declare
stoo_selcnt integer;
stoo_error integer;
stoo_rowcnt integer := 1;
stoo_crowcnt integer := 0;
stoo_fetchstatus integer := 0;
stoo_errmsg varchar2(255);
stoo_sqlstatus integer;
num_of_rows number(10,0);
noruntrg number(1);
v_next_id integer;
v_keypart1_use varchar(16);
v_keypart1indic integer;
v_keypart2_use varchar(16);
v_keypart2indic integer;
v_keypart3_use varchar(16);
v_keypart3indic integer;
begin
num_of_rows := stoo_rowcnt ;
if num_of_rows = 0 then
return ;
end if ;
begin
noruntrg := checkruntrigger ;
if (noruntrg = 1) then
begin
dbms_output.put_line('trigger is bypassed') ;
return ;
end;
end if ;
end ;
select count(*) into num_of_rows
from mdsvendors v
where :new.vendorid=v.vendorid;
if num_of_rows=0 then
begin
RAISE_APPLICATION_ERROR(-20500,'Trigger forces a rollback');
ROLLBACK ;
raise_application_error(-20999, 3100 || '-' || 'Unable to insert.');
return;
end;
end if;
select next_id into v_next_id
from next_id
where table_name='Platforms';
:new.platformid:=v_next_id+1;
update next_id
set next_id=next_id+1
where table_name='Platforms';
select nvl(keypart1_use,'nothing'),nvl(keypart2_use,'nothing'),nvl(keypart3_use,'nothing')
into v_keypart1_use,v_keypart2_use, v_keypart3_use
from platforms
where platform=:new.platform;
dbms_output.put_line('The values are'||v_keypart1_use||','||v_keypart2_use||','||v_keypart3_use);
/ if (v_keypart1_use = 'nothing') then
v_keypart1indic := 0;
else
v_keypart1indic := 1;
end if;
if (v_keypart2_use = 'nothing') then
v_keypart2indic := 0;
else
v_keypart2indic := 1;
end if;
if (v_keypart3_use = 'nothing') then
v_keypart3indic := 0;
else
v_keypart3indic := 1;
end if;
insert into platformmapkeys( platformid, keypart1indic, keypart2indic, keypart3indic )
select platformid, v_keypart1indic, v_keypart2indic, v_keypart3indic
from platforms
where platform=:new.platform;
end tri_platforms;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|