Subject Re: [firebird-support] select count in view Firebird 2.5
Author Thomas Steinmaurer
Hello,

> I have table and view, thats returning grouped field with the count of fields records in it.
> After upgrading from 2.1 to 2.5 I noticed that select count is returning null. Has anyone experienced anything like this and can confirm that it' s a bug and has reported it?
>
> Here is DDL:
> --------------------------------------------------------------------------------------
> -- Test table T_EMPLOYEE:
> SET SQL DIALECT 3;
>
> CREATE TABLE T_EMPLOYEE (
> ID INTEGER,
> NAME VARCHAR(20),
> DEPT_NO INTEGER
> );
>
> -- View
> SET SQL DIALECT 3;
> CREATE VIEW V_EMP_DEP(
> DEPT_NO,
> EMP_COUNT)
> AS
> select
> e.dept_no,
> (select count(*) from t_employee e1 where e1.dept_no = e.dept_no) as emp_count
> from t_employee e
> group by e.dept_no
> ;
> -- Data
> INSERT INTO T_EMPLOYEE (ID, NAME, DEPT_NO) VALUES (1, 'John', 100);
> INSERT INTO T_EMPLOYEE (ID, NAME, DEPT_NO) VALUES (2, 'Bob', 100);
> INSERT INTO T_EMPLOYEE (ID, NAME, DEPT_NO) VALUES (3, 'Dilan', 200);
> --------------------------------------------------------------------------------------
> select * from v_emp_dep in version 2.1 returns:
>
> dept_no emp_count
> -----------------
> 100 2
> 200 1
>
> select * from v_emp_dep in version 2.5 returns:
>
> dept_no emp_count
> -----------------
> 100 <null>
> 200 <null>

This is a bug in Firebird 2.5.0, which is marked as fixed for 2.5.1.
http://tracker.firebirdsql.org/browse/CORE-3141



--
With regards,

Thomas Steinmaurer
Upscene Productions
http://www.upscene.com
http://blog.upscene.com/thomas/

Download LogManager Series, FB TraceManager today!
Continuous Database Monitoring Solutions supporting
Firebird, InterBase, Advantage Database, MS SQL Server
and NexusDB!