Insert constraint

Previous Next

In the USoft Rule Language, express an INSERT constraint by FOR ... ADD:

USoft Rule Language

SQL Equivalent

FOR            participants

(

               reservation_id

,              person_id

)

ADD WHERE NOT EXISTS

SELECT         r.reservation_id

,              p.person_id

FROM           reservation r

,              person p

WHERE          condition

INSERT INTO participant

(

             reservation_id

,            person_id

)

SELECT

             r.reservation_id

,            p.person_id

FROM         reservation r

,            person p

WHERE NOT EXISTS

(

        SELECT       ''

        FROM         participant pt

        WHERE        pt.res_id = r.res_id

        AND          pt.person_id = p.person_id

)

AND     condition