Answer the question
In order to leave comments, you need to log in
What is this "ERROR: ERROR: ambiguous column reference" error?
I want to fill the empty field of table 1 with the values that I find by the code from table 1 in table 2
CREATE OR REPLACE FUNCTION public.add_soate(
)
RETURNS SETOF zagsmarriagelist
LANGUAGE 'plpgsql'
COST 100
VOLATILE
ROWS 1000
AS $BODY$
DECLARE
r zagsmarriagelist%rowtype;
DECLARE code varchar;
BEGIN
FOR r IN
SELECT id FROM zagsmarriagelist
LOOP
code := (select nullif(regexp_replace(r::varchar, '\D','','g'), ''));
UPDATE zagsmarriagelist
SET bridesoate = (select substring(a.code from 1 for 14) from ate_history a where a.ate::varchar=(select bridebirthaddress from zagsmarriagelist where id::varchar=code))
WHERE id::varchar=code;
RETURN NEXT r;
END LOOP;
RETURN;
END
$BODY$;
ALTER FUNCTION public.add_soate()
OWNER TO postgres;
select * from add_soate();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question