Create a check constraint across multiple schemas in PostGIS I'm a little new to this so apologies up front if my vocabulary is incorrect.

I'm trying to create a check constraint that determines whether a new point is located within an existing polygon. The issue is that the new point is created in one schema, and the existing polygon geometry is located in another schema.

I believe I need to create a function using 
ST_Within(NEW.geom, existing.geom) and then call that function as a constraint. However, I don't know how to deal with the syntax when using schema-qualified tables, and also be able to use NEW.geom in the function. 

Any help is greatly apreciated!
You need a trigger that runs on UPDATE and INSERT (when a row would otherwise be modified). As a-horse-with-no-name said in a comment:


  Not possible. A check constraint can only validate column values of one row in one table.