Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/sql/40-swh-func.sql
Show First 20 Lines • Show All 654 Lines • ▼ Show 20 Lines | |||||
-- Create entries in person from tmp_release | -- Create entries in person from tmp_release | ||||
create or replace function swh_person_add_from_release() | create or replace function swh_person_add_from_release() | ||||
returns void | returns void | ||||
language plpgsql | language plpgsql | ||||
as $$ | as $$ | ||||
begin | begin | ||||
with t as ( | with t as ( | ||||
select distinct author_fullname as fullname, author_name as name, author_email as email from tmp_release | select distinct author_fullname as fullname, author_name as name, author_email as email from tmp_release | ||||
where author_fullname is not null | |||||
) insert into person (fullname, name, email) | ) insert into person (fullname, name, email) | ||||
select fullname, name, email from t | select fullname, name, email from t | ||||
where not exists ( | where not exists ( | ||||
select 1 | select 1 | ||||
from person p | from person p | ||||
where t.fullname = p.fullname | where t.fullname = p.fullname | ||||
); | ); | ||||
olasd: The `fullname is not null` clause can probably move to the CTE which will make things somewhat… | |||||
return; | return; | ||||
end | end | ||||
$$; | $$; | ||||
-- Create entries in release from tmp_release | -- Create entries in release from tmp_release | ||||
create or replace function swh_release_add() | create or replace function swh_release_add() | ||||
returns void | returns void | ||||
▲ Show 20 Lines • Show All 441 Lines • Show Last 20 Lines |
The fullname is not null clause can probably move to the CTE which will make things somewhat clearer.