Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-core
Commits
74fa3698
Commit
74fa3698
authored
Mar 15, 2023
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewritten PL/SQL function im_project_sub_project_name_path
parent
a6086f07
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
52 deletions
+43
-52
intranet-projects.sql
sql/postgresql/intranet-projects.sql
+43
-52
No files found.
sql/postgresql/intranet-projects.sql
View file @
74fa3698
...
...
@@ -633,59 +633,50 @@ end;$body$ language 'plpgsql' VOLATILE;
CREATE
OR
REPLACE
FUNCTION
im_project_sub_project_name_path
(
integer
,
boolean
,
boolean
)
RETURNS
character
varying
AS
$
BODY
$
RETURNS
character
varying
AS
$
BODY
$
DECLARE
-- Returns a path of project_names -> bottom-up
-- Output of subproject-name itself and top parent project can be surpressed
p_sub_project_id
alias
for
$
1
;
p_exlude_main_project_p
alias
for
$
2
;
p_exlude_sub_project_p
alias
for
$
3
;
v_subproject_id
integer
;
v_parent_id
integer
;
v_project_name
varchar
;
v_ctr
integer
;
v_path
varchar
;
v_slash
varchar
;
-- Returns a path of project_names -> bottom-up
-- Output of subproject-name itself and top parent project can be surpressed
p_sub_project_id
alias
for
$
1
;
p_exclude_main_project_p
alias
for
$
2
;
p_exclude_sub_project_p
alias
for
$
3
;
v_subproject_id
integer
;
v_parent_id
integer
;
v_project_name
varchar
;
v_ctr
integer
;
v_path
varchar
;
BEGIN
v_subproject_id
:
=
p_sub_project_id
;
v_ctr
:
=
0
;
v_path
:
=
''
;
WHILE
v_ctr
<
10
LOOP
select
parent_id
,
project_name
into
v_parent_id
,
v_project_name
from
im_projects
p
where
project_id
=
v_subproject_id
;
IF
v_parent_id
is
not
null
OR
NOT
p_exlude_main_project_p
THEN
v_slash
:
=
'/'
;
IF
''
=
v_project_name
THEN
v_slash
:
=
''
;
RAISE
NOTICE
'v_project_name is empty'
;
END
IF
;
IF
(
v_ctr
=
0
AND
NOT
p_exlude_sub_project_p
)
OR
v_ctr
!=
0
THEN
v_path
:
=
v_project_name
||
v_slash
||
v_path
;
END
IF
;
v_subproject_id
:
=
v_parent_id
;
END
IF
;
IF
v_parent_id
is
null
THEN
EXIT
;
ELSE
v_ctr
:
=
v_ctr
+
1
;
END
IF
;
END
LOOP
;
return
v_path
;
end
;
$
BODY
$
LANGUAGE
'plpgsql'
v_subproject_id
:
=
p_sub_project_id
;
v_ctr
:
=
0
;
v_path
:
=
''
;
WHILE
v_ctr
<
20
LOOP
v_ctr
:
=
v_ctr
+
1
;
select
parent_id
,
project_name
into
v_parent_id
,
v_project_name
from
im_projects
p
where
project_id
=
v_subproject_id
;
IF
v_parent_id
is
null
THEN
-- We are at the end of the iteration
IF
not
p_exclude_main_project_p
THEN
IF
v_path
!=
''
THEN
v_path
:
=
' / '
||
v_path
;
END
IF
;
v_path
:
=
v_project_name
||
v_path
;
END
IF
;
EXIT
;
END
IF
;
-- v_parent_id is not null
IF
not
p_exclude_main_project_p
THEN
IF
v_path
!=
''
THEN
v_path
:
=
' / '
||
v_path
;
END
IF
;
v_path
:
=
v_project_name
||
v_path
;
END
IF
;
v_subproject_id
:
=
v_parent_id
;
END
LOOP
;
return
v_path
;
end
;
$
BODY
$
LANGUAGE
'plpgsql'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment