On 20 Sep 2015, at 7:15pm, James K. Lowden <jklowden at schemamania.org> wrote:

> Simon Slavin <slavins at bigfraud.org> wrote:
> 
>> Constructions like this
>> 
>>> INSERT INTO _TAG_EXISTS_RESULT_ ( NAME, BOOL )
>>> SELECT 'evil little sister'
>> 
>> should be rewritten so that you are not trying to do a SELECT in the
>> middle of your INSERT.
> 
> Why in the world would you say that?  That's the SQL assignment
> function, the equivalent of 
> 
>       A = A + B

I would argue that that would be UPDATE, not INSERT.  But I see your side of 
the issue.

> Anything you'd do to rewrite it would result in something more complex,
> doubly so if it included the atomicity guarantee of the original. 

Suppose the SELECT doesn't return anything.  Do you still want to do the INSERT 
? Do you now have to look up the values to INSERT elsewhere ?  Put the commands 
in a transaction if that worries you.

You're right -- I should probably have written "I preffer" instead if making it 
an absolute statement.

Simon.

Reply via email to