"Pre-parsing" of SQL statements?
Posted: Sat 15 Aug 2009 09:58
We have a situation where we want to insert SQL-queries into a table, for execution later on.
We have a table called "future_queries", which has two columns "sqlquery" (text) and "executetime" (datetime).
We insert data into this table using this code;
SQL.Text := 'INSERT INTO future_queries (sqlquery, executetime) VALUES (:sqlquery, :executetime)';
ParamByName('sqlquery').AsString := SQLQuery;
ParamByName('executetime').AsDateTime := Now + 1;
Execute;
The problem is that we need to have the data in SQLQuery string to be prepared somehow, since the query sometime can hold binary data etc, the data must be escaped the way that the provider expects it to be.
We would need something like this;
q.SQL.Text := 'INSERT INTO whatevertable (filename, data) VALUES (:filename, :data)';
q.ParamByName('filename').AsString := 'test.xml';
q.ParamByName('data').ReadFromStream(filestream);
SQLQuery := q.PreparsedQuery;
That is, to make the UniDAC to do all parsing of the parameters, but not execute the query, just return it as a string.
Is this possible somehow? This would also be a nice feature to have when logging the "real" query, instead of logging the query before it was parsed.
Regards,
Peter Olsson
We have a table called "future_queries", which has two columns "sqlquery" (text) and "executetime" (datetime).
We insert data into this table using this code;
SQL.Text := 'INSERT INTO future_queries (sqlquery, executetime) VALUES (:sqlquery, :executetime)';
ParamByName('sqlquery').AsString := SQLQuery;
ParamByName('executetime').AsDateTime := Now + 1;
Execute;
The problem is that we need to have the data in SQLQuery string to be prepared somehow, since the query sometime can hold binary data etc, the data must be escaped the way that the provider expects it to be.
We would need something like this;
q.SQL.Text := 'INSERT INTO whatevertable (filename, data) VALUES (:filename, :data)';
q.ParamByName('filename').AsString := 'test.xml';
q.ParamByName('data').ReadFromStream(filestream);
SQLQuery := q.PreparsedQuery;
That is, to make the UniDAC to do all parsing of the parameters, but not execute the query, just return it as a string.
Is this possible somehow? This would also be a nice feature to have when logging the "real" query, instead of logging the query before it was parsed.
Regards,
Peter Olsson