Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
1
Indexable
Never
# TO ROBIE ZEBY CONSTRAINT NA KALKULACJACH PRZESZEDL POPRAWNIE

# update pola `analyte_id` w kalkulacjach
```
UPDATE 	sample_calculation main
SET 	analyte_id = (select ((variables::json->0)::json->'analyte'->'value'->'id')::jsonb::text::integer from sample_calculation where id=main.id)
WHERE analyte_id is null;
```


select id from sample_result where calc_id in (1, 3, 4, 6, 8, 13, 2, 5, 7, 9, 10, 11, 12);


select id, calc_id, analyte_id from sample_calculation where analyte_id is null;
select id, calc_id from sample_analyte where calc_id is not null;

delete from sample_calculation where id in (1, 3, 4, 6, 8, 13, 2, 5, 7, 9, 10, 11, 12);


UPDATE sample_calculation
SET analyte_id = 70
WHERE id=8;


UPDATE sample_calculation
SET analyte_id = 76
WHERE id=9;

UPDATE sample_calculation
SET analyte_id = 218
WHERE id=12;

select analyte_id from sample_calculation where id=12;


# id kalkulacji bez analyte_id oraz bez additional_parameter_id

1, 3, 4, 6, 13, 2, 5, 7, 10, 11


select * from sample_analyte where calc_id in (1, 3, 4, 6, 13, 2, 5, 7, 10, 11);
0 rows

select * from sample_result where calc_id in (1, 3, 4, 6, 13, 2, 5, 7, 10, 11);
0 rows


delete from sample_calculation where id in (1, 3, 4, 6, 13, 2, 5, 7, 10, 11);