Re: A new scenario for check constraints - Mailing list pgsql-sql

From Steve Midgley
Subject Re: A new scenario for check constraints
Date
Msg-id CAJexoSLKxRvqM72W_wqOKZb9eDiOA1t=g+SiDeXRwA9R1_0TeA@mail.gmail.com
Whole thread Raw
In response to A new scenario for check constraints  (Shaozhong SHI <shishaozhong@gmail.com>)
List pgsql-sql

On Fri, Oct 8, 2021 at 4:14 AM Shaozhong SHI <shishaozhong@gmail.com> wrote:
Hi, All,

Can Postgres do some thing like this one?

The scenario is that we have a large Postgres table.  Can a solution be designed to create a table with constraint specifications and filter in all records meeting specifications and producing reports (e.g., on problematic ones)?

Your question about TRY/CATCH and your subsequent paragraph don't seem related to me. For exception handling, I think functionally it's identical to the MS SQL example you shared (though syntactically different): https://www.postgresql.org/docs/current/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING

Regarding your second question, I think you just want to write some stored procedures -- the cool thing about Pg is you can write them in almost any language you can think of, but I believe writing them in SQL is the easiest and with the most support/examples online:

You can create "procedures" and "functions" and to be honest I'm not totally clear on the difference, but I know others here are: https://www.postgresql.org/docs/current/sql-createprocedure.html

Write with specific issues you are having and the specific code you are using, and the results you are expecting and you'll get better support.

Steve

 

pgsql-sql by date:

Previous
From: Steve Midgley
Date:
Subject: Re: How to capture error message and save to a table in PostgreSQL?
Next
From: Karsten Hilbert
Date:
Subject: Re: How to capture error message and save to a table in PostgreSQL?