cannot get error message after dblink_exec execution

From: "Sofer, Yuval" <Yuval_Sofer(at)bmc(dot)com>
To: <pgsql-admin(at)postgresql(dot)org>
Cc: "Abraham, Danny" <danny_abraham(at)bmc(dot)com>
Subject: cannot get error message after dblink_exec execution
Date: 2007-08-19 13:51:39
Message-ID: F8B9B12641FB6B4FAC761BDEF9D63B040E30A911@tlv-ex-01.adprod.bmc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi,

I am using DBLink contrib module.

I cannot catch the dblink_exec error messages.

On the other hand, the pgadmin gui shows the error message under
"DETAIL" section:

The test function :

CREATE OR REPLACE FUNCTION test_func1()

RETURNS integer AS

$$

DECLARE

stmt text;

conn text;

err text ;

last_message text default 'aaa';

BEGIN

conn := 'dbname=postgres user=postgres password=manager';

stmt := 'drop table not_existing_table';

err := dblink_exec(conn, stmt,false);

last_message := dblink_error_message('dbname=postgres
user=postgres password=manager') ;

raise notice ' err is %',err;

raise notice ' last_message is %',last_message;

return 0;

END;

$$

LANGUAGE 'plpgsql' VOLATILE;

When I execute select test_func1(); I get the error message from the gui
(table "not_existing table" does not exist):

NOTICE: sql error

DETAIL: ERROR: table "not_existing_table" does not exist

CONTEXT: PL/pgSQL function "test_func1" line 11 at assignment

NOTICE: err is ERROR

NOTICE: last_message is

Total query runtime: 100 ms.

1 rows retrieved.

My questions :

How can catch this error into the stored procedure parameter?

Am I not using dblink_error_message correctly?

I don't mind retrieving the error message as the gui does, but how can I
do it?

Thanks

Yuval

DBA team

BMC Software

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message giuseppe.derossi 2007-08-19 15:38:43 HELP, can't implement e filter
Previous Message Medi Montaseri 2007-08-18 23:15:49 Re: compilation error on CentOS 5