Subject Re: How to insert only if a matching row does not exist?
Author gastrocus
--- In firebird-support@yahoogroups.com, Paul Vinkenoog <paul@...> wrote:
>
> > So, when I tested it on a table which had 100 rows (non matching the 'ZZZZZ' test), it inserted 100 new rows, each with a 'ZZZZ' name.
>
> Yes, if you want to use this trick, the _source_ table should have 1 row.
>
> So this works:
>
> merge
> into emp
> using (select 'mango' fruits from rdb$database) src
> on emp.fruits = src.fruits
> when not matched then insert (fruits) values ('mango')
>

Nice trick! That seems to work.

Cheers.
Ed