Subject | Re: [firebird-support] Re: How to insert only if a matching row does not exist? |
---|---|
Author | Milan Babuskov |
Post date | 2011-10-25T13:46:52Z |
gastrocus wrote:
INSERT INTO T1 (type, name, sysid, flag)
SELECT 1, 'ZZZZZ', 1, 0 FROM RDB$DATABASE
WHERE NOT EXISTS (SELECT 1 FROM T1 WHERE name = 'ZZZZZ');
HTH
--
Milan Babuskov
==================================
The easiest way to import XML, CSV
and textual files into Firebird:
http://www.guacosoft.com/xmlwizard
==================================
> INSERT INTO T1 (type, name, sysid, flag) values (1, 'ZZZZZ', 1, 0)You can apply select to rdb$database table which always returns one row:
> WHERE NOT EXISTS (SELECT 1 FROM T1 WHERE name = 'ZZZZZ')
INSERT INTO T1 (type, name, sysid, flag)
SELECT 1, 'ZZZZZ', 1, 0 FROM RDB$DATABASE
WHERE NOT EXISTS (SELECT 1 FROM T1 WHERE name = 'ZZZZZ');
HTH
--
Milan Babuskov
==================================
The easiest way to import XML, CSV
and textual files into Firebird:
http://www.guacosoft.com/xmlwizard
==================================