Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Postgresql DBLink Error
Message
From
02/09/2022 08:39:06
 
 
To
All
General information
Forum:
PostgreSQL
Category:
Coding, syntax & commands
Title:
Postgresql DBLink Error
Miscellaneous
Thread ID:
01684928
Message ID:
01684928
Views:
42
Good norning,
I'm testing how to insert data into another postgresq database and I'm having the attached error.
Below is the code to create the postgresql function:


CREATE OR REPLACE FUNCTION efaturas(
character,
character,
character,
character)
RETURNS text AS
$BODY$

DECLARE

o_codigo_retorno character(5);
a_data_vencimento date;
lcComandoSQL text;
o_tipodoc character(2);
o_totaldocumento numeric(10,2);

BEGIN
-- Reuno as Variaveis
o_tipodoc := $4;'
o_totaldocumento := 15000;

lcComandoSQL := 'INSERT INTO teste(nomeentidade, valor) VALUES('||o_tipodoc||', '||o_totaldocumento||')';
-- Gravo os Dados no ficheiro de Documentos na Base dados eFatura
SELECT * FROM dblink('dbname = mydb port = 5432 host = myserver.com user = my_login password = 1234', lcComandoSQL) AS foreign_rec(id integer) INTO o_codigo_retorno;

END;$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION efaturas(character, character, character, character)
OWNER TO clima_user;
Next
Reply
Map
View

Click here to load this message in the networking platform