What is the cause of using SELECT null FROM RDB $ DATABASE

4

I'm not understanding this SELECT null FROM RDB$DATABASE :

SELECT CK.IDCHEK,
       CK.DESCHE,
       (SELECT null FROM RDB$DATABASE) AS ENTEGU
FROM TC_CHECKL CK
ORDER BY CK.IDCHEK

It looks like it goes into an internal table of the bank and does not bring anything. Later in the code the programmer is saving this with insert directly into the database in the onDraw event.     

asked by anonymous 20.02.2014 / 15:20

2 answers

1

At first, none. In SQL, considering version 2.0 on Firebird, the code you showed is no better than the code below:

SELECT CK.IDCHEK,
       CK.DESCHE,
       null AS ENTEGU
FROM TC_CHECKL CK
ORDER BY CK.IDCHEK

I did a search for possible bugs in Firebird, but I did not find any related to the query. So, in addition to possible programmer error that made SQL, I believe two things could be the causes:

1) Due to compatibility with components used in Delphi. Maybe using the SQL in my response, the components detect the ENTEGU field as if it were of a different type (float or string) than the current SQL.

2) Select was more complicated using other fields, but was optimized. To avoid possible errors, the programmer kept (SELECT null FROM RDB$DATABASE) .

    
20.02.2014 / 17:22
-1

This is a way to execute queries that return only one record. I think Firebird does not support TOP 1. Here are some examples: link

If the current version allows queries that return only one record without using the form above, it may be worth refactoring in the name of clarity.

    
20.02.2014 / 15:38