sqlparser/language.cpp
// Check for implicit field reference (without record name)
Check for implicit field reference (without record name)
Check for implicit field reference ( without record name )
bool SqlParser::ConvertImplicitForRecordVariable(Token *token)
{
	if(token == NULL || _source != SQL_DB2 || _spl_implicit_record_fields.GetCount() == 0)
		return false;
	bool exists = false;
	ListwmItem *i = Find(_spl_implicit_record_fields, NULL, token);
	if(i != NULL && i->value != NULL && i->value2 != NULL)
	{
		Token *rec = (Token*)i->value;
		if(Token::Compare(token, rec, rec->len) == false)
		{
			if(IsScope(SQL_SCOPE_INSERT_VALUES) == true ||
				(IsScope(SQL_SCOPE_ASSIGNMENT_RIGHT_SIDE) == true && IsScope(SQL_SCOPE_SELECT_STMT) == false))
			{
				TokenStr new_name(rec);
				new_name.Append(".", L".", 1);
				new_name.Append(token);
				Token::ChangeNoFormat(token, new_name);
			}
		}
		exists = true;
	}
	return exists;
}
bool SqlParser :: ConvertImplicitForRecordVariable ( Token * token ) { if ( token == NULL || _source != SQL_DB2 || _spl_implicit_record_fields . GetCount ( ) == 0 ) return false ; bool exists = false ; ListwmItem * i = Find ( _spl_implicit_record_fields , NULL , token ) ; if ( i != NULL && i -> value != NULL && i -> value2 != NULL ) { Token * rec = ( Token * ) i -> value ; if ( Token :: Compare ( token , rec , rec -> len ) == false ) { if ( IsScope ( SQL_SCOPE_INSERT_VALUES ) == true || ( IsScope ( SQL_SCOPE_ASSIGNMENT_RIGHT_SIDE ) == true && IsScope ( SQL_SCOPE_SELECT_STMT ) == false ) ) { TokenStr new_name ( rec ) ; new_name . Append ( " " , L" " , 1 ) ; new_name . Append ( token ) ; Token :: ChangeNoFormat ( token , new_name ) ; } } exists = true ; } return exists ; }
Check for implicit field reference (without record name)
Check for implicit field reference ( without record name )
// DB2 allows referencing implicit record fields without qualified name // Field found // Make sure name is not qualified // There can be conflicts with column names, check the current scope // Assignment but not SET var = (SELECT ...)