001package gudusoft.gsqlparser.nodes; 002 003import gudusoft.gsqlparser.ESqlClause; 004import gudusoft.gsqlparser.TCustomSqlStatement; 005import gudusoft.gsqlparser.stmt.TSelectSqlStatement; 006 007/** 008* Indicates that only a specified first set or percent of rows will be returned from the query result set. 009 * expression can be either a number or a percent of the rows. 010 * <p> Syntax: 011 * <blockquote><pre> 012 * TOP ( expression ) [ PERCENT ] [ WITH TIES ]</pre> 013 * </blockquote> 014 015*/ 016public class TTopClause extends TParseTreeNode { 017 private TExpression expr = null; 018 private TSelectSqlNode selectNode = null; 019 private TSelectSqlStatement subquery = null; 020 021 public void init(Object arg1) 022 { 023 if (arg1 instanceof TExpression){ 024 expr = (TExpression)arg1; 025 } 026// else if (arg1 instanceof TSelectSqlNode){ 027// selectNode = (TSelectSqlNode)arg1; 028// } 029 030 } 031 032 public void doParse(TCustomSqlStatement psql, ESqlClause plocation){ 033 if (expr != null){ 034 expr.doParse(psql,plocation); 035 } 036 037// if (selectNode != null){ 038// if (subquery != null){ 039// subquery = new TSelectSqlStatement(psql.dbvendor); 040// subquery.rootNode = selectNode; 041// subquery.doParseStatement(psql); 042// } 043// } 044 } 045 046 public TSelectSqlStatement getSubquery() { 047 return subquery; 048 } 049 050 public TExpression getExpr() { 051 052 return expr; 053 } 054 055 private boolean percent = false; 056 private boolean withties = false; 057 058 public void setPercent(boolean percent) { 059 this.percent = percent; 060 } 061 062 public void setWithties(boolean withties) { 063 this.withties = withties; 064 } 065 066 public void setExpr(TExpression expr) { 067 this.expr = expr; 068 } 069 070 public void setSubquery(TSelectSqlStatement subquery) { 071 this.subquery = subquery; 072 } 073 074 public boolean isPercent() { 075 076 return percent; 077 } 078 079 public boolean isWithties() { 080 return withties; 081 } 082 083 public void accept(TParseTreeVisitor v){ 084 v.preVisit(this); 085 v.postVisit(this); 086 } 087 088 public void acceptChildren(TParseTreeVisitor v){ 089 v.preVisit(this); 090 expr.acceptChildren(v); 091 v.postVisit(this); 092 } 093 094 095}