sl@0: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // TSqlParser2 class. "DBMS Security" related - full support. sl@0: // sl@0: // sl@0: sl@0: #include "UQ_STD.H" sl@0: sl@0: /** sl@0: This method is used to extract the table name from a particular sql sl@0: string - aTableName parameter. Also, the function determines the sql string type - sl@0: Sql::EDDL, Sql::EDML or Sql::ENone (SELECT sql string). sl@0: */ sl@0: void TSqlParser2::ParseL(const TDesC& aSql) sl@0: { sl@0: TSqlParser sqlParser(aSql); sl@0: iStatementType = sqlParser.Type(); sl@0: iTableName.Set(NULL, 0); sl@0: switch(iStatementType) sl@0: { sl@0: case Sql::ENone: sl@0: //It may be a "SELECT" statement. Check the sql and get the table name. sl@0: if(sqlParser.ParseL(ESqlKeyword_select) == ESqlAsterisk) sl@0: { sl@0: sqlParser.NextToken(); sl@0: } sl@0: else sl@0: { sl@0: for(;;) sl@0: { sl@0: TSqlTokenType t = sqlParser.NextToken(); sl@0: if(t != ESqlComma) sl@0: break; sl@0: sqlParser.NextToken(); sl@0: } sl@0: } sl@0: sqlParser.ParseL(ESqlKeyword_from); sl@0: sqlParser.IdentifierL(iTableName); sl@0: break; sl@0: case Sql::EDDL: sl@0: //CREATE/DROP/ALTER statement. There is a table name, but we do not need it. sl@0: //The caller has to have "SCHEMA" access level, so we do not bother with the table name. sl@0: break; sl@0: case Sql::EDML: sl@0: //INSERT/UPDATE/DELETE statement. Get the table name. sl@0: if(sqlParser.Parse(ESqlKeyword_insert)) sl@0: { sl@0: sqlParser.ParseL(ESqlKeyword_into); sl@0: } sl@0: else if(sqlParser.Parse(ESqlKeyword_update)) sl@0: { sl@0: } sl@0: else sl@0: { sl@0: sqlParser.ParseL(ESqlKeyword_delete); sl@0: sqlParser.ParseL(ESqlKeyword_from); sl@0: } sl@0: sqlParser.IdentifierL(iTableName); sl@0: break; sl@0: default: sl@0: __ASSERT(EFalse); sl@0: break; sl@0: } sl@0: }