Skip to content

Instantly share code, notes, and snippets.

@nathanlws
Created July 22, 2013 19:16
Show Gist options
  • Save nathanlws/6056726 to your computer and use it in GitHub Desktop.
Save nathanlws/6056726 to your computer and use it in GitHub Desktop.
Parser ORDER BY
import com.akiban.sql.parser.*;
public class ParserOrderBy {
public static void main(String[] args) throws Exception {
String sql = "Select id, refName from refRepo where property='SQL' order by id asc";
System.out.println("SQL: " + sql);
SQLParser parser = new SQLParser();
StatementNode node = parser.parseStatement(sql);
System.out.println(node);
}
}
/*
Download and extract:
https://launchpad.net/akiban-sql-parser/trunk/1.0.15/+download/akiban-sql-parser-1.0.15.tar.gz
Compile:
$ javac -cp akiban-sql-parser-1.0.15/akiban-sql-parser-1.0.15.jar ParserOrderBy.java
Run:
$ java -cp akiban-sql-parser-1.0.15/akiban-sql-parser-1.0.15.jar:. ParserOrderBy
SQL: Select id, refName from refRepo where property='SQL' order by id asc
name: null
updateMode: UNSPECIFIED
statementType: SELECT
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment