diff options
| author | ckonstanski <kostcarl@isu.edu> | 2026-07-18 21:18:18 -0600 |
|---|---|---|
| committer | ckonstanski <kostcarl@isu.edu> | 2026-07-18 21:18:18 -0600 |
| commit | 08e435104c42751689553537b1f20ffb14b8dfcc (patch) | |
| tree | f83d8db1a02d4be448ab044d28fda7411470bd7c /sql/functions/auth.user_toggle_active.sql | |
initial commit
Diffstat (limited to 'sql/functions/auth.user_toggle_active.sql')
| -rw-r--r-- | sql/functions/auth.user_toggle_active.sql | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sql/functions/auth.user_toggle_active.sql b/sql/functions/auth.user_toggle_active.sql new file mode 100644 index 0000000..adc1b62 --- /dev/null +++ b/sql/functions/auth.user_toggle_active.sql @@ -0,0 +1,31 @@ +drop function auth.user_toggle_active ( + p_id bigint +); + +create or replace function auth.user_toggle_active ( + p_id bigint +) +returns bigint +as $$ +declare + l_id bigint; +begin + select u.id into l_id + from auth.users u + where u.id = p_id; + + if(l_id is not null) then + update auth.users + set active = not active + where id = p_id; + + select u.id into l_id + from auth.users u + where u.id = p_id; + + return l_id; + else + return null; + end if; +end; +$$ language plpgsql; |
