001package gudusoft.gsqlparser.stmt.oracle;
002
003import gudusoft.gsqlparser.*;
004import gudusoft.gsqlparser.nodes.TObjectName;
005import gudusoft.gsqlparser.nodes.TTypeName;
006import gudusoft.gsqlparser.nodes.TParseTreeVisitor;
007
008/**
009 * A collection groups elements of the same type in a specified order. Each element has a unique subscript that determines its position in the collection.
010 *<p>PL/SQL has three kinds of collections:
011 *<ul>
012 *<li>Associative arrays (formerly called "PL/SQL tables" or "index-by tables"), represents by {@link TPlsqlTableTypeDefStmt}</li>
013 *<li>Nested tables, represents by {@link TPlsqlTableTypeDefStmt}</li>
014 *<li>Variable-size arrays (varrays), represents by {@link TPlsqlVarrayTypeDefStmt}</li>
015 *</ul>
016 *<p>Associative arrays can be indexed by either integers or strings. Nested tables and varrays are indexed by integers.
017 */
018
019public class TPlsqlTableTypeDefStmt extends TCustomSqlStatement {
020    public TPlsqlTableTypeDefStmt(){
021        this(EDbVendor.dbvoracle);
022    }
023
024     public TPlsqlTableTypeDefStmt(EDbVendor dbvendor){
025        super(dbvendor);
026        sqlstatementtype = ESqlStatementType.sstplsql_tabletypedef ;
027        }
028
029    void buildsql() {
030    }
031
032    void clear() {
033    }
034
035    String getasprettytext() {
036        return "";
037    }
038
039    void iterate(TVisitorAbs pvisitor) {
040    }
041
042    public int doParseStatement(TCustomSqlStatement psql) {
043        super.doParseStatement(psql);
044        return 0;
045    }
046
047    private TObjectName typeName = null;
048    private TTypeName elementDataType = null;
049    private Boolean notNull = false;
050    private TTypeName indexByDataType = null;
051
052    /**
053     * For an associative array, the data type of its indexes PLS_INTEGER, BINARY_INTGER, or VARCHAR2.
054     * @return
055     */
056    public TTypeName getIndexByDataType() {
057        return indexByDataType;
058    }
059
060    /**
061     * Specifies that no element of the collection can have the value NULL.
062     * @return
063     */
064    public Boolean getNotNull() {
065        return notNull;
066    }
067
068    public void setIndexByDataType(TTypeName indexByDataType) {
069
070        this.indexByDataType = indexByDataType;
071    }
072
073    public void setNotNull(Boolean notNull) {
074        this.notNull = notNull;
075    }
076
077    private boolean ifNotExists = false;
078
079    public void setIfNotExists(boolean ifNotExists) {
080        this.ifNotExists = ifNotExists;
081    }
082
083    /**
084     *
085     * @return True if IF NOT EXISTS clause was specified.
086     */
087    public boolean isIfNotExists() {
088        return ifNotExists;
089    }
090
091    private boolean notPersistable = false;
092
093    public void setNotPersistable(boolean notPersistable) {
094        this.notPersistable = notPersistable;
095    }
096
097    /**
098     *
099     * @return True if NOT PERSISTABLE clause was specified (Oracle 26 PL/SQL feature).
100     */
101    public boolean isNotPersistable() {
102        return notPersistable;
103    }
104
105    /**
106     * The data type of the collection element.
107     * @return
108     */
109    public TTypeName getElementDataType() {
110        return elementDataType;
111    }
112
113    /**
114     * The name that you give to the collection type that you are defining.
115     * @return
116     */
117    public TObjectName getTypeName() {
118        return typeName;
119    }
120
121    public void init(Object arg1,Object arg2)
122    {
123        typeName = (TObjectName)arg1;
124        //typeName.setObjectType(TObjectName.ttobjTypeName);
125        typeName.setDbObjectType(EDbObjectType.user_defined_type);
126        elementDataType = (TTypeName)arg2;
127    }
128
129    public void accept(TParseTreeVisitor v){
130        v.preVisit(this);
131        v.postVisit(this);
132    }
133
134    public void acceptChildren(TParseTreeVisitor v){
135        v.preVisit(this);
136        v.postVisit(this);
137    }
138
139    public void setTypeName(TObjectName typeName) {
140        this.typeName = typeName;
141    }
142
143    public void setElementDataType(TTypeName elementDataType) {
144        this.elementDataType = elementDataType;
145    }
146}