I don't think you could express it in the SELECT directly (someone else will probably build a statement refuting that) but you could do:
SELECT r.RDB$FIELD_NAME FROM RDB$RELATION_FIELDS r where r.RDB$RELATION_NAME=<your table name here> and then process that result set to build your appropriate SELECT for the target table. So I suppose you could build a statement with a quantity of derived sets using IIF and WHERE EXISTS - the question is do you need to express this as single SELECT, or can you accomplish your goal either via your calling program or a stored procedure? -- Daniel On 10/9/2017 1:36:20 AM, "Elmar Haneke el...@haneke.de [firebird-support]" <firebird-support@yahoogroups.com> wrote: > >>Is there a way to include a column in a SELECT but substitute a value >>if >>it doesn't? I need my code to work with different versions of my db >>schema. >> >>eg I want to SELECT A, B, C, ... but C might not exist. >> >>SELECT * would work of course, except it will fetch a bunch of columns >>I >>don't need. > >You can read the list of fields available in advance and modify your >query ommitting missing columns. > > >Elmar > > > >------------------------------------ >Posted by: Elmar Haneke <el...@haneke.de> >------------------------------------ > >++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > >Visit http://www.firebirdsql.org and click the Documentation item >on the main (top) menu. Try FAQ and other links from the left-side >menu there. > >Also search the knowledgebases at >http://www.ibphoenix.com/resources/documents/ > >++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >------------------------------------ > >Yahoo Groups Links > > >