Here I have used like this but not working please provide me the solution
IF 'select topic1 from tblscmipklimipcmapprovalio2269 t except select miptopic1 from tblmiptopic1master tm' THEN
BEGIN
topic := topic1;
execute 'insert into tblmiptopic1master (miptopic1 , createdby , createdon , updatedby , updatedon , active) values
(topic,22,'',55,'',1)';
END;
```
insert into tblmiptopic1master
(miptopic1, createdby, createdon, updatedby, updatedon, active)
select topic1, 22, '', 55, '', 1
from tblscmipklimipcmapprovalio2269 t
where not exists (
select * from tblmiptopic1master nx
where nx.miptopic1 = t.topic1
);
If you want the topic to be unique, then you should let the database control the data integrity:
alter table tblmiptopic1master add constraint unq_tblmiptopic1master_miptopic1
unique (miptopic1);
Then you would phrase the insert
as:
insert into tblmiptopic1master (miptopic1, createdby, createdon, updatedby, updatedon, active)
select topic1, 22, '', 55, '', 1
from tblscmipklimipcmapprovalio2269 t
on conflict (miptopic1) do nothing;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.