os/persistentdata/persistentstorage/dbms/usql/UQ_DDL.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/dbms/usql/UQ_DDL.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,85 @@
     1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// SQL DDL statements
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "UQ_STD.H"
    1.22 +
    1.23 +// Class CSqlCreateTableStatement
    1.24 +
    1.25 +CDbIncremental* CSqlCreateTableStatement::ExecuteL(CDbDatabase& aDatabase,TDbTextComparison,TInt& aStep)
    1.26 +	{
    1.27 +	aDatabase.CreateTableL(iName,iColumns,0);
    1.28 +	aStep=0;
    1.29 +	return 0;
    1.30 +	}
    1.31 +
    1.32 +// Class CSqlDropTableStatement
    1.33 +
    1.34 +CDbIncremental* CSqlDropTableStatement::ExecuteL(CDbDatabase& aDatabase,TDbTextComparison,TInt& aStep)
    1.35 +	{
    1.36 +	return aDatabase.DropTableL(iName,aStep);
    1.37 +	}
    1.38 +
    1.39 +// Class CSqlAlterTableStatement
    1.40 +
    1.41 +CSqlAlterTableStatement::~CSqlAlterTableStatement()
    1.42 +	{
    1.43 +	iDrop.Close();
    1.44 +	}
    1.45 +
    1.46 +CDbIncremental* CSqlAlterTableStatement::ExecuteL(CDbDatabase& aDatabase,TDbTextComparison,TInt& aStep)
    1.47 +	{
    1.48 +	CDbColSet* set=CDbColSet::NewLC();
    1.49 +	aDatabase.ColumnsL(*set,iName);
    1.50 +	TInt todrop=iDrop.Count();
    1.51 +	for (TDbColSetIter iter(*set);iter;++iter)
    1.52 +		{
    1.53 +		TInt ii=-1;
    1.54 +		for (;;)
    1.55 +			{
    1.56 +			if (++ii==todrop)
    1.57 +				{
    1.58 +				iAdd.AddL(*iter);
    1.59 +				break;
    1.60 +				}
    1.61 +			if (iter->iName.CompareF(iDrop[ii])==0)
    1.62 +				{
    1.63 +				iDrop.Remove(ii);
    1.64 +				--todrop;
    1.65 +				break;
    1.66 +				}
    1.67 +			}
    1.68 +		}
    1.69 +	if (todrop!=0)
    1.70 +		__LEAVE(KErrNotFound);
    1.71 +	CleanupStack::PopAndDestroy();	// set
    1.72 +	return aDatabase.AlterTableL(iName,iAdd,aStep);
    1.73 +	}
    1.74 +
    1.75 +// Class CSqlCreateIndexStatement
    1.76 +
    1.77 +CDbIncremental* CSqlCreateIndexStatement::ExecuteL(CDbDatabase& aDatabase,TDbTextComparison aComparison,TInt& aStep)
    1.78 +	{
    1.79 +	iKey.SetComparison(aComparison);
    1.80 +	return aDatabase.CreateIndexL(iName,iTable,iKey,aStep);
    1.81 +	}
    1.82 +
    1.83 +// Class CSqlDropIndexStatement
    1.84 +
    1.85 +CDbIncremental* CSqlDropIndexStatement::ExecuteL(CDbDatabase& aDatabase,TDbTextComparison,TInt& aStep)
    1.86 +	{
    1.87 +	return aDatabase.DropIndexL(iName,iTable,aStep);
    1.88 +	}