sqlparser/statements.cpp
// CREATE TYPE in Oracle, SQL Server
CREATE TYPE in Oracle, SQL Server
CREATE TYPE in Oracle SQL Server
bool SqlParser::ParseCreateType(Token *create, Token *type)
{
	if(create == NULL || type == NULL)
		return false;
	STATS_DECL
    STMS_STATS_V("CREATE TYPE", create);
	Token *name = GetNextToken();
	if(name == NULL)
		return false;
	Token *from = GetNextWordToken("FROM", L"FROM", 4);
	Token *datatype = GetNextToken();
	ParseDataType(datatype);
	Token *type_end = GetLastToken();
	ParseColumnConstraints(create, name, name, datatype, type_end, NULL, NULL, NULL, NULL);
	Token *last = GetLastToken();
	_udt.Add(name, datatype, type_end);
	if(_source != SQL_ORACLE && _target == SQL_ORACLE)
	{
		Append(create, " OR REPLACE", L" OR REPLACE", 11);
		if(_source == SQL_SQL_SERVER)
		{
			Token::Change(from, "AS OBJECT (", L"AS OBJECT (", 11);
			AppendCopy(from, name);
			AppendNoFormat(last, ")", L")", 1);
		}
		Token *semi = GetNextCharToken(';', L';');
		Append(Nvl(semi, last), "\n/", L"\n/", 2);
	}
	return true;
}
bool SqlParser :: ParseCreateType ( Token * create , Token * type ) { if ( create == NULL || type == NULL ) return false ; STATS_DECL STMS_STATS_V ( " " , create ) ; Token * name = GetNextToken ( ) ; if ( name == NULL ) return false ; Token * from = GetNextWordToken ( " " , L" " , 4 ) ; Token * datatype = GetNextToken ( ) ; ParseDataType ( datatype ) ; Token * type_end = GetLastToken ( ) ; ParseColumnConstraints ( create , name , name , datatype , type_end , NULL , NULL , NULL , NULL ) ; Token * last = GetLastToken ( ) ; _udt . Add ( name , datatype , type_end ) ; if ( _source != SQL_ORACLE && _target == SQL_ORACLE ) { Append ( create , " " , L" " , 11 ) ; if ( _source == SQL_SQL_SERVER ) { Token :: Change ( from , " " , L" " , 11 ) ; AppendCopy ( from , name ) ; AppendNoFormat ( last , " " , L" " , 1 ) ; } Token * semi = GetNextCharToken ( ' ' , L' ' ) ; Append ( Nvl ( semi , last ) , " \n " , L" \n " , 2 ) ; } return true ; }
CREATE TYPE in Oracle, SQL Server
CREATE TYPE in Oracle SQL Server
// User-defined type name // FROM keyword in SQL Server // System data type // Optional constraint // CREATE TYPE name AS OBJECT (name type) in Oracle // In Oracle CREATE TYPE requires / for execution