Capturing the result status of an ALTER command in plpgsql

From: jarednevans(at)yahoo(dot)com
To: pgsql-novice(at)postgresql(dot)org
Subject: Capturing the result status of an ALTER command in plpgsql
Date: 2004-08-17 17:08:01
Message-ID: cfte1h$6m8@odah37.prod.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

How does one capture the result status of an ALTER command inside
plpgsql code block?

For example:

-----------------
CREATE OR REPLACE FUNCTION public."Setup_Primary_Keys"()
RETURNS SETOF varchar AS
'DECLARE

BEGIN

ALTER TABLE public."HCM00101" ADD CONSTRAINT "hcm00101-pk" PRIMARY
KEY("CUSTNMBR");
-- Capture Success or Failure here of the ALTER command
IF [how do I determine success here?] THEN
return next \'HCM00101 primary key set\';
ELSE [eat the failure exception here and continue]
return next \'HCM00101 primary key was not set, continuing with more
code below\';
END IF;

....... more code ........
return;

END;'
LANGUAGE 'plpgsql' VOLATILE;
-------------------

Browse pgsql-novice by date

  From Date Subject
Next Message operationsengineer1 2004-08-17 18:51:49 PGSQL 7.4.3 Compatible with 7.4.2?
Previous Message jarednevans 2004-08-17 16:46:25 return set different in psql and MS Access/ODBC