Hi!

"With this I don't know whether the RETURNING returns NULL as a new value or 
nothing was updated. I would have to go to PSQL and use ROW_COUNT or something 
like that."

Workaround:
update foobar set foo = 2 where id = 1 returning id, bar;

if id is null then bar null values is valid, otherwise no update were made.

András

-----Original Message-----
From: Jiří Činčura [mailto:j...@cincura.net] 
Sent: Wednesday, November 29, 2017 11:52 AM
To: For discussion among Firebird Developers 
<firebird-devel@lists.sourceforge.net>
Subject: [Firebird-devel] RETURNING clause returning NULL row when no value was 
updated

Hi *,

both 2.5.7 and 3.0.3 have same behavior, so it's probably expected. But still, 
looks wrong to me (in such case educate me).

SQL> create table foobar (id int primary key, foo int, bar generated
always as (foo+1));
SQL> insert into foobar values (1, 1);
SQL> update foobar set foo = 2 where id = 1 returning bar;

                  BAR
=====================
                    3

SQL> update foobar set foo = 2 where id = -1 returning bar;

                  BAR
=====================
               <null>

SQL>

The second update did not update any records, yet it still returns one row in 
result with NULL value. Shouldn't it return empty result set?
With this I don't know whether the RETURNING returns NULL as a new value or 
nothing was updated. I would have to go to PSQL and use ROW_COUNT or something 
like that.

--
Mgr. Jiří Činčura
https://www.tabsoverspaces.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech 
sites, Slashdot.org! http://sdm.link/slashdot Firebird-Devel mailing list, web 
interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to