Kem Tekinay of MacTechnologies Consulting is proud to release SQLBuilder_MTC, a free, open-source module to build and prepare SQL statements.
SQLBuilder_MTC is pure Xojo code that lets you construct a SQL statement naturally while it assists with syntax through auto-complete. Thanks to the innovative “Conditional Where” feature, you can easily construct a query that varies depending on the values given.
SQLBuilder_MTC also introduces intelligence to the process. Because it links values directly to clauses, it can do things like substitute
IS NULL for
= where the given value is nil, or let you provide multiple values either in sequence (ParamArray) or as an array.
An example of how it’s used:
dim rs as RecordSet = SQLBuilder_MTC _ .SQLSelect( "" ) _ .From( "person" ) _ .CondWhere( firstName <> "", "first_name", "ILIKE", firstName ) _ .CondWhere( lastName <> "", "last_name", "ILIKE", lastName ) _ .Where( "ssn", ssn ) _ .OrderBy( "last_name, first_name" ) _ .Prepare( db ).SQLSelect
SQLBuilder_MTC is database agnostic and will handle all binding and preparation for you. You can see the extensive README and get it from: