exception handling in postgres plpgsql

From: Karthikeyan Sundaram <skarthi98(at)hotmail(dot)com>
To: <pgsql-admin(at)postgresql(dot)org>, <pgsql-sql(at)postgresql(dot)org>
Subject: exception handling in postgres plpgsql
Date: 2007-04-03 22:35:17
Message-ID: BAY131-W11D9F51A1A2E1E3AEFB6D8B0670@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-sql


Hi,

I am having a function like this

create or replace function audio_format_func ( in p_bitrate audio_format.audio_bitrate%TYPE, in p_sampling_rate audio_format.sampling_rate%type, in p_bit_per_sample audio_format.bit_per_sample%type, in p_audio_codec audio_format.audio_codec%type, in p_mimetype audio_format.mimetype%type, in p_mono_stero audio_format.number_of_channel%type) returns int as$$DECLARE p_audio_id audio_format.audio_id%type;begin
select audio_id into a from audio_format where audio_bitrate = p_bitrate and sampling_rate = p_sampling_rate and mimetype = p_mimetype and number_of_channel = p_mono_stero and audio_code = p_audio_codec;
return 1; exception when NO_DATA_FOUND then return 100;end;$$language 'plpgsql';

When I compile, I am getting an error message
ERROR: unrecognized exception condition "no_data_found"CONTEXT: compile of PL/pgSQL function "audio_format_func" near line 15

How will I handle exceptions in postgres?

Please advise.

Regards
skarthi

_________________________________________________________________
i'm making a difference. Make every IM count for the cause of your choice. Join Now.
http://clk.atdmt.com/MSN/go/msnnkwme0080000001msn/direct/01/?href=http://im.live.com/messenger/im/home/?source=wlmailtagline

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Joe 2007-04-03 23:30:43 Re: [SQL] exception handling in postgres plpgsql
Previous Message Andreas Kretschmer 2007-04-03 18:18:43 Re: plpgsql function question

Browse pgsql-sql by date

  From Date Subject
Next Message Joe 2007-04-03 23:30:43 Re: [SQL] exception handling in postgres plpgsql
Previous Message John DeSoi 2007-04-03 20:27:16 Re: plpgsql function question