Recent

Author Topic: IndexFieldNames (multiuse query)  (Read 3287 times)

exdatis

  • Hero Member
  • *****
  • Posts: 668
    • exdatis
IndexFieldNames (multiuse query)
« on: July 06, 2012, 08:38:51 am »
 :-[
Hi!
I have SQLQuery component  for simple queries which I use many times with different SQL, e.g.
  DbModule.SQLAny.Close;
  DbModule.SQLAny.SQL.Clear;
  DbModule.SQLAny.SQL.Text:= SOME_SQL; //+ open
The problem occurs if I use(db_grid on TitleClick):
    if not DbModule.SQLAny.IsEmpty then
      DbModule.SQLAny.IndexFieldNames:= Column.FieldName;
After close/open new form(and use SQLAny), I've got error because IndexFiled exist.
I tried: DbModule.SQLAny.IndexFieldNames:= ''; without success.  %)
How to clear IndexFieldNames?
Thanks.
C.T.2.5 XUbuntu12.4(32), Firebird2.5
« Last Edit: July 06, 2012, 09:44:48 am by exdatis »

exdatis

  • Hero Member
  • *****
  • Posts: 668
    • exdatis
Re: IndexFieldNames (multiuse query)
« Reply #1 on: July 07, 2012, 12:34:31 pm »
Well, I suppose, I'll have to find an alternative solution.
Thank you anyway.
Regards.

TheBlackSheep

  • Jr. Member
  • **
  • Posts: 93
Re: IndexFieldNames (multiuse query)
« Reply #2 on: July 07, 2012, 01:44:45 pm »
Hi exdatis

I tend to build the SQL and us the "order by" and the field name of the titlebutton - you have more control and you don't have to worry whether there is an index or not (you can sort by any field - the relevant sql engine should use the relevant index if one exists for the query).

You will need to add the "asc" or "desc" depending on which was title button was clicked before - sort by asc if it's a different field than last time and only do "desc" if it was the same field and "asc" was used in the previous query.

TheBlackSheep


exdatis

  • Hero Member
  • *****
  • Posts: 668
    • exdatis
Re: IndexFieldNames (multiuse query)
« Reply #3 on: July 07, 2012, 01:50:38 pm »
Thank you very much TheBlackSheep. Good idea.
Regards!

 

TinyPortal © 2005-2018