Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
RONALDO RODRIGUES DE OLIVEIRA
/
simec-scripts-banco
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1e5224e1
authored
Apr 22, 2025
by
RONALDO RODRIGUES DE OLIVEIRA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Function de ciência/notificacao
parent
aca8894d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
declaracao_omissao/1-function-par-get_ciencias_termo.sql
declaracao_omissao/1-function-par-get_ciencias_termo.sql
0 → 100644
View file @
1e5224e1
-- drop function if exists par.get_ciencias_termo(int, int);
create
or
replace
function
par
.
get_ciencias_termo
(
i_prpid
int
,
i_dopid
int
)
returns
table
(
_cpf
varchar
,
_id
integer
,
_tipo
varchar
,
_data_notificado
date
,
_data_ciencia
date
)
language
plpgsql
as
$$
declare
ciencias
record
;
BEGIN
for
ciencias
in
(
with
cpf_ciencias
as
(
select
opc
.
opcid
as
id
,
usu
.
usucpf
,
'omissaopcente'
as
tipo
,
opc
.
opcdataomissao
as
data_notificado
,
opc
.
opcdataciencia
as
data_ciencia
FROM
par
.
omissaopcente
opc
inner
JOIN
seguranca
.
usuario
usu
on
usu
.
usucpf
=
opc
.
opccpfciencia
WHERE
opc
.
prpid
=
i_prpid
and
opc
.
opcstatus
=
'A'
-- and usu.usustatus = 'A' NÃO COLOCAR PQ REMOVE CIENCIA/RESPOSNAVEL
union
all
select
neg
.
negid
as
id
,
usu
.
usucpf
,
'notificacaoexgestor'
as
tipo
,
neg
.
negdtenvionotificacao
as
data_notificado
,
neg
.
negdtaceiterealizado
as
data_ciencia
from
par
.
exgestor
eg
inner
join
par
.
notificacaoexgestor
neg
on
neg
.
egid
=
eg
.
egid
inner
join
seguranca
.
usuario
usu
on
usu
.
usucpf
=
eg
.
usucpf
where
dopid
=
i_dopid
and
neg
.
negstatus
=
'A'
and
neg
.
negdtaceiterealizado
is
not
null
and
eg
.
egstatus
=
'A'
-- and usu.usustatus = 'A' NÃO COLOCAR PQ REMOVE CIENCIA/RESPONSAVEL
union
all
select
np
.
npid
as
id
,
usu
.
usucpf
,
'notificacao_postal'
as
tipo
,
np
.
npdtgeracao
as
data_notificado
,
np
.
npcienc_dt_receb
as
data_ciencia
from
par
.
notificacao_postal
np
inner
join
seguranca
.
usuario
usu
on
usu
.
usucpf
=
np
.
npresptermocpf
-- and usu.usustatus = 'A' NÃO COLOCAR PQ REMOVE CIENCIA/RESPONSAVEL
where
np
.
dopid
=
i_dopid
and
np
.
npcienc_dt_receb
is
not
null
and
np
.
npstatus
=
'A'
)
select
*
from
cpf_ciencias
order
by
usucpf
desc
)
loop
_id
:
=
ciencias
.
id
;
_cpf
:
=
ciencias
.
usucpf
;
_tipo
:
=
ciencias
.
tipo
;
_data_notificado
:
=
ciencias
.
data_notificado
;
_data_ciencia
:
=
ciencias
.
data_ciencia
;
return
next
;
end
loop
;
end
;
$$
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