Not sure this helps, a way to a conditionally insert based on if record
already exists, is a select with literals left outer joined to the maybe
record and use a where test value is null.

Something like this pseudo SQL

insert into T  (valueA, valueB') (select 'ValueA', 'ValueB' left outer
join T where T.valueA ='valueA' and T.valueA is null);


On 11/18/2019 2:14 PM, Simon Slavin wrote:
> On 18 Nov 2019, at 10:00pm, Jose Isaias Cabrera <jic...@outlook.com> wrote:
>
>> Thanks Keith.  So, you are saying that this is a bad INSERT, and I don't 
>> know much to argue, but is working. If I take out the first IfNull, and 
>> there is not, at least one instance of 'p006' in the table, the INSERT never 
>> works. I was thinking of using COALESCE, but that would also mean that one 
>> or the other would have to be not null. Any suggestion would be appreciated.
> Being completely serious, whenever I see "undocumented" or "implementation 
> dependent" or "optimization side-effect", or a SQL statement I can't parse in 
> my head, I usually decide to do it in my programming language instead.  This 
> simplifies testing and debugging, and makes things easier for the poor 
> engineer who has to understand my code.
>
> You can do clever things in a language like SQL which allows recursive 
> construction clauses.  But what strikes me as ingenious when I'm writing it 
> can look bizarre and impenetrable to me, or someone else, a year later.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to