Original post

hi, im trying to access the exception message in , but without any success so far…

what ive got so far in Postgres:

CREATE OR REPLACE FUNCTION data.insert_data(num integer)

RETURNS text AS

$BODY$

DECLARE errorMsg TEXT;

BEGIN

SET search_path TO Data;

COPY tbl FROM ‘path’ DELIMITER ‘ ‘ CSV HEADER;

errorMsg = ‘im_a_return_var’;

RETURN errorMsg;

EXCEPTION

WHEN others THEN

RAISE EXCEPTION

USING ERRCODE = sqlstate

,MESSAGE = ‘Error: ‘ || sqlstate || ‘/ ‘ || sqlerrm;

errorMsg = sqlstate

,MESSAGE = ‘Error: ‘ || sqlstate || ‘/ ‘ || sqlerrm

RETURN errorMsg;

END

$BODY$

LANGUAGE plpgsql VOLATILE

on error i get, like i want it the errormessage and the sqlstate.

GoCode accessing the function:

db.QueryRow(“SELECT data.insert_data(” + “10” + “)”).Scan(&errorMsg)

on success i get im_a_return_var in go, but on error i just get no value at all.

Would anyone have a hint for me? Thanks!