Copyright: 0.9 (preview release)


QIFormatter component

 	TQIFormatter component

version

0.9   preview release

purpose

Produces SQL query scripting from the information contained in the connected QueryInfo component, aswell as the user orientated version thereof. Subtype this component to customize query script formatting for different database requirements.

properties

QueryInfo, Prefix, Qualify, DefaultSelect

methods

SQLSelectClause, SQLFromClause, SQLJoinClause, SQLFilterClause, SQLGroupClause, SQLOrderClause, UserSelectClause, UserFromClause, UserFilterClause, UserGroupClause, UserOrderClause, BuildSQLScript, BuildUserScript

events

OnSelectClause, OnFromClause, OnJoinClause, OnFilterClause, OnGroupClause, OnOrderClause

files

qiFormat.dcu	TQIFormatter

qiFormat.hlp	this file


QueryInfo property

References the TQueryInfo component whose query information it is to format.

type

TQueryInfo

stage

design time	run time

access

read 	write


Prefix property

If true, a description precedes the user version of the clause, eg “Show” or “Filter” or “Unfiltered”.

type

Boolean

stage

design time	run time

access

read 	write


Qualify property

If true, all field names are qualified by their table alias.  Should be set if multiple tables are used in case of duplicate field names.

type

Boolean

stage

design time	run time

access

read 	write


DefaultSelect property

If true, if no selections are defined, all selectable fields are included.

type

Boolean

stage

design time	run time

access

read 	write


Events
On…Clause events

Passes the clause string to give the programmer an opportunity to edit it.

declaration

TSQLClauseEvent = procedure(Sender: TObject; var Clause: string) of object;

applies to

OnSelectClause, OnFromClause, OnJoinClause, OnFilterClause, OnGroupClause, OnOrderClause


SQLSelectClause method

Returns the SQL SELECT clause of the query, built from the contained information, eg. ‘SELECT T1.CUST_NO, T1.CUST_NAME, SUM (PAYMENT)’.

declaration

function SQLSelectClause: String;


UserSelectClause method

Returns a user version of the query SELECT clause, built from the contained information, eg. ‘Show Customer No, Customer Name, the sum of Amount Paid’.

declaration

function UserSelectClause: String;


SQLFromClause method

Returns the SQL FROM clause of the query, built from the contained information, eg. ‘FROM CUSTOMERS T1, ORDERS T2’.

declaration

function SQLFromClause: String;


UserFromClause method

Returns the user version of the query FROM clause, built from the contained information, eg. ‘From Customers, Orders’.

declaration

function UserFromClause: String;


SQLJoinClause method

Returns the SQL join criteria for the use of multiple tables in the query, built from the contained information, eg. ‘WHERE T1.CUST_NO = T2.CUST_NO’.

declaration

function SQLJoinClause: String;


SQLFilterClause method

Returns the SQL WHERE clause, built from the contained information, eg. ‘WHERE T1.CUST_NAME IN [“BROWN”, “SMITH”, “JONES”] AND T2.ORDER_DATE <= 10/12/96’.

declaration

function SQLFilterClause: String;


UserFilterClause method

Returns a user version of the query WHERE clause, built from the contained information, eg. ‘Filtered where Customer Name is any of Brown, Smith, Jones and Order Date is smaller or equal to 10/12/96’.

Usage example:  FilterLabel.Caption := QIFormatter1.UserFilterClause;

declaration

function UserFilterClause: String;


SQLGroupClause method

Returns the SQL GROUP BY clause, built from the contained information, eg. ‘GROUP BY T1.CUST_NO’

declaration

function SQLGroupClause: String;


UserGroupClause method

Returns a user version of the query GROUP clause, built from the contained information, eg. Grouped by Order Number’.

declaration

function UserGroupClause: String;


SQLOrderClause method

Returns the SQL ORDER BY clause, built from the contained information, eg. ‘ORDER BY T1.CUST_NAME ASC, T1.PAYMENT DESC’

declaration

function SQLOrderClause: String;


UserOrderClause method

Returns a user version of the query ORDER BY clause, built from the contained information, eg. Sorted by Customer Name asc, Amount Paid desc’.

declaration

function UserOrderClause: String;


BuildSQLScript method

Returns an entire SQL query built from the current query information in the supplied string list. (Generally the sum of the SQL….Clause methods). Usage example: QueryInfo.BuildSQLScript(Query1.SQL);  Query1.Open;

declaration

procedure BuildSQLScript(Strings: TStrings);


BuildUserScript method

Returns an entire user query built from the current query information in the supplied string list. (Generally the sum of the User….Clause methods). Usage example: QueryInfo.BuildUserScript(Memo1.Lines);

declaration

procedure BuildUserScript(Strings: TStrings);