os/persistentdata/persistentstorage/dbms/pcdbms/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/pcdbms/usql/UQ_DDL.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,91 @@
     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 +#include "D32Assert.h"
    1.23 +
    1.24 +// Class CSqlCreateTableStatement
    1.25 +
    1.26 +CDbIncremental* CSqlCreateTableStatement::ExecuteL(CDbDatabase& aDatabase,TDbTextComparison,TInt& aStep)
    1.27 +	{
    1.28 +	aDatabase.CreateTableL(iName,iColumns,0);
    1.29 +	aStep=0;
    1.30 +	return 0;
    1.31 +	}
    1.32 +
    1.33 +// Class CSqlDropTableStatement
    1.34 +
    1.35 +CDbIncremental* CSqlDropTableStatement::ExecuteL(CDbDatabase& aDatabase,TDbTextComparison,TInt& aStep)
    1.36 +	{
    1.37 +	return aDatabase.DropTableL(iName,aStep);
    1.38 +	}
    1.39 +
    1.40 +// Class CSqlAlterTableStatement
    1.41 +
    1.42 +CSqlAlterTableStatement::~CSqlAlterTableStatement()
    1.43 +	{
    1.44 +	iDrop.Close();
    1.45 +	}
    1.46 +
    1.47 +CDbIncremental* CSqlAlterTableStatement::ExecuteL(CDbDatabase& aDatabase,TDbTextComparison,TInt& aStep)
    1.48 +	{
    1.49 +	CDbColSet* set=CDbColSet::NewLC();
    1.50 +	aDatabase.ColumnsL(*set,iName);
    1.51 +	TInt todrop=iDrop.Count();
    1.52 +	for (TDbColSetIter iter(*set);iter;++iter)
    1.53 +		{
    1.54 +		TInt ii=-1;
    1.55 +		for (;;)
    1.56 +			{
    1.57 +			if (++ii==todrop)
    1.58 +				{
    1.59 +				iAdd.AddL(*iter);
    1.60 +				break;
    1.61 +				}
    1.62 +			if (iter->iName.CompareF(iDrop[ii])==0)
    1.63 +				{
    1.64 +				iDrop.Remove(ii);
    1.65 +				--todrop;
    1.66 +				break;
    1.67 +				}
    1.68 +			}
    1.69 +		}
    1.70 +	if (todrop!=0)
    1.71 +		__LEAVE(KErrNotFound);
    1.72 +	CleanupStack::PopAndDestroy();	// set
    1.73 +	return aDatabase.AlterTableL(iName,iAdd,aStep);
    1.74 +	}
    1.75 +
    1.76 +// Class CSqlCreateIndexStatement
    1.77 +
    1.78 +CDbIncremental* CSqlCreateIndexStatement::ExecuteL(CDbDatabase& aDatabase,TDbTextComparison aComparison,TInt& aStep)
    1.79 +	{
    1.80 +	// comparison can now be set from SQL, use aComparison only if existing comparison mode is 
    1.81 +	// EDbCompareNormal
    1.82 +	if ( iKey.Comparison() == EDbCompareNormal && aComparison != EDbCompareNormal )
    1.83 +		{
    1.84 +		iKey.SetComparison(aComparison);
    1.85 +		}
    1.86 +	return aDatabase.CreateIndexL(iName,iTable,iKey,aStep);
    1.87 +	}
    1.88 +
    1.89 +// Class CSqlDropIndexStatement
    1.90 +
    1.91 +CDbIncremental* CSqlDropIndexStatement::ExecuteL(CDbDatabase& aDatabase,TDbTextComparison,TInt& aStep)
    1.92 +	{
    1.93 +	return aDatabase.DropIndexL(iName,iTable,aStep);
    1.94 +	}