Author Topic: SQLQuery "ParseSQL", how used?  (Read 3609 times)


  • Hero Member
  • *****
  • Posts: 849
SQLQuery "ParseSQL", how used?
« on: August 08, 2012, 11:02:53 pm »
Hi, I have been meaning to ask if anyone can brief on how this property is used: ParseSQL for the SQLQuery, which by default is True.

I though all SQL parsing is to be done by the SQL database engine.

I'm sure it has a purpose whose benefit I might be missing.



  • Hero Member
  • *****
  • Posts: 5365
Re: SQLQuery "ParseSQL", how used?
« Reply #1 on: August 09, 2012, 04:50:19 am »
When SQLParse is true the query can distinguish between queries that return data and ones that do not. This is the only usage of it you can't use it for anything else and this is internal to the query you do not have access to that part either. When you set it to false you are saying that you know what you are doing and you do not want the component to do any checks before opening or executing a command.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64


  • Hero Member
  • *****
  • Posts: 1173
Re: SQLQuery "ParseSQL", how used?
« Reply #2 on: August 09, 2012, 02:30:05 pm »
The function of TCustomSQLQuery.SQLParse is slightly different: SQLPrepare will always do a minimal parsing to find out what type of query it is dealing with (SELECT, INSERT, etc) to see if it can expect a resultset or not. When SQLParse is true it will continue parsing SELECT statements to determine whether the SELECT is updatable or not and extract the table name. It also detects if the SELECT statement has a WHERE part and stores the position of WHERE so that  server side filters can be construct by modifying or adding the WHERE clause.
So if SQLParse is false, the query is never updatable and ServerFiltered can't be set.

Not to be confused with the TParams.ParseSQL function which also parses the SQL statement but to find the parameters and their names in the query.


TinyPortal © 2005-2018