1 year ago

#362157

test-img

Ray92

How to rollback simple piece of Postgres UDF code

This is my code:

create or replace function roundfind(dates date) returns varchar 
as $$
select
case 
    when dates between '2020-06-08' and '2020-11-14' then 'Round 1'
    when dates between '2020-11-15' and '2021-02-17' then 'Round 2'
    when dates between '2021-02-18' and '2021-04-28' then 'Round 3'
    when dates between '2021-04-29' and '2021-07-16' then 'Round 4'
    when dates between '2021-07-16' and '2021-10-03' then 'Round 5'
    when dates between '2021-10-04' and '2021-11-30' then 'Round 6'
    when dates between '2021-12-01' and '2022-02-01' then 'Round 7'
    when dates between '2021-02-02' and '2022-03-28' then 'Round 8'
    when dates >= '2022-03-29' then  'Round 9'
end;
$$
language sql;

select roundfind(date '2020-06-09')

THIS code is correct, BUT initially had some error due to which I received the error "SQL Error [25P02]: ERROR: current transaction is aborted, commands ignored until end of transaction block".

Now even though I am running the correct code, I am still getting the error. I know I am supposed to "rollback" somehow, but do not know how, please help.

postgresql

rollback

0 Answers

Your Answer

Accepted video resources