#include <Statement.h>
Inheritance diagram for CreateTblStatement:
Public Member Functions | |
DbRetVal | execute (int &rowsAffected) |
DbRetVal | resolve () |
CreateTblStatement () | |
~CreateTblStatement () | |
DbRetVal | execute (int &rowsAffected) |
DbRetVal | resolve () |
CreateTblStatement () | |
~CreateTblStatement () |
Definition at line 240 of file Statement.h.
CreateTblStatement::CreateTblStatement | ( | ) |
Definition at line 18 of file DdlStatement.cxx.
References Statement::dbMgr, and Statement::parsedData.
00019 { 00020 parsedData = NULL; 00021 dbMgr = NULL; 00022 }
CreateTblStatement::~CreateTblStatement | ( | ) |
Definition at line 24 of file DdlStatement.cxx.
References TableDef::reset().
00025 { 00026 tblDef.reset(); 00027 }
Here is the call graph for this function:
CreateTblStatement::CreateTblStatement | ( | ) |
CreateTblStatement::~CreateTblStatement | ( | ) |
DbRetVal CreateTblStatement::execute | ( | int & | rowsAffected | ) | [virtual] |
Implements DdlStatement.
DbRetVal CreateTblStatement::execute | ( | int & | rowsAffected | ) | [virtual] |
Implements DdlStatement.
Definition at line 28 of file DdlStatement.cxx.
References DatabaseManager::createIndex(), DatabaseManager::createTable(), Statement::dbMgr, FieldName::fldName, ParsedData::getFieldNameList(), List::getIterator(), ListIterator::hasElement(), hashIndex, IDENTIFIER_LENGTH, ListIterator::nextElement(), OK, Statement::parsedData, and List::size().
00029 { 00030 DbRetVal rv = OK; 00031 rv = dbMgr->createTable(tblName, tblDef); 00032 if (rv != OK) return rv; 00033 if (parsedData->getFieldNameList().size() > 0) 00034 { 00035 HashIndexInitInfo *idxInfo = new HashIndexInitInfo(); 00036 strcpy(idxInfo->tableName, tblName); 00037 ListIterator iter = parsedData->getFieldNameList().getIterator(); 00038 FieldName *name = NULL; 00039 while (iter.hasElement()) 00040 { 00041 name = (FieldName*)iter.nextElement(); 00042 idxInfo->list.append(name->fldName); 00043 } 00044 idxInfo->indType = hashIndex; 00045 idxInfo->isPrimary = true; 00046 idxInfo->isUnique = true; 00047 00048 char indName[IDENTIFIER_LENGTH]; 00049 sprintf(indName, "%s_idx1_Primary", tblName); 00050 rv = dbMgr->createIndex(indName, idxInfo); 00051 delete idxInfo; 00052 } 00053 return rv; 00054 }
Here is the call graph for this function:
DbRetVal CreateTblStatement::resolve | ( | ) | [virtual] |
Implements DdlStatement.
DbRetVal CreateTblStatement::resolve | ( | ) | [virtual] |
Implements DdlStatement.
Definition at line 56 of file DdlStatement.cxx.
References TableDef::addField(), FieldDef::defaultValueBuf_, ErrUnknown, FieldName::fldName, FieldDef::fldName_, ParsedData::getCreFldList(), ParsedData::getFieldNameList(), List::getIterator(), FieldList::getIterator(), ParsedData::getTableName(), ListIterator::hasElement(), FieldDef::isDefault_, FieldDef::isNull_, FieldDef::length_, ListIterator::nextElement(), OK, Statement::parsedData, printError, ListIterator::reset(), and FieldDef::type_.
00057 { 00058 DbRetVal rv = OK; 00059 strcpy(tblName, parsedData->getTableName()); 00060 FieldIterator iter = parsedData->getCreFldList().getIterator(); 00061 FieldDef fDef; 00062 00063 int i = 0; 00064 FieldName *name = NULL; 00065 ListIterator nIter = parsedData->getFieldNameList().getIterator(); 00066 while (iter.hasElement()) 00067 { 00068 fDef = iter.nextElement(); 00069 nIter.reset(); 00070 while (nIter.hasElement()) 00071 { 00072 name = (FieldName*)nIter.nextElement(); 00073 if (strcmp(name->fldName, fDef.fldName_) == 0) fDef.isNull_ = true; 00074 } 00075 00076 00077 //TODO : need a new addField function which can take FieldDef as parameter. 00078 if (!fDef.isDefault_) { 00079 i = tblDef.addField(fDef.fldName_, fDef.type_, fDef.length_, 00080 NULL,fDef.isNull_); 00081 } else { 00082 i = tblDef.addField(fDef.fldName_, fDef.type_, fDef.length_, 00083 fDef.defaultValueBuf_,fDef.isNull_); 00084 } 00085 if( 0 != i ) 00086 { 00087 printError(ErrUnknown, "Error while adding field"); 00088 rv = ErrUnknown; 00089 break; 00090 } 00091 } 00092 return rv; 00093 }
Here is the call graph for this function: