Subject | RE: [firebird-support] select column |
---|---|
Author | Svein Erling Tysvær |
Post date | 2012-04-11T14:29:51Z |
>we have some workstations. Every ws need to show some fields of an table.No need for a configuration table, Olaf, you could construct your query on the fly from the system tables, e.g.
>Now I thought, I can configure that with the numbers of the column. I also could write
>down the column-Names in a configuration table, but sql statements should be slower.
WITH TMP(FieldName, FieldPos) AS
(SELECT RDB$FIELD_NAME, RDB$FIELD_POSITION+1
FROM RDB$RELATION_FIELDS
WHERE RDB$RELATION_NAME = :MyTableName
ORDER BY RDB$FIELD_POSITION)
SELECT 'SELECT ' || LIST(FieldName) || ' FROM ' || cast(:MyTableName as Char(31)) || ' WHERE ... '
FROM TMP
WHERE FieldPos in (2, 3) /*If you want field number 2 and 3*/
The result will be the SQL you want.
HTH,
Set