-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
179a6d7
commit f610dd1
Showing
4 changed files
with
59 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
database/code/meta/u-utility/u_remove_last_array_element.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
CREATE OR REPLACE FUNCTION meta.u_remove_last_array_element( | ||
in_ids int[]) | ||
RETURNS int[] -- returns array with last element removed | ||
LANGUAGE plpgsql | ||
COST 1 | ||
IMMUTABLE PARALLEL SAFE | ||
AS $function$ | ||
DECLARE | ||
i int; | ||
v_ret int[] := '{}'; | ||
BEGIN | ||
|
||
FOR i IN 1..array_upper(in_ids, 1) - 1 LOOP | ||
v_ret := v_ret || in_ids[i]; | ||
END LOOP; | ||
|
||
RETURN v_ret; | ||
END; | ||
|
||
$function$; |