FireBird table alias

Posts   
 
    
Asimov
User
Posts: 113
Joined: 05-Dec-2003
# Posted on: 04-Dec-2004 21:19:57   

Hi!

I re-installed the OS on my computer and I downloaded all the latest llbl builds. Now when I run a query using a ResultsetFields collection (to use a group by and predicates), I get an error about an invalid token "AS". I checked the generated SQL and it refers to the AS used to specify the alias for a table. Without the AS keyword, the query works fine (as well as the alias). Any idea why it used to work and now it doesn't? I never noticed when my code worked (before I reisntalled my OS) if the AS keyword was generated or not...) I'm running firebird 1.5 on linux.

Thank you! simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 05-Dec-2004 12:13:31   

'AS' is only used for column aliasses, not table aliasses. Could you please paste the SQL generated and the code which produced it (your code) so I can try to reproduce it here?

Frans Bouma | Lead developer LLBLGen Pro
Asimov
User
Posts: 113
Joined: 05-Dec-2003
# Posted on: 05-Dec-2004 13:54:31   

Here's my code


ResultsetFields fields = new ResultsetFields(3);
                fields.DefineField(ArticleFieldIndex.CategorieId, 0, "CategorieId", "Article");
                fields.DefineField(ArticleFieldIndex.Creation, 1, "ArticleCreation", "Article", AggregateFunction.Max);
                fields.DefineField(ArticleFieldIndex.Id, 2, "ArticleId", "Article", AggregateFunction.Max);

                                ISortExpression sorter = new SortExpression(SortClauseFactory.Create(ArticleFieldIndex.Creation, SortOperator.Descending, "Article"));

                IGroupByCollection groupByClause = new GroupByCollection();
                groupByClause.Add(fields[0]);

                DataTable dtArticles = new DataTable();
                TypedListDAO dao = new TypedListDAO();
                dao.GetMultiAsDataTable(fields, dtArticles, 5, null, null, null, false, groupByClause, null, 0, 0);


and here's the generated SQL


SELECT FIRST 5 DISTINCT Article.PILTGCATEGORIEID AS CategorieId,MAX(Article.ARTCLCREATION) AS ArticleCreation,MAX(Article.ARTCLID) AS ArticleId FROM ARTICLE AS Article GROUP BY Article.PILTGCATEGORIEID

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 05-Dec-2004 19:49:05   

Ah, found it. Indeed a bug.

(btw, you don't have to specify an alias if you just use 1 entity. Only specify aliasses if you join an entity multiple times) simple_smile So removing the alias will give you a workaround.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 05-Dec-2004 20:11:16   

Please grab the hotfix for the runtimes. This should fix your problem. Firebird can't handle the 'AS' keyword for table alias definitions apparently.

Frans Bouma | Lead developer LLBLGen Pro
Asimov
User
Posts: 113
Joined: 05-Dec-2003
# Posted on: 05-Dec-2004 20:24:31   

Thanks simple_smile I'm glad to help from time to time, for all the times you've helped me out!