sqlparser/informix.cpp
// Check for pattern LET var = DBINFO('sqlca.sqlerrd1') that gets the last SERIAL value
Check for pattern LET var = DBINFO('sqlca.sqlerrd1') that gets the last SERIAL value
Check for pattern LET var = DBINFO ( ' sqlca . sqlerrd1 ' ) that gets the last SERIAL value
bool SqlParser::InformixPatternAssignLastSerial(Token *let)
{
	if(let == NULL || _target != SQL_ORACLE)
		return false;
	Token *var = GetNextToken();
	if(var == NULL)
		return false;
	Token *equal = GetNextCharToken('=', L'=');
	Token *dbinfo = GetNextWordToken(equal, "DBINFO", L"DBINFO", 6);
	if(dbinfo == NULL)
	{
		PushBack(var);
		return false;
	}
	Token *open = GetNextCharToken(dbinfo, '(', L'(');
	Token *sqlerrd1 = GetNextWordToken(open, "\"sqlca.sqlerrd1\"", L"\"sqlca.sqlerrd1\"", 16);
	if(sqlerrd1 == NULL)
		sqlerrd1 = GetNextWordToken(open, "'sqlca.sqlerrd1'", L"'sqlca.sqlerrd1'", 16);
	Token *close = GetNextCharToken(sqlerrd1, ')', L')');
	if(sqlerrd1 == NULL)
	{
		PushBack(var);
		return false;
	}
	if(_target == SQL_ORACLE)
	{
		Token::Change(let, "SELECT ", L"SELECT ", 7);
		AppendCopy(let, _spl_last_insert_table_name);
		AppendNoFormat(let, "_seq.currval ", L"_seq.currval ", 13);
		Append(let, "INTO", L"INTO", 4);
		Append(var, " FROM ", L" FROM ", 6, let);
		AppendNoFormat(var, "dual", L"dual", 4);
		Token::Remove(equal, close);
	}
	return true;
}
bool SqlParser :: InformixPatternAssignLastSerial ( Token * let ) { if ( let == NULL || _target != SQL_ORACLE ) return false ; Token * var = GetNextToken ( ) ; if ( var == NULL ) return false ; Token * equal = GetNextCharToken ( ' ' , L' ' ) ; Token * dbinfo = GetNextWordToken ( equal , " " , L" " , 6 ) ; if ( dbinfo == NULL ) { PushBack ( var ) ; return false ; } Token * open = GetNextCharToken ( dbinfo , ' ' , L' ' ) ; Token * sqlerrd1 = GetNextWordToken ( open , " \" \" " , L" \" \" " , 16 ) ; if ( sqlerrd1 == NULL ) sqlerrd1 = GetNextWordToken ( open , " " , L" " , 16 ) ; Token * close = GetNextCharToken ( sqlerrd1 , ' ' , L' ' ) ; if ( sqlerrd1 == NULL ) { PushBack ( var ) ; return false ; } if ( _target == SQL_ORACLE ) { Token :: Change ( let , " " , L" " , 7 ) ; AppendCopy ( let , _spl_last_insert_table_name ) ; AppendNoFormat ( let , " " , L" " , 13 ) ; Append ( let , " " , L" " , 4 ) ; Append ( var , " " , L" " , 6 , let ) ; AppendNoFormat ( var , " " , L" " , 4 ) ; Token :: Remove ( equal , close ) ; } return true ; }
Check for pattern LET var = DBINFO('sqlca.sqlerrd1') that gets the last SERIAL value
Check for pattern LET var = DBINFO ( ' sqlca . sqlerrd1 ' ) that gets the last SERIAL value
// Variable name // Not DBINFO function // Check DBINFO property // Not DBINFO('sqlca.sqlerrd1') function // SELECT table_name_seq.CURRVAL INTO var FROM dual in Oracle // Use the sequence for the table from last INSERT statement