I have a layer containing an id and a geometry. then I have 3 tables X, Y, Z connected by a relation of 1 to several.

I will want to recover in Z for each new tuple the corresponding geometry, so as to obtain:

X1, Y1, Z1, geom (X1, Y1, Z1)
X1, Y1, Z2, geom (X1, Y1, Z2)
X1, Y2, Z1, geom (X1, Y2, Z1)
X1, Y2, Z2, geom (X1, Y2, Z2)

How could I do this?

PS: For now, I made a trigger, but I have an error "more than one line returned by a subquery used as a CONTEXT expression: SQL statement"

SELECT geom 
FROM   trigger2.geo_parcelle_majic2018_dist 
WHERE  (SELECT Upper (Concat_ws ('-', insee, section, parcel)) 
        FROM   trigger2.ref_cadas 
               natural JOIN trigger2.bien 
               natural JOIN trigger2.commune) IN 
              (SELECT ( Concat_ws ('-', Substring (geo_parcelle, 5.2) 
                        Substring (geo_parcelle, 8.3 
                        ), Substring ( 
                        , Substring (geo_parcelle, 
                          16, 4)) ) 
               FROM   trigger2.geo_parcelle_majic2018_dist) 

function PL / pgsql trigger2.maj_refcadas (), line 3 with SQL statement 
SQL state: 21000`
  • What are trying to do wirh the result? Insert it to a table? Or query it. A trigger is only used when data is inserted or updated. – Sir Swears-a-lot May 11 at 6:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.