Инструменты пользователя

Инструменты сайта


postgres:raise_exception

Различия

Здесь показаны различия между двумя версиями данной страницы.

Ссылка на это сравнение

Предыдущая версия справа и слева Предыдущая версия
Следующая версия
Предыдущая версия
postgres:raise_exception [2021/11/02 17:52]
werwolf [Examples of PostgreSQL RAISE EXCEPTION]
postgres:raise_exception [2023/01/12 12:18] (текущий)
Строка 75: Строка 75:
 ''​DO $$\\ BEGIN\\ RAISE INFO 'Print the message of information %', now() ;\\ RAISE LOG 'Print the message of log %', now();\\ RAISE DEBUG 'Print the message of debug %', now();\\ RAISE WARNING 'Print the message of warning %', now();\\ RAISE NOTICE 'Print the message of notice %', now();\\ RAISE EXCEPTION 'Print the message of exception %', now();\\ END $$;''​ ''​DO $$\\ BEGIN\\ RAISE INFO 'Print the message of information %', now() ;\\ RAISE LOG 'Print the message of log %', now();\\ RAISE DEBUG 'Print the message of debug %', now();\\ RAISE WARNING 'Print the message of warning %', now();\\ RAISE NOTICE 'Print the message of notice %', now();\\ RAISE EXCEPTION 'Print the message of exception %', now();\\ END $$;''​
  
-**Output:** 
  
-{{https://​cdn.educba.com/​academy/​wp-content/​uploads/​2020/​06/​PostgreSQL-RAISE-EXCRPTION-1.jpg.webp?​801x299|PostgreSQL RAISE EXCEPTION 1}} {{https://​cdn.educba.com/​academy/​wp-content/​uploads/​2020/​06/​PostgreSQL-RAISE-EXCRPTION-1.jpg.webp?​801x299|PostgreSQL RAISE EXCEPTION 1}} In the above example, only info, warning, notice and exception will display the information. But debug and log will not display the output information.+In the above example, only info, warning, notice and exception will display the information. But debug and log will not display the output information.
  
 === Example #2 === === Example #2 ===
Строка 90: Строка 89:
 ''​DO $$\\ DECLARE\\ personal_email varchar(100) := '​raise@exceptions.com';​\\ BEGIN\\ -- First check the user email id is correct as well as duplicate or not.\\ -- If user email id is duplicate then report mail as duplicate.\\ RAISE EXCEPTION 'Enter email is duplicate: %', personal_email\\ USING HINT = 'Check email and enter correct email ID of user';​\\ END $$;''​ ''​DO $$\\ DECLARE\\ personal_email varchar(100) := '​raise@exceptions.com';​\\ BEGIN\\ -- First check the user email id is correct as well as duplicate or not.\\ -- If user email id is duplicate then report mail as duplicate.\\ RAISE EXCEPTION 'Enter email is duplicate: %', personal_email\\ USING HINT = 'Check email and enter correct email ID of user';​\\ END $$;''​
  
-**Output:** 
  
-{{data:​image/​svg+xml,​%3Csvg%20xmlns='​http://​www.w3.org/​2000/​svg'​%20viewBox='​0%200%20797%20304'​%3E%3C/​svg%3E?​797x304|PostgreSQL RAISE EXCEPTION 2}} {{https://​cdn.educba.com/​academy/​wp-content/​uploads/​2020/​06/​PostgreSQL-RAISE-EXCRPTION-2.jpg.webp?​797x304|PostgreSQL RAISE EXCEPTION 2}} === Example #3 ===+ 
 +=== Example #3 ===
  
 Raise exception by creating function. Raise exception by creating function.
Строка 99: Строка 98:
  
 **Code:** **Code:**
 +<code sql>
 +create or replace function test_exp() returns void as\\ $$\\ begin\\ raise exception using message = 'S 167', detail = 'D 167', hint = 'H 167', errcode = '​P3333';​\\ end;\\ $$ language plpgsql\\ ;
 +</​code>​
  
-''​create or replace function test_exp() returns void as\\ $$\\ begin\\ raise exception using message = 'S 167', detail = 'D 167', hint = 'H 167', errcode = '​P3333';​\\ end;\\ $$ language plpgsql\\ ;''​ +==== Advantages of PostgreSQL RAISE EXCEPTION ====
- +
-**Output:​** +
-==== Advantages of PostgreSQL RAISE EXCEPTION ====+
  
 Below are the advantages: Below are the advantages:
postgres/raise_exception.1635864720.txt.gz · Последние изменения: 2023/01/12 12:17 (внешнее изменение)