summaryrefslogtreecommitdiff
path: root/src/utils/xb_execsql.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/xb_execsql.cpp')
-rwxr-xr-xsrc/utils/xb_execsql.cpp95
1 files changed, 0 insertions, 95 deletions
diff --git a/src/utils/xb_execsql.cpp b/src/utils/xb_execsql.cpp
deleted file mode 100755
index daa6b6e..0000000
--- a/src/utils/xb_execsql.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/* xb_execsql.cpp
-
-XBase64 Software Library
-
-Copyright (c) 1997,2003,2014,2023 Gary A Kunkel
-
-The xb64 software library is covered under
-the terms of the GPL Version 3, 2007 license.
-
-Email Contact:
-
- xb64-devel@lists.sourceforge.net
- xb64-users@lists.sourceforge.net
-
-*/
-
-#include <xbase.h>
-
-using namespace xb;
-
-xbInt16 GetNextSqlCmd( xbFile &f, xbString &sCmd );
-xbInt16 GetNextSqlCmd( xbFile &f, xbString &sCmd )
-{
- sCmd = "";
- xbString sLine;
- xbInt16 iRc = XB_NO_ERROR;
- xbUInt32 lPos = 0;
- xbBool bDone = xbFalse;
- while( !bDone ){
- if(( iRc = f.xbFgets( 256, sLine )) != XB_NO_ERROR ){
- bDone = xbTrue;
- } else {
-
- // don't need CR/LF chars
- sLine.ZapChar( 0x0a );
- sLine.ZapChar( 0x0d );
-
- // if comment, zap out everything to the right of the hash
- lPos = sLine.Pos( '#' );
- if( lPos > 0 )
- sLine.Left( lPos - 1);
-
- if( sLine.Pos( ';' ) > 0 ){
- bDone = xbTrue;
- sLine.ZapChar( ';' );
- }
- }
- sCmd += sLine;
- }
- return iRc;
-}
-
-int main(int ac,char** av)
-{
-
- if (ac <= 1) {
- std::cout << "Usage: xb_execsql filename..." << std::endl;
- return 1;
- }
-
- xbXBase x;
- x.EnableMsgLogging();
- xbSql sql( &x );
- xbFile f( sql.GetXbasePtr() );
- xbInt16 iRc = XB_NO_ERROR;
- xbString sFileName;
- xbString sSqlLine;
-
- sFileName = av[1];
-
- if(( iRc = f.xbFopen( "r", sFileName, XB_SINGLE_USER )) != XB_NO_ERROR ){
- xbString sMsg;
- sMsg.Sprintf( "Error opening [%s]\n", sFileName.Str() );
- std::cout << sMsg.Str();
- sql.GetXbasePtr()->DisplayError( iRc );
- return 1;
- }
-
- while( iRc == XB_NO_ERROR ){
- iRc = GetNextSqlCmd( f, sSqlLine );
-
- if( iRc == XB_NO_ERROR ){
-
- sSqlLine.Trim();
- std::cout << "Processing line [" << sSqlLine.Str() << "]\n";
- iRc = sql.ExecuteNonQuery( sSqlLine );
- if( iRc != XB_NO_ERROR )
- x.DisplayError( iRc );
- }
- }
-
- f.xbFclose();
- return 0;
-}
-