GRIMS Insert names

From ICISWiki

Jump to: navigation, search

Insert into NAMES table


Initial insertion to names query needs the sql scrip below:


insert into names 
select
names_seq.nextval, a.gid, 1, 0,-1,'IRGC ' || lpad(a.accno,6,'0') ,nvl(b.cntryid,0),nvl(to_char(acq_date,'yyyymmdd'),0),0,1
from passport1 a, iris_central.cntry b
where a.ori_country=b.isothree(+)
/

insert into names 
select
names_seq.nextval, a.gid, 6, 0,-1,a.varname,nvl(b.cntryid,0),nvl(to_char(acq_date,'yyyymmdd'),0),0,1
from passport1 a, iris_central.cntry b
where a.ori_country=b.isothree(+)
and varname is not null
/

insert into names 
select names_seq.nextval, a.gid, 9, 0,-1,a.coll_no,nvl(b.cntryid,0),nvl(to_char(acq_date,'yyyymmdd'),0),0,1
from passport1 a, iris_central.cntry b
where a.ori_country=b.isothree(+)
and a.coll_no is not null
/

insert into names 
select
names_seq.nextval, a.gid, -35, 0,-1,a.prev_name,nvl(b.cntryid,0),nvl(to_char(acq_date,'yyyymmdd'),0),0,1
from passport1 a, iris_central.cntry b
where a.ori_country=b.isothree(+)
and a.prev_name is not null
/

insert into names 
select
names_seq.nextval, a.gid, 10, 0,-1,a1.donor_code,nvl(b.cntryid,0),nvl(to_char(acq_date,'yyyymmdd'),0),
0,a1.donor_seq
from passport1 a, passport_donor a1, iris_central.cntry b
and a.accno=a1.accno
where a.ori_country=b.isothree(+)
and a.prev_name is not null
/

insert into names 
select
names_seq.nextval, a.gid, 8, 0,-1,a.species_reid,nvl(b.cntryid,0),nvl(to_char(acq_date,'yyyymmdd'),0),0,1
from passport1 a, iris_central.cntry b
where a.ori_country=b.isothree(+)
and species_reid is not null
/

Personal tools