Franki1986
Franki1986

Reputation: 1436

Firebird select non existing columns

Is it anyhow possible to return NULL values for non-existing columns in Firebird? Let's say you have an ORM Framework and want to support multiple database versions, wherein some tables columns exist or not. So in case, a column does not exist, is it possible to return a NULL value?

Upvotes: 0

Views: 161

Answers (1)

Mark Rotteveel
Mark Rotteveel

Reputation: 109171

There is nothing in Firebird itself that would allow you to do that. Selecting from a non-existing column is an error, and with good reason.

To allow for something like this, you would need to have your ORM support this and have it rewrite the queries based on the underlying table structure, which is not an easy thing to do, and on top of that a very unusual requirement. Alternatively, you should consider writing an API with implementations for the different database versions, and select the right implementation based on the underlying database.

But the only real and viable solution, would be to either have your application refuse to work with a wrong database version (eg if the db version is too high), or otherwise make it automatically upgrade the structure (eg if the db version is too low).

Upvotes: 1

Related Questions