On 10/20/2011 11:28 AM, gastrocus wrote:
--- In firebird-support@yahoogroups.com
mailto:firebird-support%40yahoogroups.com, Helen Borrie
helebor@... wrote:
What is the analogous way to achieve this in Firebird (2.5) ?
INSERT INTO emp (fruits) values ('mango')
where not exists
gastrocus wrote:
INSERT INTO T1 (type, name, sysid, flag) values (1, 'Z', 1, 0)
WHERE NOT EXISTS (SELECT 1 FROM T1 WHERE name = 'Z')
You can apply select to rdb$database table which always returns one row:
INSERT INTO T1 (type, name, sysid, flag)
SELECT 1, 'Z', 1, 0 FROM
Just realized you can make it even easier:
merge
into emp
using rdb$database
on emp.fruits = 'mango'
when not matched then insert (fruits) values ('mango')
An alternative (just an alternative available on all Firebird - and probably
many InterBase - versions, the MERGE
--- In firebird-support@yahoogroups.com, Helen Borrie helebor@... wrote:
What is the analogous way to achieve this in Firebird (2.5) ?
INSERT INTO emp (fruits) values ('mango')
where not exists (select 1 from emp where fruits = 'mango')
Thanks for the quick reply.
Strange... when I try
I do not believe that that way be able to
You should make a stored procedure with:
SELECT 1 FROM T1 WHERE name = :imput_parameter
if (row_count = 0) then
INSERT INTO T1 (type, name, sysid, flag) values (1, :imput_parameter, 1, 0);
Best Regards
=
|| ISMAEL ||
=
- Original
At 05:28 AM 21/10/2011, you wrote:
--- In firebird-support@yahoogroups.com, Helen Borrie helebor@... wrote:
What is the analogous way to achieve this in Firebird (2.5) ?
INSERT INTO emp (fruits) values ('mango')
where not exists (select 1 from emp where fruits = 'mango')
Strange... when I
--- In firebird-support@yahoogroups.com, Helen helebor@... wrote:
Would you like to try this:
merge into t1 tab2
using t1 tab1
on tab1.name = tab2.name and tab1.name = 'Z'
when not matched then
insert (type, name, sysid, flag) values (1, 'Z', 1, 0)
That works like a charm!
Hi Ed,
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.
Just realized you can make it even easier:
merge
into emp
using