7 namespace Deveel.Data.Sql.Parser {
9 public string Direction {
get;
private set; }
11 public string CursorName {
get;
private set; }
18 if (node.
NodeName ==
"direction_opt") {
21 CursorName = ((IdentifierNode) node).Text;
22 }
else if (node.
NodeName ==
"into_opt") {
26 return base.OnChildNode(node);
30 var childNode = node.
ChildNodes.FirstOrDefault();
31 if (childNode == null)
34 childNode = childNode.ChildNodes.FirstOrDefault();
35 if (childNode == null)
38 if (String.Equals(childNode.NodeName,
"NEXT", StringComparison.OrdinalIgnoreCase) ||
39 String.Equals(childNode.NodeName,
"PRIOR", StringComparison.OrdinalIgnoreCase) ||
40 String.Equals(childNode.NodeName,
"FIRST", StringComparison.OrdinalIgnoreCase) ||
41 String.Equals(childNode.NodeName,
"LAST", StringComparison.OrdinalIgnoreCase)) {
42 Direction = childNode.NodeName.ToUpper();
43 }
else if (String.Equals(childNode.NodeName,
"ABSOLUTE", StringComparison.OrdinalIgnoreCase) ||
44 String.Equals(childNode.NodeName,
"RELATIVE", StringComparison.OrdinalIgnoreCase)) {
45 var positionNode = childNode.ChildNodes.FirstOrDefault();
46 if (positionNode == null)
47 throw new SqlParseException(
"The position expression if required in an ABSOLUTE or RELATIVE fetch.");
50 if (expression == null)
53 Direction = childNode.NodeName.ToUpper();
54 Position = expression;
59 foreach (var childNode
in node.ChildNodes) {
61 Into = childNode as IExpressionNode;
69 return Enum.TryParse(s,
true, out direction);
83 if (!TryParseDirection(Direction, out direction))
84 throw new InvalidOperationException();
This is a simple identifier within a SQL grammar.
Defines the contract for nodes in an AST model for a SQL grammar analysis and parsing.
string NodeName
Gets the name of the node analyzed from the parser.
static SqlExpression Build(IExpressionNode node)
override void BuildStatement(StatementBuilder builder)
void GetInto(ISqlNode node)
ICollection< IStatement > Statements
void GetDirection(ISqlNode node)
IEnumerable< ISqlNode > ChildNodes
Gets a read-only enumeration of the children nodes, if any.
override ISqlNode OnChildNode(ISqlNode node)
During the initialization of the node from the parser, this method is called for every child node add...
static bool TryParseDirection(string s, out FetchDirection direction)
An error that occurs when compiling a input string into a SQL object.
This interface acts like a marker that indicates if a ISqlNode represents a SQL expression.