Is there a parser for Firebird SQL

412 views Asked by At

Using Firebird and the .Net Firebird provider. Looking for something like:

using (var cmd = new FbCommand()) {

   var parser = new FbParser(someSqlText);

   // Add a filter to the where clause. May need code for adding a "where" if there is none or adding an "and" statement, etc.
   parser.MainWhereClause += "someTable.someField = @someParam";

   // Default some orderby. Add one, etc?
   parser.OrderByClause = parser.OrderByClause ?? "customer.name";

   parser.SelectFields.Add("customer.phone");
   if (parser.GroupByFields.Any()) {
      parser.GroupByFields.Add("customer.phone");
   }

   cmd.CommandText = parser.ToString();

   // FbCommand does have a Prepare() method and that does allow that object to know the parameters, but they are private and not accessible.
   foreach (var parameterName in parser.Parameters) {
      cmd.Parameters.Add(parameterName).Value = GetSomeValue(parameterName);
   }

Anything like this out there? I am finding this for other SQL flavors, but nothing understands the FB syntax like the concatenations, CTEs, derived tables, etc.

0

There are 0 answers