2000-09-18 15:18:56 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 10:16:16 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:16:16 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:16:16 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:16:16 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:16:16 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:16:16 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _CONNECTIVITY_FILE_OSTATEMENT_HXX_
|
|
|
|
#define _CONNECTIVITY_FILE_OSTATEMENT_HXX_
|
|
|
|
|
|
|
|
#include <com/sun/star/sdbc/XStatement.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XMultipleResults.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XBatchExecution.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XCloseable.hpp>
|
|
|
|
#include <com/sun/star/sdbc/SQLWarning.hpp>
|
|
|
|
#include <com/sun/star/util/XCancellable.hpp>
|
2000-10-11 09:10:28 +00:00
|
|
|
#include <comphelper/proparrhlp.hxx>
|
2004-10-22 07:45:19 +00:00
|
|
|
#include <cppuhelper/compbase3.hxx>
|
|
|
|
#include <cppuhelper/implbase2.hxx>
|
2000-10-11 09:10:28 +00:00
|
|
|
#include <comphelper/uno3.hxx>
|
2000-09-18 15:18:56 +00:00
|
|
|
#include "connectivity/CommonTools.hxx"
|
|
|
|
#include "file/FConnection.hxx"
|
2008-12-30 13:32:01 +00:00
|
|
|
#include "file/filedllapi.hxx"
|
2000-09-18 15:18:56 +00:00
|
|
|
#ifndef _LIST_
|
|
|
|
#include <list>
|
|
|
|
#endif
|
|
|
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
2000-10-05 07:23:48 +00:00
|
|
|
#include <comphelper/propertycontainer.hxx>
|
2000-09-18 15:18:56 +00:00
|
|
|
#include "file/fanalyzer.hxx"
|
2000-10-25 10:24:43 +00:00
|
|
|
#include <comphelper/broadcasthelper.hxx>
|
2006-06-20 01:01:37 +00:00
|
|
|
#include "TSortIndex.hxx"
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2001-08-24 05:19:41 +00:00
|
|
|
#define SQL_COLUMN_NOTFOUND STRING_NOTFOUND
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
namespace connectivity
|
|
|
|
{
|
|
|
|
namespace file
|
|
|
|
{
|
2000-09-29 14:05:41 +00:00
|
|
|
class OResultSet;
|
2001-08-24 05:19:41 +00:00
|
|
|
class OFileTable;
|
2004-10-22 07:45:19 +00:00
|
|
|
typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XWarningsSupplier,
|
2000-09-29 14:05:41 +00:00
|
|
|
::com::sun::star::util::XCancellable,
|
|
|
|
::com::sun::star::sdbc::XCloseable> OStatement_BASE;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
//**************************************************************
|
|
|
|
//************ Class: java.sql.Statement
|
|
|
|
//**************************************************************
|
2008-12-30 13:32:01 +00:00
|
|
|
class OOO_DLLPUBLIC_FILE OStatement_Base :
|
|
|
|
public comphelper::OBaseMutex,
|
2000-09-18 15:18:56 +00:00
|
|
|
public OStatement_BASE,
|
2000-10-05 07:23:48 +00:00
|
|
|
public ::comphelper::OPropertyContainer,
|
2000-10-11 09:10:28 +00:00
|
|
|
public ::comphelper::OPropertyArrayUsageHelper<OStatement_Base>
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
{
|
2001-04-06 13:04:04 +00:00
|
|
|
protected:
|
2001-08-24 05:19:41 +00:00
|
|
|
::std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 everytime
|
2001-12-03 11:11:40 +00:00
|
|
|
::std::vector<sal_Int32> m_aParameterIndexes; // maps the parameter index to column index
|
2001-08-24 05:19:41 +00:00
|
|
|
::std::vector<sal_Int32> m_aOrderbyColumnNumber;
|
2006-06-20 01:01:37 +00:00
|
|
|
::std::vector<TAscendingOrder> m_aOrderbyAscending;
|
2001-08-24 05:19:41 +00:00
|
|
|
|
2000-09-29 14:05:41 +00:00
|
|
|
::com::sun::star::sdbc::SQLWarning m_aLastWarning;
|
|
|
|
::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
|
2001-08-24 05:19:41 +00:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xDBMetaData;
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColNames; // table columns // for this Statement
|
2001-04-06 13:04:04 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
connectivity::OSQLParser m_aParser;
|
|
|
|
connectivity::OSQLParseTreeIterator m_aSQLIterator;
|
|
|
|
|
|
|
|
OConnection* m_pConnection;// The owning Connection object
|
|
|
|
connectivity::OSQLParseNode* m_pParseTree;
|
2001-08-24 05:19:41 +00:00
|
|
|
OSQLAnalyzer* m_pSQLAnalyzer; //the sql analyzer used by the resultset
|
|
|
|
|
2001-10-01 10:24:29 +00:00
|
|
|
::std::vector<sal_Int32>* m_pEvaluationKeySet;
|
|
|
|
|
2001-08-24 05:19:41 +00:00
|
|
|
OFileTable* m_pTable; // the current table
|
2003-09-04 07:28:19 +00:00
|
|
|
OValueRefRow m_aSelectRow;
|
|
|
|
OValueRefRow m_aRow;
|
|
|
|
OValueRefRow m_aEvaluateRow; // contains all values of a row
|
2001-12-03 11:11:40 +00:00
|
|
|
ORefAssignValues m_aAssignValues; // needed for insert,update and parameters
|
|
|
|
// to compare with the restrictions
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
::rtl::OUString m_aCursorName;
|
|
|
|
sal_Int32 m_nMaxFieldSize;
|
|
|
|
sal_Int32 m_nMaxRows;
|
|
|
|
sal_Int32 m_nQueryTimeOut;
|
|
|
|
sal_Int32 m_nFetchSize;
|
|
|
|
sal_Int32 m_nResultSetType;
|
|
|
|
sal_Int32 m_nFetchDirection;
|
|
|
|
sal_Int32 m_nResultSetConcurrency;
|
|
|
|
sal_Bool m_bEscapeProcessing;
|
2001-08-24 05:19:41 +00:00
|
|
|
|
2006-06-20 01:01:37 +00:00
|
|
|
::cppu::OBroadcastHelper& rBHelper;
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
protected:
|
2001-08-24 05:19:41 +00:00
|
|
|
// initialize the column index map (mapping select columns to table columns)
|
|
|
|
void createColumnMapping();
|
|
|
|
// searches the statement for sort criteria
|
|
|
|
void anylizeSQL();
|
2001-08-29 11:21:08 +00:00
|
|
|
void setOrderbyColumn( connectivity::OSQLParseNode* pColumnRef,
|
2001-08-24 05:19:41 +00:00
|
|
|
connectivity::OSQLParseNode* pAscendingDescending);
|
|
|
|
|
|
|
|
virtual void initializeResultSet(OResultSet* _pResult);
|
|
|
|
// create the analyzer
|
|
|
|
virtual OSQLAnalyzer* createAnalyzer();
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2000-09-29 14:05:41 +00:00
|
|
|
void reset () throw( ::com::sun::star::sdbc::SQLException);
|
|
|
|
void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException);
|
|
|
|
void setWarning (const ::com::sun::star::sdbc::SQLWarning &ex) throw( ::com::sun::star::sdbc::SQLException);
|
2000-09-18 15:18:56 +00:00
|
|
|
sal_Int32 getPrecision ( sal_Int32 sqlType);
|
|
|
|
|
|
|
|
void disposeResultSet();
|
2001-12-03 11:11:40 +00:00
|
|
|
void GetAssignValues();
|
|
|
|
void SetAssignValue(const String& aColumnName,
|
|
|
|
const String& aValue,
|
|
|
|
BOOL bSetNull = FALSE,
|
|
|
|
UINT32 nParameter=SQL_NO_PARAMETER);
|
|
|
|
void ParseAssignValues( const ::std::vector< String>& aColumnNameList,
|
|
|
|
connectivity::OSQLParseNode* pRow_Value_Constructor_Elem,xub_StrLen nIndex);
|
|
|
|
|
|
|
|
virtual void parseParamterElem(const String& _sColumnName,OSQLParseNode* pRow_Value_Constructor_Elem);
|
2000-09-29 14:05:41 +00:00
|
|
|
// factory method for resultset's
|
|
|
|
virtual OResultSet* createResultSet() = 0;
|
2000-09-18 15:18:56 +00:00
|
|
|
// OPropertyArrayUsageHelper
|
|
|
|
virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
|
|
|
|
// OPropertySetHelper
|
|
|
|
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
|
2001-05-23 13:05:55 +00:00
|
|
|
virtual ~OStatement_Base();
|
2000-09-18 15:18:56 +00:00
|
|
|
public:
|
|
|
|
connectivity::OSQLParseNode* getParseTree() const { return m_pParseTree;}
|
|
|
|
|
|
|
|
OStatement_Base(OConnection* _pConnection );
|
|
|
|
|
2001-02-05 11:26:42 +00:00
|
|
|
OConnection* getOwnConnection() const { return m_pConnection;}
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
|
2001-08-24 05:19:41 +00:00
|
|
|
|
|
|
|
virtual void construct(const ::rtl::OUString& sql) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// OComponentHelper
|
2001-04-30 08:59:56 +00:00
|
|
|
virtual void SAL_CALL disposing(void);
|
2000-09-18 15:18:56 +00:00
|
|
|
// XInterface
|
2000-09-29 14:05:41 +00:00
|
|
|
// virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException) = 0;
|
2001-10-17 15:36:33 +00:00
|
|
|
virtual void SAL_CALL acquire() throw();
|
2000-09-18 15:18:56 +00:00
|
|
|
// XInterface
|
2000-09-29 14:05:41 +00:00
|
|
|
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
|
2000-09-18 15:18:56 +00:00
|
|
|
//XTypeProvider
|
2000-09-29 14:05:41 +00:00
|
|
|
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// XPropertySet
|
2001-04-30 08:59:56 +00:00
|
|
|
virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
|
2000-09-18 15:18:56 +00:00
|
|
|
// XWarningsSupplier
|
2000-09-29 14:05:41 +00:00
|
|
|
virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
|
|
|
virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
2000-09-18 15:18:56 +00:00
|
|
|
// XCancellable
|
2000-09-29 14:05:41 +00:00
|
|
|
virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException);
|
2000-09-18 15:18:56 +00:00
|
|
|
// XCloseable
|
2000-09-29 14:05:41 +00:00
|
|
|
virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
|
2000-09-18 15:18:56 +00:00
|
|
|
};
|
|
|
|
|
2008-12-30 13:32:01 +00:00
|
|
|
class OOO_DLLPUBLIC_FILE OStatement_BASE2 :
|
|
|
|
public OStatement_Base,
|
2001-04-12 14:12:41 +00:00
|
|
|
public connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
{
|
2001-04-12 14:12:41 +00:00
|
|
|
friend class connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>;
|
2000-09-18 15:18:56 +00:00
|
|
|
public:
|
|
|
|
OStatement_BASE2(OConnection* _pConnection ) : OStatement_Base(_pConnection ),
|
2001-04-12 14:12:41 +00:00
|
|
|
connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this){}
|
2000-09-18 15:18:56 +00:00
|
|
|
// OComponentHelper
|
|
|
|
virtual void SAL_CALL disposing(void);
|
|
|
|
// XInterface
|
2001-10-17 15:36:33 +00:00
|
|
|
virtual void SAL_CALL release() throw();
|
2000-09-18 15:18:56 +00:00
|
|
|
};
|
|
|
|
|
2004-10-22 07:45:19 +00:00
|
|
|
typedef ::cppu::ImplHelper2< ::com::sun::star::sdbc::XStatement,::com::sun::star::lang::XServiceInfo > OStatement_XStatement;
|
2008-12-30 13:32:01 +00:00
|
|
|
class OOO_DLLPUBLIC_FILE OStatement :
|
|
|
|
public OStatement_BASE2,
|
2004-10-22 07:45:19 +00:00
|
|
|
public OStatement_XStatement
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2000-09-29 14:05:41 +00:00
|
|
|
protected:
|
|
|
|
// factory method for resultset's
|
|
|
|
virtual OResultSet* createResultSet();
|
2000-09-18 15:18:56 +00:00
|
|
|
public:
|
|
|
|
// ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
|
|
|
|
OStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection){}
|
|
|
|
DECLARE_SERVICE_INFO();
|
|
|
|
|
2001-04-30 08:59:56 +00:00
|
|
|
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
|
2001-10-17 15:36:33 +00:00
|
|
|
virtual void SAL_CALL acquire() throw();
|
|
|
|
virtual void SAL_CALL release() throw();
|
2004-10-22 07:45:19 +00:00
|
|
|
|
|
|
|
// XStatement
|
|
|
|
virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
|
|
|
|
virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
|
|
|
|
virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
|
|
|
|
virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
|
2000-09-18 15:18:56 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // _CONNECTIVITY_FILE_OSTATEMENT_HXX_
|
|
|
|
|