Thread: A new scenario for check constraints
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)?
Regards,
David
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