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
f746d241
authored
Apr 22, 2025
by
RONALDO RODRIGUES DE OLIVEIRA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Function de transferência de recursos entre gestores
parent
d68cfef6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
declaracao_omissao/4-function par.set_trans_credito_debito.sql
declaracao_omissao/4-function par.set_trans_credito_debito.sql
0 → 100644
View file @
f746d241
-- drop function if exists par.set_trans_credito_debito(integer)
create
or
replace
function
par
.
set_trans_credito_debito
(
i_odeid
integer
)
returns
void
language
plpgsql
as
$$
declare
romid_array
integer
[]:
=
ARRAY
(
SELECT
romid
FROM
par
.
responsaveisomisso
where
odeid
=
i_odeid
order
by
dtfimmandato
);
valor_debito
numeric
(
20
,
2
);
data_debito
timestamp
;
begin
FOR
i
IN
1
..(
array_length
(
romid_array
,
1
)
-
1
)
LOOP
if
(
(
select
coalesce
(
valorcredito
,
'0.00'
)
from
par
.
responsaveisomisso
where
romid
=
romid_array
[
i
]
)
>
0
)
then
select
valorcredito
,
datacredito
into
valor_debito
,
data_debito
from
par
.
responsaveisomisso
where
romid
=
romid_array
[
i
];
update
par
.
responsaveisomisso
set
datadebito
=
dtiniciomandato
,
valordebito
=
valor_debito
where
romid
=
romid_array
[
i
+
1
];
end
if
;
END
LOOP
;
update
par
.
responsaveisomisso
set
romstatus
=
'A'
,
carga
=
'CREDITOVIRADEBITO'
where
odeid
=
i_odeid
;
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