001package gudusoft.gsqlparser.stmt; 002 003import gudusoft.gsqlparser.*; 004import gudusoft.gsqlparser.nodes.*; 005 006/** 007 * The FETCH statement retrieves rows of data from the result set of a multiple-row query. 008 * fetch cursor into variables 009 * In plsq and pgplsql 010 */ 011 012public class TFetchStmt extends TCustomSqlStatement { 013 014 public TFetchStmt(){ 015 this(EDbVendor.dbvoracle); 016 } 017 018 public TFetchStmt(EDbVendor dbvendor){ 019 super(dbvendor); 020 sqlstatementtype = ESqlStatementType.sst_fetchstmt; 021 } 022 023 void buildsql() { 024 } 025 026 void clear() { 027 } 028 029 String getasprettytext() { 030 return ""; 031 } 032 033 void iterate(TVisitorAbs pvisitor) { 034 } 035 036 public int doParseStatement(TCustomSqlStatement psql) { 037 super.doParseStatement(psql); 038 switch (dbvendor){ 039 case dbvmysql: 040 if (rootNode == null) return -1; 041 TFetchSqlNode node = (TFetchSqlNode)rootNode; 042 043 044 this.cursorName = node.getCursorName(); 045 this.variableNameObjectList = node.getVariableNames(); 046 break; 047 default: 048 break; 049 } 050 051 return 0; 052 } 053 054 public TObjectNameList getVariableNameObjectList() { 055 return variableNameObjectList; 056 } 057 058 private TObjectNameList variableNameObjectList = null; 059 060 private TObjectName cursorName = null; 061 062 /** 063 * 064 * @return 065 */ 066 public TObjectName getCursorName() { 067 return cursorName; 068 } 069 070 private TExpressionList variableNames = null; 071 072 /** 073 * 074 * @return variable names in into clause. 075 */ 076 public TExpressionList getVariableNames() { 077 return variableNames; 078 } 079 080 public void init(Object arg1,Object arg2) 081 { 082 cursorName = (TObjectName)arg1; 083 variableNames = (TExpressionList)arg2; 084 } 085 086 public void accept(TParseTreeVisitor v){ 087 v.preVisit(this); 088 v.postVisit(this); 089 } 090 091 public void acceptChildren(TParseTreeVisitor v){ 092 v.preVisit(this); 093 v.postVisit(this); 094 } 095 096 public void setCursorName(TObjectName cursorName) { 097 this.cursorName = cursorName; 098 } 099 100 public void setVariableNames(TExpressionList variableNames) { 101 this.variableNames = variableNames; 102 } 103}