1 /*
2  * Copyright 2015-2018 HuntLabs.cn
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 module hunt.sql.dialect.mysql.ast.clause.MySqlCursorDeclareStatement;
17 
18 import hunt.sql.ast.SQLName;
19 import hunt.sql.ast.expr.SQLIdentifierExpr;
20 import hunt.sql.ast.statement.SQLSelect;
21 import hunt.sql.ast.statement.SQLSelectStatement;
22 import hunt.sql.dialect.mysql.ast.statement.MySqlStatementImpl;
23 import hunt.sql.dialect.mysql.visitor.MySqlASTVisitor;
24 
25 public class MySqlCursorDeclareStatement : MySqlStatementImpl{
26 	
27 	alias accept0 = MySqlStatementImpl.accept0;
28 	//cursor name
29 	private SQLName cursorName;
30 	//select statement
31 	private SQLSelect select;
32 	
33 	public SQLName getCursorName() {
34 		return cursorName;
35 	}
36 	
37 	public void setCursorName(SQLName cursorName) {
38 		if (cursorName !is null) {
39 			cursorName.setParent(this);
40 		}
41 		this.cursorName = cursorName;
42 	}
43 
44 	public void setCursorName(string cursorName) {
45 		this.setCursorName(new SQLIdentifierExpr(cursorName));
46 	}
47 
48 	public SQLSelect getSelect() {
49 		return select;
50 	}
51 
52 	public void setSelect(SQLSelect select) {
53 		if (select !is null) {
54 			select.setParent(this);
55 		}
56 		this.select = select;
57 	}
58 
59 	override
60 	public void accept0(MySqlASTVisitor visitor) {
61 		 if (visitor.visit(this)) {
62 	         acceptChild(visitor, select);
63 	        }
64 	     visitor.endVisit(this);
65 		
66 	}
67 
68 }