Recent

Author Topic: SQLdb and RefreshSQL  (Read 2103 times)

KarenT

  • Full Member
  • ***
  • Posts: 120
SQLdb and RefreshSQL
« on: May 22, 2017, 07:34:36 pm »
I am not familiar with having more than one SQL.Text functions built in the same Query. I can't find any Help on why this (and other ...SQL) are included. Seems like it might be a good thing depending on how they work, but the Help is more a reference rather than actual "help." :)

How is RefreshSQL (InsertSQL, UdateSQL etc) used? I understand *how* they are used as an SQL text, but confused as to when/why it is used.

If I assigned this to it at Design time,.
Code: Pascal  [Select][+][-]
  1.   aSQL.RefreshSQL.Text:='SELECT * FROM table';
  2.  


Then at some time later I use the normal SQL
Code: Pascal  [Select][+][-]
  1.   aSQL.SQL.Text:='SELECT * FROM table ORDER BY name';
  2.   aSQL.ExecSQL;
  3.  


If some time after that I use
Code: Pascal  [Select][+][-]
  1.   aSQL.Refresh;
  2.  


Will it revert to the "un-ordered" use of the RefreshSQL.Text by using that? Or what?





mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: SQLdb and RefreshSQL
« Reply #1 on: May 23, 2017, 08:37:21 am »
If you want a result back, never use execSQL. This function is for insert/update/delete.
If you're using SQLdb, a required dataset will bet put in TBufdataset. This is a memtable. You're 'disconnected' from the original table.
By sorting directly you can use 'ORDER BY'. But there's also a property indexfieldnames which sort your dataset.
Code: Pascal  [Select][+][-]
  1.   indexfieldnames := 'name';
  2.  

When using this property a refresh of your query will sort the dataset again with your given name.
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

 

TinyPortal © 2005-2018