SyntaxNode *SyntaxNode::findChild(int searchtoken) const { switch(m_token) { case NAME : case PARAM : case HOSTVAR : case STRING : case NUMBER : case DATECONST : case TIMECONST : case TIMESTAMPCONST: throwSqlError(SQL_FATAL_ERROR,_T("No children in findChild(%d) in SyntaxNode (line %d, token %d)") ,searchtoken,m_pos.getLineNumber(),m_token); break; } for(int i = 0; i < m_attributes.m_children.m_count; i++) { SyntaxNode *p = m_attributes.m_children.m_child[i]; if(p->token() == searchtoken) return p; } return NULL; }
void SqlCompiler::genInsert(SyntaxNode *n) { // n == <insert_stmt> const TCHAR *tableName = n->child(0)->name(); StatementTable table(*this,n->child(0)); if(!ok()) return; if(table.getTableType() != TABLETYPE_USER) { syntaxError(n->child(0),SQL_INVALID_TABLETYPE,_T("Cannot insert into systemtable <%s>"),tableName); return; } SyntaxNode *insertwhat = n->child(2); switch(insertwhat->token()) { case VALUES: genInsertValues(n,table); break; case SELECT: genInsertSelect(n); break; default: stopcomp(insertwhat); } m_code.appendIns0(CODERETURN); }