summaryrefslogtreecommitdiff
path: root/src/utils/xb_dbfutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/xb_dbfutil.cpp')
-rwxr-xr-xsrc/utils/xb_dbfutil.cpp75
1 files changed, 50 insertions, 25 deletions
diff --git a/src/utils/xb_dbfutil.cpp b/src/utils/xb_dbfutil.cpp
index e50495e..76988c0 100755
--- a/src/utils/xb_dbfutil.cpp
+++ b/src/utils/xb_dbfutil.cpp
@@ -90,6 +90,7 @@ class xbUtil{
void UpdateTableAutoCommit();
void DisplayTableInfo();
void RenameTable();
+ void DeleteTable();
// 4 - RecordMenu options
void GetRecord();
@@ -776,7 +777,7 @@ void xbUtil::LockRecord(){
std::cin.getline( cBuf, 15 );
//iRc = dActiveTable->LockRecord( XB_LOCK, atol( cBuf ));
iRc = dActiveTable->LockRecord( XB_LOCK, strtoul( cBuf, NULL, 0 ));
-
+
x->DisplayError( iRc );
}
@@ -1453,6 +1454,24 @@ void xbUtil::DisplayTableInfo(){
}
/*************************************************************************************/
+void xbUtil::DeleteTable(){
+
+ if( !dActiveTable )
+ dActiveTable = GetTablePtr( " - select table" );
+
+ if( !dActiveTable ){
+ std::cout << "No table selected" << std::endl;
+ return;
+ }
+
+ dActiveTable->DeleteTable();
+ dActiveTable = NULL;
+ std::cout << "Table deleted.\n";
+
+}
+
+
+/*************************************************************************************/
void xbUtil::RenameTable(){
if( !dActiveTable )
@@ -1510,26 +1529,29 @@ void xbUtil::DisplayActiveTable() const{
if( dActiveTable ){
std::cout << "Active Table = [" << dActiveTable->GetTblAlias().Str() << "] ";
xbUInt32 ulRecCnt = 0;
- dActiveTable->ReadHeader( 0, 1 );
- dActiveTable->GetRecordCnt( ulRecCnt );
- std::cout << "Total Records = [" << ulRecCnt << "] ";
- std::cout << "Current Record = [" << dActiveTable->GetCurRecNo() << "] ";
-
- if( dActiveTable->GetAutoCommit())
- std::cout << " Auto Commit = [Enabled]";
- else
- std::cout << " Auto Commit = [Disabled]";
+ xbInt16 iRc;
+ if(( iRc = dActiveTable->GetRecordCnt( ulRecCnt )) == XB_NO_ERROR ){
+ std::cout << "Total Records = [" << ulRecCnt << "] ";
+ std::cout << "Current Record = [" << dActiveTable->GetCurRecNo() << "] ";
- std::cout << std::endl;
- #ifdef XB_INDEX_SUPPORT
- xbIx *pIx = dActiveTable->GetCurIx();
- if( pIx ){
- void *vpTag = dActiveTable->GetCurTag();
- std::cout << "Active Tag = [" << pIx->GetTagName( vpTag ).Str() << "] Type = [" << dActiveTable->GetCurIxType().Str() <<
+ if( dActiveTable->GetAutoCommit())
+ std::cout << " Auto Commit = [Enabled]";
+ else
+ std::cout << " Auto Commit = [Disabled]";
+
+ std::cout << std::endl;
+ #ifdef XB_INDEX_SUPPORT
+ xbIx *pIx = dActiveTable->GetCurIx();
+ if( pIx ){
+ void *vpTag = dActiveTable->GetCurTag();
+ std::cout << "Active Tag = [" << pIx->GetTagName( vpTag ).Str() << "] Type = [" << dActiveTable->GetCurIxType().Str() <<
"] \tFile Name = [" << pIx->GetFileName().Str() << "] Key = [" << pIx->GetKeyExpression( vpTag ).Str() << "]" << std::endl;
+ }
+ #endif // XB_INDEX_SUPPORT
+ std::cout << std::endl;
+ } else {
+ x->DisplayError( iRc );
}
- #endif // XB_INDEX_SUPPORT
- std::cout << std::endl;
}
}
/*************************************************************************************/
@@ -1716,7 +1738,7 @@ void xbUtil::DisplayTableStats(){
iOptionNo = 1;
}
if( iOptionNo < 5 ) {
- d->ReadHeader( xbTrue, 0 );
+ // d->ReadHeader( xbTrue, 0 ); moved to DumpHeader routine
d->DumpHeader( iOptionNo );
} else {
// DBMS settings
@@ -2192,6 +2214,8 @@ void xbUtil::ProcessOption( const xbString &sOption ){
DisplayTableInfo();
else if( sOption == "=3.15" )
RenameTable();
+ else if( sOption == "=3.16" )
+ DeleteTable();
else if( sOption == "=4" )
RecordMenu();
else if( sOption == "=4.1" )
@@ -2824,7 +2848,7 @@ void xbUtil::FileMenu()
std::cout << "13 - Update Table Auto Commit Setting" << std::endl;
std::cout << "14 - Display Table Info" << std::endl;
std::cout << "15 - Rename Table" << std::endl;
-
+ std::cout << "16 - Delete Table" << std::endl;
std::cout << "99 - Exit Menu" << std::endl;
option = GetOption();
@@ -2833,7 +2857,7 @@ void xbUtil::FileMenu()
case 0: break;
case 1: ListFilesInDataDirectory(); break;
case 2: UpdateDataDirectory(); break;
- case 3: x->DisplayTableList(); break;
+ case 3: x->DisplayTableList(); break;
case 4: Open(); break;
case 5: Close(); break;
case 6: CloseAllTables(); break;
@@ -2845,13 +2869,13 @@ void xbUtil::FileMenu()
case 13: UpdateTableAutoCommit(); break;
case 14: DisplayTableInfo(); break;
case 15: RenameTable(); break;
+ case 16: DeleteTable(); break;
case 99: break;
default: std::cout << "Invalid Option" << std::endl;
}
}
}
-
/************************************************************************/
#ifdef XB_NDXINF_SUPPORT
void xbUtil::InfFileMenu()
@@ -3391,7 +3415,7 @@ void xbUtil::FindKey(){
default:
std::cout << "Unknown key type [" << cKeyType << "]" << std::endl;
return;
- break;
+ // break;
}
char cBuf[128];
@@ -3457,8 +3481,9 @@ void xbUtil::Reindex(){
std::cout << "Tag not selected" << std::endl;
return;
}
- void *vpCurTag = dActiveTable->GetCurTag();
- xbInt16 iRc = pIx->Reindex( &vpCurTag );
+ //void *vpCurTag = dActiveTable->GetCurTag();
+ //xbInt16 iRc = pIx->Reindex( &vpCurTag );
+ xbInt16 iRc = dActiveTable->Reindex( 0 );
x->DisplayError( iRc );
}