select [some computed value] as ID1 from "MyTable"
String Concatenation
The concatenation operator is language dependent - in Firebird SQL, it is 2 verticle bars.
select "field1" || ' ' || "field2" as r1 from "MyTable"A problem with this occurs when one of the fields returns a null value - in the case, the result of the concatenation is also null.
This can be "fixed" by using the coalesce function.
To actually use the result in a program, it is important to use the as clause (the word "as" is optional).
select coalesce("field1", 'unknown') || ' ' || coalesce("field2", 'unknown') as r1 from "MyTable"The following is an example from working Delhpi code - notice that the single quote is the Delphi string delimiter and, therefore, it is doubled to include it in the actual sql string.
s := 'SELECT coalesce("Port_Barcode", ''na'')' + ' || '' '' || coalesce("Sample_Holder_Barcode", ''na'')' + ' || '' '' || coalesce("Filter_Holder_Barcode", ''na'') as Config,' + ' "ID" ' + ' FROM "Port_Configurations_tbl" ' + ' WHERE "Experiment_ID" = ''' + Experiment_ID + '''' ;
Function Call
See this for more information on Firebird generators
Author: Robert Clemenzi - clemenzi@cpcug.org