'Postgres Error 08001 (SQLCLIENT UNABLE TO ESTABLISH SQLCONNECTION) and the FOC1394 Error
I use trigger after the update and insert one table to synchronize one table on one server with a foreign table on a different server. My problem is that different servers can be down and I need my functions to be able to handle that (not with error).
CREATE OR REPLACE FUNCTION public.gapless_seq_update_forein()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
begin
update gapless_seq_b set drain=new.drain, end_batch=new.end_batch,
file_name=new.file_name
where seq=new.seq and lobid = new.lobid and neid = new.neid;
END IF;
return new;
end;
$function$
;
Solution 1:[1]
easy solution (that is for some reason hard to google)
CREATE OR REPLACE FUNCTION public.gapless_seq_update_forein()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
begin
update gapless_seq_b set drain=new.drain, end_batch=new.end_batch,
file_name=new.file_name
where seq=new.seq and lobid = new.lobid and neid = new.neid;
return new;
exception when others THEN
-- Do nothing.
return new;
END;
$function$
;
note: my error is 08001 sqlclient_unable_to_establish_sqlconnection but for some reason it works only with "others"...
more here: https://www.postgresql.org/docs/9.4/plpgsql-control-structures.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Drual |
