-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDIS 58] Ajout de la numérotation du SDIS 58
Issue : #225967 Change-Id: I8dfb1eaad946fdc7d4bfcb64988da55d3bcb78c9
- Loading branch information
Clément GRENOT
committed
Nov 6, 2024
1 parent
5f7a3a1
commit 6e0895e
Showing
3 changed files
with
176 additions
and
0 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
28 changes: 28 additions & 0 deletions
28
server/sdis-remocra/home/postgres/remocra_db/patches/sdis/58/203_001.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,28 @@ | ||
CREATE OR REPLACE FUNCTION remocra.nextnumerointerne(idhydrant bigint, codehydrant character varying, naturehydrant bigint, idcommune bigint, startserie bigint, stopserie bigint) | ||
RETURNS bigint | ||
LANGUAGE plpgsql | ||
AS $function$ | ||
DECLARE returned bigint; | ||
BEGIN | ||
SELECT n INTO returned | ||
FROM generate_series(COALESCE(startserie, 1), COALESCE(stopserie, 99999)) gs(n) | ||
except | ||
SELECT numero_interne | ||
FROM remocra.hydrant h | ||
WHERE | ||
(case when idhydrant is not null then h.id != idhydrant else true end) | ||
and (case | ||
when codehydrant = 'PIBI' then h.code = codehydrant | ||
when codehydrant = 'PENA' then | ||
CASE WHEN naturehydrant = (select id from remocra.type_hydrant_nature where code = 'PU') THEN h.nature = naturehydrant | ||
ELSE h.nature <> naturehydrant END | ||
ELSE TRUE END) | ||
and (case when idcommune is not null then h.commune = idcommune else true end) | ||
order BY 1 | ||
limit 1; | ||
|
||
return returned; | ||
end; | ||
|
||
$function$ | ||
; |