Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
Institutional Coding
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AG Bibliometrie
Institutional Coding
Commits
6176d1e5
Commit
6176d1e5
authored
5 months ago
by
Christopher Lenke
Browse files
Options
Downloads
Patches
Plain Diff
23.09.2024
parent
a83aa16f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Procedures/get_hi_tree_for_uid_pg_numeric__date__text_.txt
+73
-0
73 additions, 0 deletions
Procedures/get_hi_tree_for_uid_pg_numeric__date__text_.txt
with
73 additions
and
0 deletions
Procedures/get_hi_tree_for_uid_pg_numeric__date__text_.txt
0 → 100644
+
73
−
0
View file @
6176d1e5
-- DROP PROCEDURE schema_xyz.get_hi_tree_for_uid_pg(numeric, date, text);
CREATE OR REPLACE PROCEDURE schema_xyz.get_hi_tree_for_uid_pg(input_uid numeric, hi_date date, output_table text)
LANGUAGE plpgsql
AS $procedure$
BEGIN
/*
Parameters:
* a uid for which the HIs are to be found
* a date for which you want to search
* a name for an output table, which then contains the result
*/
EXECUTE 'create table '||output_table||' as (SELECT (CASE r1.uid_0 WHEN 0 THEN r1.uid_1 ELSE
(CASE r2.uid_0 WHEN 0 THEN r2.uid_1 ELSE
(CASE r3.uid_0 WHEN 0 THEN r3.uid_1 ELSE
(CASE r4.uid_0 WHEN 0 THEN r4.uid_1 ELSE
(CASE r5.uid_0 WHEN 0 THEN r5.uid_1 ELSE
(CASE r6.uid_0 WHEN 0 THEN r6.uid_1 ELSE r6.uid_0 END)END)END)END)END)END) top,
r6.uid_0 u6,
r5.uid_0 u5,
r4.uid_0 u4,
r3.uid_0 u3,
r2.uid_0 u2,
r1.uid_0 u1,
r1.uid_1 u_last
FROM schema_xyz.relation r1
LEFT JOIN schema_xyz.relation r2 ON r2.uid_1=r1.uid_0
AND r2.type IN (0,1)
AND r2.last_date >=to_date('''||hi_date||''',''YYYY-MM-DD'')
AND r2.first_date <=to_date('''||hi_date||''',''YYYY-MM-DD'')
LEFT JOIN schema_xyz.relation r3 ON r3.uid_1=r2.uid_0
AND r3.type IN (0,1)
AND r3.last_date >=to_date('''||hi_date||''',''YYYY-MM-DD'')
AND r3.first_date <=to_date('''||hi_date||''',''YYYY-MM-DD'')
LEFT JOIN schema_xyz.relation r4 ON r4.uid_1=r3.uid_0
AND r4.type IN (0,1)
AND r4.last_date >=to_date('''||hi_date||''',''YYYY-MM-DD'')
AND r4.first_date <=to_date('''||hi_date||''' ,''YYYY-MM-DD'')
LEFT JOIN schema_xyz.relation r5 ON r5.uid_1=r4.uid_0
AND r5.type IN (0,1)
AND r5.last_date >=to_date('''||hi_date||''',''YYYY-MM-DD'')
AND r5.first_date <=to_date('''||hi_date||''' ,''YYYY-MM-DD'')
LEFT JOIN schema_xyz.relation r6 ON r6.uid_1=r5.uid_0
AND r6.type IN (0,1)
AND r6.first_date >=to_date('''||hi_date||''',''YYYY-MM-DD'')
AND r6.last_date <=to_date('''||hi_date||''',''YYYY-MM-DD'')
WHERE
r1.uid_1='||input_uid||'
AND r1.last_date >=to_date('''||hi_date||''',''YYYY-MM-DD'')
AND r1.first_date <=to_date('''||hi_date||''',''YYYY-MM-DD'')
and
(CASE r1.uid_0 WHEN 0 THEN r1.uid_1 ELSE
(CASE r2.uid_0 WHEN 0 THEN r2.uid_1 ELSE
(CASE r3.uid_0 WHEN 0 THEN r3.uid_1 ELSE
(CASE r4.uid_0 WHEN 0 THEN r4.uid_1 ELSE
(CASE r5.uid_0 WHEN 0 THEN r5.uid_1 ELSE
(CASE r6.uid_0 WHEN 0 THEN r6.uid_1 ELSE r6.uid_0 END)END)END)END)END)END) IS NOT NULL
AND r1.type IN (0, 1))';
end;
$procedure$
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment