General information
Category:
Coding, syntax & commands
Title:
Postgresql DBLink Error
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only