User defined exceptions
| От | Alex Ignatov |
|---|---|
| Тема | User defined exceptions |
| Дата | |
| Msg-id | [email protected] обсуждение исходный текст |
| Ответы |
Re: User defined exceptions
Re: User defined exceptions Re: User defined exceptions Re: User defined exceptions |
| Список | pgsql-sql |
Hello all!<br /> Trying to emulate "named" user defined exception with:<br /> CREATE OR REPLACE FUNCTION exception_aaa () RETURNS text AS $body$<br /> BEGIN<br /> return 31234; <br /> END;<br /> $body$<br /> LANGUAGE PLPGSQL<br /> SECURITYDEFINER<br /> ;<br /><br /> do $$<br /> begin<br /> raise exception using errcode=exception_aaa();<br /> exception<br /> when sqlstate exception_aaa()<br /> then<br /> raise notice 'got exception %',sqlstate;<br />end;<br /> $$<br /> <br /> Got:<br /><br /> ERROR: syntax error at or near "exception_aaa"<br /> LINE 20: sqlstate exception_aaa()<br/><br /> I looks like "when sqlstate exception_aaa()" doesn't work. <br /><br /> How can I catch exceptionin this case?<br /><pre class="moz-signature" cols="72">-- Alex Ignatov Postgres Professional: <a class="moz-txt-link-freetext" href="http://www.postgrespro.ru/%3Ca%20href="http://www.postgrespro.com/">http://www.postgrespro.com">http://www.postgrespro.com</a> The Russian Postgres Company </pre><br /><br /><hr style="border:none; color:#909090; background-color:#B0B0B0; height: 1px; width: 99%;" /><table style="border-collapse:collapse;border:none;"><tr><tdstyle="border:none;padding:0px 15px 0px 8px"><a href="http://www.postgrespro.ru/%3Ca%20href="https://www.avast.com/antivirus">https://www.avast.com/antivirus"><img alt="Avast logo" border="0" src="http://www.postgrespro.ru/%3Ca%20href="http://static.avast.com/emails/avast-mail-stamp.png">http://static.avast.com/emails/avast-mail-stamp.png"/> </a></td><td><p style="color:#3d4d5a; font-family:"Calibri","Verdana","Arial","Helvetica";font-size:12pt;"> This email has been checked for viruses by Avast antivirussoftware. <br /><a href="http://www.postgrespro.ru/%3Ca%20href="https://www.avast.com/antivirus">https://www.avast.com/antivirus">www.avast.com</a></td></tr></table><br />
В списке pgsql-sql по дате отправления: