src/PreparedStatement.h
author František Kučera <franta-hg@frantovo.cz>
Mon, 26 Oct 2020 00:00:35 +0100
branchv_0
changeset 53 cc6ffeba0fe5
parent 36 91cb012d779a
permissions -rw-r--r--
fix: support bigger numbers, SQL_BIGINT there was an overflow and some values resulted into negative ones. TODO: there is still a problem with big negative numbers – this needs to be addressed in relpipe-lib-writer/relpipe-lib-reader

/**
 * Relational pipes
 * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
#pragma once

#include <list>
#include <string>
#include <utility>

#include <relpipe/reader/typedefs.h>
#include <relpipe/reader/TypeId.h>
#include <relpipe/writer/TypeId.h>
#include "SqlException.h"
#include "ResultSet.h"

namespace relpipe {
namespace tr {
namespace sql {

class PreparedStatement {
private:
	void* statement;
	std::wstring_convert<std::codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings
	std::list<relpipe::reader::boolean_t> booleanParameters;
	std::list<std::string> integerParameters;
	std::list<std::pair<std::string, long>> stringParameters;
public:
	PreparedStatement(void* stmt);
	virtual ~PreparedStatement();
	ResultSet* executeQuery();
	long executeUpdate();
	void reset();
	void setBoolean(int parameterNumber, relpipe::reader::boolean_t value);
	void setInteger(int parameterNumber, relpipe::reader::integer_t value);
	void setString(int parameterNumber, relpipe::reader::string_t value);
	void setNull(int parameterNumber);
};

}
}
}