Generates Delphi code from your database and lets you build typesafe SQL queries through its fluent API.SQLBuilder4Delphi is a little Delphi library for dynamically generating SQL statements. It's sweet spot is for applications that need to build up complicated queries with criteria that changes at runtime. Ordinarily it can be quite painful to figure out how to build this string. SQLBuilder4Delphi takes much of this pain away.SQLBuilder4Delphi applies the concept: DSL. This acronym stands for Domain Specific Language and portrays a common trend in modern languages which basically consists in creating a subset of the language in order to facilitate the solution of simple and specific problems.The code of SQLBuilder4Delphi is intentionally clean and simple. Rather than provide support for every thing you could ever do with SQL, it provides support for the most common situations and allows you to easily modify the source to suit your needs.The SQLBuilder4Delphi provides libraries useful auxiliary for developing any Delphi application and requires Delphi 2010 or greater.You can't view the links! Click here to registerLimitations
- Values of type TDateTime, TDate, TTime should be used as string, for through TValue can not differentiate these types of a Float. (Example: Where('FieldDateTime').Equal('01.01.2015 01:05:22')). Or you can use the SQL.Value(). With this feature you can do something like: SQL.Value(Date).Date, SQL.Value(Now).Datetime and SQL.Value(Now).Time.
PHP Code:
[code]
//SQLBuilder Command
SQL.Select
.AllColumns
.From('Customer')
.ToString;
//SQL Result
Select * From Customer
//SQLBuilder Command
SQL.Select
.Column('Emp_No')
.Column('Full_Name')
.Column('Job_Code')
.Column('Job_Country')
.From('Employee')
.ToString;
//SQL Result
Select Emp_No, Full_Name, Job_Code, Job_Country From Employee
//SQLBuilder Command
SQL.Select
.Column('Emp_No')
.Column('Full_Name')
.Column('Job_Code')
.Column('Job_Country')
.Column('Currency')
.From('Employee')
.Join(
SQL.Join('Country').Condition(
SQL.JoinTerm.Left('Job_Country').Op(opEqual).Right('Country')
)
).Where('Currency').Equal('Dollar')
.ToString;
//SQL Result
Select Emp_No, Full_Name, Job_Code, Job_Country, Currency
From Employee
Join Country On (Job_Country = Country)
Where (Currency = 'Dollar')
//SQLBuilder Command
SQL.Select
.Column('Job_Country')
.Column(
SQL.Aggregate(aggSum, 'Min_Salary').Alias('Min_Salary')
)
.Column(
SQL.Coalesce(SQL.Aggregate(aggSum, 'Max_Salary'), 0).Alias('Max_Salary')
)
.From('Job')
.GroupBy(
SQL.GroupBy('job_country')
)
.Having.Expression(
SQL.AggCondition(SQL.Aggregate(aggSum, 'Min_Salary'), opGreater, 70000)
)
.OrderBy(
SQL.OrderBy('Job_Country')
)
.ToString;
//SQL Result
Select
Job_Country, Sum(Min_Salary) As Min_Salary,
Coalesce(Sum(Max_Salary),0) As Max_Salary
From Job
Group By job_country
Having (Sum(Min_Salary) > 70000)
Order By Job_Country
//SQLBuilder Command
SQL.Select
.Column('First_Name')
.Column('Last_Name')
.Column(
SQL.&Case('Job_Country')
.When('USA').&Then('United State')
.When('England').&Then('Great Britain')
.&Else('Other')
.&End.Alias('Job_Country')
)
.From('Employee')
.Where('Job_Grade').Greater(3)
.&And(SQL.Where('Job_Code').Equal('Admin')
.&Or('Job_Code').Equal('SRep'))
.ToString;
//SQL Result
Select
First_Name, Last_Name,
Case Job_Country
When 'USA' Then 'United State'
When 'England' Then 'Great Britain'
Else 'Other'
End As Job_Country
From Employee
Where (Job_Grade > 3) And ((Job_Code = 'Admin') Or (Job_Code = 'SRep'))
[/code]