001package gudusoft.gsqlparser.stmt.teradata; 002 003 004import gudusoft.gsqlparser.*; 005import gudusoft.gsqlparser.nodes.TParseTreeVisitor; 006import gudusoft.gsqlparser.stmt.teradata.utilities.BteqCmdType; 007 008public class TTeradataBTEQCmd extends TCustomSqlStatement { 009 010 public TTeradataBTEQCmd(EDbVendor dbvendor) { 011 super(dbvendor); 012 sqlstatementtype = ESqlStatementType.sstteradataBTEQ; 013 } 014 015 public int doParseStatement(TCustomSqlStatement psql) { 016 // if (rootNode == null) return -1; 017 // super.doParseStatement(psql); 018 019 return 0; 020 } 021 022 protected int dochecksyntax(TCustomSqlStatement psql){ 023 isparsed = true; 024 return 0; //not check syntax of sqlplus cmd ,always ok 025 } 026 027 private BteqCmdType bteqCmdType; 028 029 public void setBteqCmdType(BteqCmdType bteqCmdType) { 030 this.bteqCmdType = bteqCmdType; 031 } 032 033 public BteqCmdType getBteqCmdType() { 034 return bteqCmdType; 035 } 036 037 private EFindSqlStateType sqlFindStateType; 038 public void setFindSqlStateType(EFindSqlStateType sqlFindStateType){ 039 040 this.sqlFindStateType = sqlFindStateType; 041 switch (sqlFindStateType){ 042 case stBTEQCmd: 043 sqlstatementtype = ESqlStatementType.sstteradataBTEQ; 044 break; 045 case stMultiLoadCmd: 046 sqlstatementtype = ESqlStatementType.sstteradaMultiLoad; 047 break; 048 case stFastExportCmd: 049 sqlstatementtype = ESqlStatementType.sstteradataFastExport; 050 break; 051 case stFastLoadCmd: 052 sqlstatementtype = ESqlStatementType.sstteradataFastLoad; 053 break; 054 055 } 056 } 057 058 public void accept(TParseTreeVisitor v){ 059 v.preVisit(this); 060 v.postVisit(this); 061 } 062 public void acceptChildren(TParseTreeVisitor v){ 063 v.preVisit(this); 064 v.postVisit(this); 065 } 066 067 public void setSqlFindStateType(EFindSqlStateType sqlFindStateType) { 068 this.sqlFindStateType = sqlFindStateType; 069 } 070 071 public String getParamValue(){ 072 if (this.toString() != null && this.toString().length() > 0) { 073 String[] parts = this.toString().trim().split("\\s+"); 074 if (parts.length >= 3 && parts[0].equalsIgnoreCase(".SET")) { 075 return parts[2].replaceAll(";$", ""); // Remove trailing semicolon if present 076 }else if(parts.length >= 2 && parts[0].equalsIgnoreCase(".ERRLIMIT")) { 077 return parts[1].replaceAll(";$", ""); // Remove trailing semicolon if present 078 } 079 } 080 return null; 081 } 082 083 public String getParamName(){ 084 if (this.toString() != null && this.toString().length() > 0) { 085 String[] parts = this.toString().trim().split("\\s+"); 086 if (parts.length >= 3 && parts[0].equalsIgnoreCase(".SET")) { 087 return parts[1].replaceAll(";$", ""); // Remove trailing semicolon if present 088 } 089 } 090 return null; 091 } 092 093}