Re: How to raise error from PostgreSql SQL statement if some condition is met

From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to raise error from PostgreSql SQL statement if some condition is met
Date: 2012-08-12 10:02:17
Message-ID: F8704FB9C6B043D8B01D84A515FFE8F7@dell2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>... RaiseException(text, variadic text[])
>..

>VARIADIC is keyword, not datatype

Thank you.

I tried code below but got error shown in comment.
No idea what I'm doing wrong.

Andrus.

CREATE OR REPLACE FUNCTION RaiseException(text, variadic text[] )
RETURNS void LANGUAGE plpgsql AS
$BODY$
BEGIN
-- ERROR: syntax error at or near "$1"
RAISE EXCEPTION $1, $2;
END;
$BODY$;

SELECT RaiseException('Exception Param1=% Param2=%', 'textvalue', '2' );

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Neanderthelle Jones 2012-08-12 10:16:59 Deleting BLOBs
Previous Message Pavel Stehule 2012-08-12 09:12:07 Re: How to raise error from PostgreSql SQL statement if some condition is met