001package gudusoft.gsqlparser.nodes; 002 003 004import gudusoft.gsqlparser.TSourceToken; 005import gudusoft.gsqlparser.nodes.TConstant; 006import gudusoft.gsqlparser.nodes.TObjectName; 007import gudusoft.gsqlparser.nodes.TParseTreeNode; 008 009public class TPrepareSqlNode extends TParseTreeNode { 010 011 private TObjectName stmtName; 012 private TSourceToken preparableStmtToken; 013 private TTypeNameList datatypeList; 014 private TParseTreeNode statementNode; 015 016 public void init(Object arg1,Object arg2){ 017 stmtName = (TObjectName)arg1; 018 preparableStmtToken = (TSourceToken)arg2; 019 } 020 021 /** 022 * PostgreSQL {@code PREPARE name [ ( data_type [, ...] ) ] AS statement} (Mantis 4868): the statement 023 * is part of the parse tree, not a string. 024 * 025 * @param arg1 the name of the prepared statement 026 * @param arg2 the parameter data types, or null when the statement has no type list 027 * @param arg3 the parse tree node of the prepared SELECT, INSERT, UPDATE, DELETE, MERGE or VALUES 028 */ 029 public void init(Object arg1,Object arg2,Object arg3){ 030 stmtName = (TObjectName)arg1; 031 datatypeList = (TTypeNameList)arg2; 032 statementNode = (TParseTreeNode)arg3; 033 } 034 035 036 public TObjectName getStmtName() { 037 return stmtName; 038 } 039 040 /** 041 * @return the text of the prepared statement when it is given as a string or a variable, or the empty string 042 * when the statement is part of the parse tree (see {@link #getStatementNode()}) 043 */ 044 public String getPreparableStmt(){ 045 return preparableStmtToken == null ? "" : preparableStmtToken.toString(); 046 } 047 048 /** 049 * @return the parameter data types of a PostgreSQL PREPARE, or null when it has none 050 */ 051 public TTypeNameList getDatatypeList() { 052 return datatypeList; 053 } 054 055 /** 056 * @return the parse tree node of the prepared statement of a PostgreSQL PREPARE, or null when the statement 057 * is given as a string or a variable 058 */ 059 public TParseTreeNode getStatementNode() { 060 return statementNode; 061 } 062}