Insert with where clause

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 20-Jun-2013 23:48:08   

What's the best way to insert an entity only if there's a related row in the database with a particular column value. Something like this imaginary query...


INSERT INTO Foo (Id, col1) VALUES (4, 1)
INNER JOIN Bar ON Foo.Id = Bar.Id
WHERE Bar.Status = 1

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Jun-2013 07:51:11   

That is not supported (passsing a IRelationPredicateBucket into an adapter.Save action). As I see it, the options are:

A. Check for the restriction before the insert. B. Do it at DB trigger level.

David Elizondo | LLBLGen Support Team
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 21-Jun-2013 10:06:53   

In t-sql I reckon it could be done using SELECT INTO.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 21-Jun-2013 10:57:27   

Unfortunately not supported.