home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
dbutil.zip
/
EXECSQL.ZIP
/
EXECSQL.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-26
|
2KB
|
82 lines
//
// processed by precompiler 10-26-93 07:08:57
//
#include <istring.hpp>
#include <string.h>
#include <fstream.h>
//### EXEC SQL INCLUDE SQLCA;
#include <sqlda.h> // sqlda structure
#include <sqlca.h> // sqlca structre
#include <sqlaprep.h> // api(s) for most calls
#include <sqlenv.h> // api(s) for start & stop db
sqlca sqlca;
typedef int Boolean;
#define false 0
#define true 1
Boolean _sqlfound = false;
Boolean _sqlerror = false;
Boolean _sqlwarn = false;
int _RC;
const unsigned char sqla_program_id[40] = {
0x6f,0x41,0x41,0x42,0x41,0x45,0x43,0x43,0x45,0x44,
0x20,0x20,0x20,0x20,0x20,0x20,0x65,0x78,0x65,0x63,
0x73,0x71,0x6c,0x20,0x63,0x41,0x36,0x49,0x48,0x61,
0x4b,0x4a,0x30,0x20,0x20,0x20,0x20,0x20,0x20,0x20};
//### 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;
sqlastrt(&sqla_program_id,NULL,&sqlca);
_RC = sqlasets(strlen( SqlStr),SqlStr,NULL);
sqlacall(23, 1, 0, 0,NULL);
sqlastop(NULL);
if(sqlca.sqlcode < 0){
sqlaintp(SqlStr,255,60,&sqlca);
cout << SqlStr;
}
//### EXEC SQL COMMIT WORK;
sqlastrt(&sqla_program_id,NULL,&sqlca);
sqlacall(21, 0, 0, 0,NULL);
sqlastop(NULL);
}