home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
dbutil.zip
/
EXECSQL.ZIP
/
EXECSQL.SQC
< prev
next >
Wrap
Text File
|
1993-10-26
|
1KB
|
53 lines
#include <istring.hpp>
#include <string.h>
#include <fstream.h>
EXEC SQL INCLUDE SQLCA;
EXEC SQL BEGIN DECLARE SECTION;
char DBName[20];
char SqlStr[1000];
EXEC SQL END DECLARE SECTION;
void ProcessSQL(char *); // prototype of process statement
void main(int nbr, char * argv[])
{
ifstream fin;
IString input;
char inString[256];
fin.open(argv[1],ios::in);
if(!fin) {
cout << "invalid input file";
return;
}
while (fin.eof() ==0){ // do till end of file
input = "";
while (!input.includes(";")) // do to end of statement
{
fin.getline(inString,255);
input = input + inString;
if (!fin.eof() == 0)
break;
}
input.translate(";"," ");
ProcessSQL(input);
} // end of while not eof
} // end of main
void ProcessSQL(char * s){
strset(SqlStr,0);
strcpy(SqlStr,s);
EXEC SQL EXECUTE IMMEDIATE :SqlStr;
if(sqlca.sqlcode < 0){
sqlaintp(SqlStr,255,60,&sqlca);
cout << SqlStr;
}
EXEC SQL COMMIT WORK;
}