This program should read the SQL Statement Create and Insert Statements. Once statements are validated what the user keys in from the insert should be written in a newly created file (.txt). I would like some assistance cause this is a pretty tough assignment. Does anyone know how to do this assignment ?
1) OPEN file.
Syntax: Open "mydatabase.db"
Your program should be able to detect whether the file exists or not. If not, prompt "This is a new file". Otherwise, prompt "Database is opened" and display the structure of the database.
will create a table with three fields. All the fields for this assignments are character fields. These table name, field information should be stored at the beginning of the file. It should be stored in a way that you can easily read the information when you open the file. The table will be automatically saved.
3) INSERT
Another command you need to implement in this assignment is INSERT, which add data to the table. For example,
INSERT INTO faculty (firstname, lastname, id) VALUES ('John', 'Smith', '393948394');
All the data are automatically saved to the database file.
if(count > 1)
{
cout << "Error: too many table names between FROM keyword and the end of the query. Only one table name authorized." << endl;
return error++;
}
else
return error;
}
int checkcomafields(string query, int& error, int position1, int positionF)
{
string fields;
fields = query.substr(position1, (positionF-position1));
int i;
for(i=position1+1; i<positionF-1; i++)
{
if(query[i] == ' ')
{
if(query[i-1] != ',')
{
cout << "Error: missing coma between field names." << endl;
error++;
}
}
}