Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
User expired
tcexam_uibk
Commits
f48671a3
Commit
f48671a3
authored
Aug 01, 2016
by
User expired
Browse files
postgresql functions for admin. groups
parent
926d679f
Changes
1
Hide whitespace changes
Inline
Side-by-side
install/postgres_db_structure_functions.sql
View file @
f48671a3
...
...
@@ -23,7 +23,51 @@ ALTER TABLE tce_tests ADD COLUMN test_group_id bigint;
-- restraint dropped because a user locked in VIS can be registered again in TCExam later, but of course keeps his matrikelnr.
ALTER
TABLE
tce_users
DROP
CONSTRAINT
ak_user_regnumber
;
-- functions for administrative group
-- Function: get_admin_group(bigint, bigint)
-- DROP FUNCTION get_admin_group(bigint, bigint);
CREATE
OR
REPLACE
FUNCTION
get_admin_group
(
itest_id
bigint
,
igroup_id
bigint
)
RETURNS
bigint
AS
$
BODY
$
DECLARE
xgroup_id
bigint
;
BEGIN
SELECT
group_id
FROM
tce_user_groups
WHERE
external_id
=
(
SELECT
LEFT
(
external_id
,
strpos
(
external_id
,
':'
)
-
1
)
FROM
tce_user_groups
WHERE
group_id
=
igroup_id
)
||
':owner'
AND
group_type
=
'B'
into
xgroup_id
;
RETURN
xgroup_id
;
END
;
$
BODY
$
LANGUAGE
plpgsql
VOLATILE
SECURITY
DEFINER
COST
100
;
ALTER
FUNCTION
get_admin_group
(
bigint
,
bigint
)
SET
search_path
=
tcexam
,
pg_temp
;
ALTER
FUNCTION
get_admin_group
(
bigint
,
bigint
)
OWNER
TO
tcexam
;
-- Function: set_admin_group(bigint, bigint)
-- DROP FUNCTION set_admin_group(bigint, bigint);
CREATE
OR
REPLACE
FUNCTION
get_admin_group
(
itest_id
bigint
,
igroup_id
bigint
)
RETURNS
bigint
AS
$
BODY
$
DECLARE
xgroup_id
bigint
;
BEGIN
SELECT
group_id
FROM
tce_user_groups
WHERE
external_id
=
(
SELECT
LEFT
(
external_id
,
strpos
(
external_id
,
':'
)
-
1
)
FROM
tce_user_groups
WHERE
group_id
=
igroup_id
)
||
':owner'
AND
group_type
=
'B'
into
xgroup_id
;
RETURN
xgroup_id
;
END
;
$
BODY
$
LANGUAGE
plpgsql
VOLATILE
SECURITY
DEFINER
COST
100
;
ALTER
FUNCTION
get_admin_group
(
bigint
,
bigint
)
SET
search_path
=
tcexam
,
pg_temp
;
ALTER
FUNCTION
get_admin_group
(
bigint
,
bigint
)
OWNER
TO
tcexam
;
-- functions for tcexam esb integration
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment