2
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; version 2 of the
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23
#include "table_inserts_loader_be.h"
24
#include "recordset_table_inserts_storage.h"
25
#include "recordset_be.h"
31
TableInsertsLoader::TableInsertsLoader(bec::GRTManager *grtm)
38
void TableInsertsLoader::process_table(db_TableRef table, const std::string &inserts_script) //!
40
if (!table.is_valid() || inserts_script.empty())
43
Recordset_sql_storage::Ref input_storage= Recordset_sql_storage::create(_grtm);
44
input_storage->sql_script(inserts_script);
45
input_storage->schema_name(table->owner()->name());
46
input_storage->table_name(table->name());
48
Sql_inserts_loader::Strings affective_columns;
49
affective_columns.reserve(table->columns().count());
50
GRTLIST_FOREACH (db_Column, table->columns(), col)
51
affective_columns.push_back((*col)->name());
52
input_storage->affective_columns(affective_columns);
55
Recordset::Ref rs= Recordset::create(_grtm);
56
rs->data_storage(input_storage);
59
Recordset_table_inserts_storage::Ref output_storage= Recordset_table_inserts_storage::create(_grtm);
60
output_storage->table(table);
61
// provoke creation of underlying table
63
Recordset::Ref rs= Recordset::create(_grtm);
64
output_storage->unserialize(rs);
66
output_storage->serialize(rs);