/** @file WritingFactory.cpp @author Brian Magill @datecreated 3/07/2007 $Date:$ $Revision:$ @copyright (©) Copyright 2006 by GATS Inc. 11864 Canon Blvd., Suite 101, Newport News, VA 23606 All Rights Reserved. No part of this software or publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise without the prior written permission of GATS Inc. @brief given a table with metadata including table names, returns a list of tables */ //---------------------------------------------------------------------- // #include #include #include "GATS_DB.h" #include "GATS_DB_Exception.h" #include "GATS_Utilities.hpp" #include "WritingFactory.h" using namespace std; using namespace gatsDBpp; ModifyGeneric WritingFactory::operator()(std::string tableName) const { vector fieldNames; unsigned long i; string strErr; try { GATS_DB_Results results; string strQuery = string("SELECT B.Col_number, B.Col_name FROM ") + metaSummary + string(" A, ") + tableStructure + " B " + " WHERE A.TableType = B.TableType " + " AND A.TableName = '" + tableName +"' ORDER BY Col_number"; results = dbConn->Query(strQuery.c_str()); if (results.size() == 0 ) { strErr = string("Table ") + tableName + string(" not found."); throw runtime_error(strErr); } else { for( i = 0; i < results.size(); i++) fieldNames.push_back(results[i][1].asString()); } } catch (exception &ex) { strErr = string("WritingFactory::operator() Error: ") + ex.what(); throw runtime_error(strErr); } return ModifyGeneric(dbConn, tableName, fieldNames); }