| 61 | |
| 62 | select * from wrbd.fish_fi join wrbd.operation_op op on (fi_year,fi_st_id)=(op_year,op_st_id) |
| 63 | where fi_op_id is null and fi_date is not null; -- 645 |
| 64 | |
| 65 | |
| 66 | select * from wrbd.operation_op op where op_year=1974; |
| 67 | |
| 68 | select * from wrbd.fish_fi where fi_year=1974 and fi_st_id='st2'; |
| 69 | --three operations missing |
| 70 | insert into wrbd.operation_op(op_st_id,op_date,op_year) values ('st2','1974-07-18',1974); |
| 71 | insert into wrbd.operation_op(op_st_id,op_date,op_year) values ('st2','1974-07-19',1974); |
| 72 | insert into wrbd.operation_op(op_st_id,op_date,op_year) values ('st2','1974-07-20',1974); |
| 73 | |
| 74 | --exporting fishes to update_fish_1.sql |
| 75 | select 'update wrbd.fish_fi set fi_op_id='||cast(op_id as text)||' where fi_id='||cast (fi_id as text)||';' from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) |
| 76 | where fi_op_id is null and fi_date is not null and fi_id not in ( |
| 77 | select fi_id from ( |
| 78 | select count(fi_id) as count, fi_id from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) |
| 79 | where fi_op_id is null and fi_date is not null |
| 80 | group by fi_id) as toto where count>1); |
| 81 | ; |
| 82 | |
| 83 | select * from wrbd.fish_fi join wrbd.operation_op op on (fi_year,fi_st_id)=(op_year,op_st_id) |
| 84 | where fi_op_id is null and fi_date is not null; -- 531 |
| 85 | |
| 86 | select * from wrbd.fish_fi where fi_year=1975 and fi_st_id='st2'; |
| 87 | select * from wrbd.operation_op op where op_year=1975; |
| 88 | |
| 89 | insert into wrbd.operation_op(op_st_id,op_date,op_year) values ('st2','1975-07-31',1974); |
| 90 | insert into wrbd.operation_op(op_st_id,op_date,op_year) values ('st2','1975-08-01',1974); |
| 91 | insert into wrbd.operation_op(op_st_id,op_date,op_year) values ('st2','1975-08-02',1974); |
| 92 | |
| 93 | --exporting fishes to update_fish_2.sql |
| 94 | select 'update wrbd.fish_fi set fi_op_id='||cast(op_id as text)||' where fi_id='||cast (fi_id as text)||';' from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) |
| 95 | where fi_op_id is null and fi_date is not null and fi_id not in ( |
| 96 | select fi_id from ( |
| 97 | select count(fi_id) as count, fi_id from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) |
| 98 | where fi_op_id is null and fi_date is not null |
| 99 | group by fi_id) as toto where count>1); |
| 100 | ; |
| 101 | select * from wrbd.fish_fi join wrbd.operation_op op on (fi_year,fi_st_id)=(op_year,op_st_id) |
| 102 | where fi_op_id is null and fi_date is not null; -- 474 no more st2, MI0011,MI0017, MI0018 |
| 103 | |
| 104 | select * from wrbd.fish_fi where fi_year=1988 and fi_st_id='MI0011'; --1988-09-09 |
| 105 | |
| 106 | select * from wrbd.operation_op op where op_year=1988 and op_st_id='MI0011'; |
| 107 | |
| 108 | select op_folio_no,op_st_id,op_year,op_yellow,op_p1,op_main_survey_target,op_equipment,op_nbnets,op_datasource from wrbd.operation_op op where op_date='1988-08-09' and op_st_id='MI0011'; |
| 109 | insert into wrbd.operation_op (op_folio_no,op_st_id,op_year,op_yellow,op_p1,op_main_survey_target,op_equipment,op_nbnets,op_datasource) |
| 110 | select op_folio_no,op_st_id,op_year,op_yellow,op_p1,op_main_survey_target,op_equipment,op_nbnets,op_datasource from wrbd.operation_op op where op_date='1988-08-09' and op_st_id='MI0011'; |
| 111 | update wrbd.operation_op set op_date='1988-09-09' where op_id=(select max(op_id) from wrbd.operation_op); |
| 112 | update wrbd.operation_op set op_yellow=(select count(*) from wrbd.fish_fi where fi_date='1988-09-09' and fi_st_id='MI0011') where op_id=(select max(op_id) from wrbd.operation_op); |
| 113 | update wrbd.operation_op set op_p1=(select count(*) from wrbd.fish_fi where fi_date='1988-09-09' and fi_st_id='MI0011') where op_id=(select max(op_id) from wrbd.operation_op); |
| 114 | |
| 115 | --exporting fishes to update_fish_3.sql |
| 116 | select 'update wrbd.fish_fi set fi_op_id='||cast(op_id as text)||' where fi_id='||cast (fi_id as text)||';' from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) |
| 117 | where fi_op_id is null and fi_date is not null and fi_id not in ( |
| 118 | select fi_id from ( |
| 119 | select count(fi_id) as count, fi_id from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) |
| 120 | where fi_op_id is null and fi_date is not null |
| 121 | group by fi_id) as toto where count>1); |
| 122 | |
| 123 | select * from wrbd.fish_fi join wrbd.operation_op op on (fi_year,fi_st_id)=(op_year,op_st_id) |
| 124 | where fi_op_id is null and fi_date is not null; -- 430 MI0017 |
| 125 | |
| 126 | select * from wrbd.fish_fi where fi_year=1988 and fi_st_id='MI0017'; --1988-09-17 there is 09-16 fiop_id=1506 |
| 127 | select * from wrbd.fish_fi where fi_date='1988-09-17' and fi_st_id='MI0017'; |
| 128 | update wrbd.fish_fi set fi_op_id=1506 where fi_date='1988-09-17' and fi_st_id='MI0017'; --26 lines |
| 129 | |
| 130 | select * from wrbd.fish_fi join wrbd.operation_op op on (fi_year,fi_st_id)=(op_year,op_st_id) |
| 131 | where fi_op_id is null and fi_date is not null; -- 40 MI0018 2007-10-11 and MI0022 2005-06-15 |
| 132 | |
| 133 | select * from wrbd.fish_fi where fi_year=2005 and fi_st_id='MI0022'; |
| 134 | select * from wrbd.fish_fi where fi_date='2005-06-15' and fi_st_id='MI0022'; |
| 135 | select distinct on (fi_op_id) fi_op_id from wrbd.fish_fi where fi_date='2005-06-14' and fi_st_id='MI0022'; |
| 136 | update wrbd.fish_fi set fi_op_id=(select distinct on (fi_op_id) fi_op_id from wrbd.fish_fi where fi_date='2005-06-14' and fi_st_id='MI0022') |
| 137 | where fi_date='2005-06-15' and fi_st_id='MI0022'; -- 5 lines modified |
| 138 | |
| 139 | |
| 140 | select * from wrbd.fish_fi join wrbd.operation_op op on (fi_year,fi_st_id)=(op_year,op_st_id) |
| 141 | where fi_op_id is null and fi_date is not null; -- 40 MI0018 2007-10-11 |
| 142 | select * from wrbd.fish_fi where fi_year=2007 and fi_st_id='MI0018'; -- cette fois pas d'operation |
| 143 | select * from wrbd.operation_op op where op_date='2007-08-14' and op_st_id='MI0018'; |
| 144 | select op_folio_no,op_st_id,op_year,op_yellow,op_p1,op_main_survey_target,op_equipment,op_nbnets,op_datasource from wrbd.operation_op op where op_date='2007-08-14' and op_st_id='MI0018'; |
| 145 | insert into wrbd.operation_op (op_folio_no,op_st_id,op_year,op_yellow,op_p1,op_main_survey_target,op_equipment,op_nbnets,op_datasource) |
| 146 | select op_folio_no,op_st_id,op_year,op_yellow,op_p1,op_main_survey_target,op_equipment,op_nbnets,op_datasource from wrbd.operation_op op where op_date='2007-08-14' and op_st_id='MI0018'; |
| 147 | update wrbd.operation_op set op_date='2007-10-11' where op_id=(select max(op_id) from wrbd.operation_op); |
| 148 | update wrbd.operation_op set op_yellow=(select count(*) from wrbd.fish_fi where fi_date='2007-10-11' and fi_st_id='MI0018') where op_id=(select max(op_id) from wrbd.operation_op); |
| 149 | update wrbd.operation_op set op_p1=(select count(*) from wrbd.fish_fi where fi_date='2007-10-11' and fi_st_id='MI0018') where op_id=(select max(op_id) from wrbd.operation_op); |
| 150 | |
| 151 | |
| 152 | --exporting fishes to update_fish_4.sql |
| 153 | select 'update wrbd.fish_fi set fi_op_id='||cast(op_id as text)||' where fi_id='||cast (fi_id as text)||';' from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) |
| 154 | where fi_op_id is null and fi_date is not null and fi_id not in ( |
| 155 | select fi_id from ( |
| 156 | select count(fi_id) as count, fi_id from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) |
| 157 | where fi_op_id is null and fi_date is not null |
| 158 | group by fi_id) as toto where count>1); |
| 159 | |
| 160 | update wrbd.fish_fi set fi_op_id=2598 where fi_id=6779; |
| 161 | update wrbd.fish_fi set fi_op_id=2598 where fi_id=6780; |
| 162 | update wrbd.fish_fi set fi_op_id=2598 where fi_id=6781; |
| 163 | update wrbd.fish_fi set fi_op_id=2598 where fi_id=6782; |
| 164 | update wrbd.fish_fi set fi_op_id=2598 where fi_id=6783; |
| 165 | update wrbd.fish_fi set fi_op_id=2598 where fi_id=6784; |
| 166 | update wrbd.fish_fi set fi_op_id=2598 where fi_id=6785; |
| 167 | update wrbd.fish_fi set fi_op_id=2598 where fi_id=6786; |
| 168 | update wrbd.fish_fi set fi_op_id=2598 where fi_id=6787; |
| 169 | update wrbd.fish_fi set fi_op_id=2598 where fi_id=6788; |
| 170 | |
| 171 | |
| 172 | select * from wrbd.fish_fi join wrbd.operation_op op on (fi_year,fi_st_id)=(op_year,op_st_id) |
| 173 | where fi_op_id is null and fi_date is not null; -- plus rien |
| 174 | |
| 175 | select * from wrbd.fish_fi where fi_op_id is null -- 1123 st2 et MI0037 |
| 176 | |
| 177 | |
| 178 | select * from wrbd.operation_op op where op_year=1973; --nothing |
| 179 | select * from wrbd.operation_op op where op_st_id='st2'; |
| 180 | select * from wrbd.fish_fi where fi_year=1973 and fi_st_id='st2'; |
| 181 | insert into wrbd.operation_op (op_st_id,op_date,op_year) values('st2','1973-06-29',1973); |
| 182 | |
| 183 | --exporting fishes to update_fish_5.sql |
| 184 | select 'update wrbd.fish_fi set fi_op_id='||cast(op_id as text)||' where fi_id='||cast (fi_id as text)||';' from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) |
| 185 | where fi_op_id is null and fi_date is not null and fi_id not in ( |
| 186 | select fi_id from ( |
| 187 | select count(fi_id) as count, fi_id from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) |
| 188 | where fi_op_id is null and fi_date is not null |
| 189 | group by fi_id) as toto where count>1); |
| 190 | |
| 191 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25647; |
| 192 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25648; |
| 193 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25649; |
| 194 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25650; |
| 195 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25651; |
| 196 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25652; |
| 197 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25653; |
| 198 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25654; |
| 199 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25655; |
| 200 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25656; |
| 201 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25657; |
| 202 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25658; |
| 203 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25659; |
| 204 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25660; |
| 205 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25661; |
| 206 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25662; |
| 207 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25663; |
| 208 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25664; |
| 209 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25665; |
| 210 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25666; |
| 211 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25667; |
| 212 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25668; |
| 213 | update wrbd.fish_fi set fi_op_id=2599 where fi_id=25669; |
| 214 | |
| 215 | select * from wrbd.fish_fi where fi_op_id is null -- 1123 MI0037 2008 and 2009 no dates |
| 216 | |
| 217 | select * from wrbd.operation_op op where op_st_id='MI0037'; --OK two operations 1961 (2008) and 1962 (2009) |
| 218 | select * from wrbd.fish_fi join wrbd.operation_op op on (fi_year,fi_st_id)=(op_year,op_st_id) where fi_op_id is null and fi_date is null |
| 219 | |
| 220 | select * from wrbd.fish_fi where fi_op_id is null and fi_year=2008 and fi_st_id='MI0037' |
| 221 | update wrbd.fish_fi set fi_op_id='1961' where fi_op_id is null and fi_year=2008 and fi_st_id='MI0037'; |
| 222 | select * from wrbd.fish_fi where fi_op_id is null and fi_year=2009 and fi_st_id='MI0037' |
| 223 | update wrbd.fish_fi set fi_op_id=1962 where fi_op_id is null and fi_year=2009 and fi_st_id='MI0037'; |
| 224 | |
| 225 | select * from wrbd.fish_fi where fi_op_id is null; --0 lines AHHHHH finished... |