formigueiro
05/25/2023, 5:23 PMsql
DECLARE
slash_position INT;
value int;
entry_id int;
BEGIN
-- Encontra a posição da última ocorrência do caractere '/'
slash_position := strpos(reverse(new.short_url), '/');
-- Extrai o valor após a última ocorrência do caractere '/'
value := reverse(substring(reverse(new.short_url) from 1 for slash_position - 1));
select id
from url_data
into entry_id
where slug = value;
update public.report_data
set id = entry_id
where id = new.id;
RETURN new;
END;
erro : "No operator matches the given name and argument types. You might need to add explicit type casts."
sql
DECLARE
slash_position INT;
value TEXT;
entry_id UUID;
BEGIN
-- Encontra a posição da última ocorrência do caractere '/'
slash_position := strpos(reverse(new.short_url), '/');
-- Extrai o valor após a última ocorrência do caractere '/'
value := reverse(substring(reverse(new.short_url) from 1 for slash_position - 1));
select id
into entry_id
from url_data
WHERE slug = value;
update public.report_data
set url_id = entry_id
where id = new.id;
-- raise exception 'zzzz %', entry_id;
RETURN new;
END;
but now its not updating report_datagaryaustin
05/25/2023, 5:55 PMraise log 'value =%',variable;
in your code to help debug. Results will be in Postgres log from dashboard.formigueiro
05/25/2023, 5:57 PMsql
DECLARE
slash_position INT;
value TEXT;
entry_id UUID;
BEGIN
-- Encontra a posição da última ocorrência do caractere '/'
slash_position := strpos(reverse(new.short_url), '/');
-- Extrai o valor após a última ocorrência do caractere '/'
value := reverse(substring(reverse(new.short_url) from 1 for slash_position - 1));
select id
into entry_id
from url_data
WHERE slug = value;
raise exception 'zzzz %', new;
-- update public.report_data
-- set url_id = 'eeff7d6b-6cd3-42ee-bab6-05b63262fb88'
-- where id = new.id;
-- raise exception 'zzzz %', entry_id;
RETURN new;
END;
yes im loggin to check, but im gettin null on newhttps://cdn.discordapp.com/attachments/1111343911659638886/1111352413207658529/image.png▾
garyaustin
05/25/2023, 5:57 PMformigueiro
05/25/2023, 5:58 PMgaryaustin
05/25/2023, 5:59 PMformigueiro
05/25/2023, 5:59 PMgaryaustin
05/25/2023, 6:00 PMhttps://cdn.discordapp.com/attachments/1111343911659638886/1111353094828204143/image.png▾
formigueiro
05/25/2023, 6:01 PMhttps://cdn.discordapp.com/attachments/1111343911659638886/1111353572756557845/image.png▾
garyaustin
05/25/2023, 6:02 PMformigueiro
05/25/2023, 6:02 PMgaryaustin
05/25/2023, 6:03 PMformigueiro
05/25/2023, 6:03 PMhttps://cdn.discordapp.com/attachments/1111343911659638886/1111353861630853213/image.png▾
garyaustin
05/25/2023, 6:03 PMhttps://cdn.discordapp.com/attachments/1111343911659638886/1111353925958910052/image.png▾
formigueiro
05/25/2023, 6:04 PMhttps://cdn.discordapp.com/attachments/1111343911659638886/1111354083060760677/image.png▾
https://cdn.discordapp.com/attachments/1111343911659638886/1111354170914639982/image.png▾
garyaustin
05/25/2023, 6:04 PMformigueiro
05/25/2023, 6:05 PMgaryaustin
05/25/2023, 6:05 PMformigueiro
05/25/2023, 6:05 PM