Main Page   Namespace List   Class Hierarchy   Compound List   Header Files   Namespace Members   Compound Members  

odbc++/preparedstatement.h

This is the verbatim text of the preparedstatement.h include file.
/* 
   This file is part of libodbc++.
   
   Copyright (C) 1999-2000 Manush Dodunekov <manush@stendahls.net>
   
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
   
   This library 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
   Library General Public License for more details.
   
   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
*/


#ifndef __ODBCXX_PREPAREDSTATEMENT_H
#define __ODBCXX_PREPAREDSTATEMENT_H

#include <odbc++/setup.h>
#include <odbc++/types.h>
#include <odbc++/statement.h>

#if defined(ODBCXX_HAVE_ISO_CXXLIB)
# include <iosfwd>
#else
# include <iostream>
#endif

namespace odbc {

  class Rowset;

  class ODBCXX_EXPORT PreparedStatement : public Statement {
    friend class Connection;

  private:
    void _prepare();
    void _setupParams();

  protected:
    ODBCXX_STRING sql_;
    //here we store the parameters
    Rowset* rowset_;
    size_t numParams_;
    std::vector<int> directions_;
    int defaultDirection_;
    bool paramsBound_;
    
    PreparedStatement(Connection* con,
                      SQLHSTMT hstmt,
                      const ODBCXX_STRING& sql,
                      int resultSetType,
                      int resultSetConcurrency,
                      int defaultDirection =SQL_PARAM_INPUT);

    void _bindParams();
    void _unbindParams();

    void _checkParam(int idx,
                     int* allowed, int numAllowed,
                     int defPrec, int defScale);

  public:
    virtual ~PreparedStatement();
    
    void clearParameters();
    
    bool execute();

    ResultSet* executeQuery();

    int executeUpdate();
    
    void setDouble(int idx, double val);

    void setBoolean(int idx, bool val);

    void setByte(int idx, signed char val);


    void setBytes(int idx, const ODBCXX_BYTES& val);

    void setDate(int idx, const Date& val);

    void setFloat(int idx, float val);


    void setInt(int idx, int val);

    void setLong(int idx, Long val);

    void setShort(int idx, short val);

    void setString(int idx, const ODBCXX_STRING& val);

    void setTime(int idx, const Time& val);

    void setTimestamp(int idx, const Timestamp& val);

    void setAsciiStream(int idx, ODBCXX_STREAM* s, int len);

    void setBinaryStream(int idx, ODBCXX_STREAM* s, int len);

    
    void setNull(int idx, int sqlType);
  };


}; // namespace odbc

#endif // __ODBCXX_PREPAREDSTATEMENT_H

Go back to the freeodbc++ homepage