I'm using dartOracle, and wanted to use many SQL statements together, but need to make sure the INSERT statement is executed only after getting the table created, I wrote the below code after reading this and this and this and this but it is not working.. any thought!
var resultset;
Future buildDB() {
var completer = new Completer();
print("Hello, from Future!");
return completer.future;
}
void createTables() {
Future result= buildDB();
connect(
"SYSTEM",
"password",
"(DESCRIPTION="
"(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))"
"(CONNECT_DATA=(SERVICE_NAME=XE)(SERVER=DEDICATED)))")
.then(
(oracleConnection) {
result
.then((_) => resultset = oracleConnection.select('''
CREATE TABLE vendors (
vendor_id NUMBER,
vCode NUMBER,
vName VARCHAR(255),
vEmail VARCHAR(255),
PRIMARY KEY (vendor_id))
'''))
.then((_) => resultset.next())
.then((_) => resultset = oracleConnection.select('''
INSERT INTO myVendors (vendor_id, vCode, vName,vEmail)
values (1,'code1','name1','email1')")
'''))
.then((_) => resultset.next())
.then((_) => resultset = oracleConnection.select('''
INSERT INTO myVendors (vendor_id, vCode, vName,vEmail)
values (2,'code2','name2','email2')")
'''))
.then((_) => resultset.next())
.then((_) => resultset = oracleConnection.select('''
INSERT INTO myVendors (vendor_id, vCode, vName,vEmail)
values (3,'code3','name3','email3')")
'''))
.then((_) => resultset.next())
.then((_) => print('tables created!'));
},
onError: (error) {
print("Failed to create tables, error found: $error");
});
}
once I execute the function, I get this:
Observatory listening on http://127.0.0.1:54590
Hello, vendor!
Hello, from Future!
Listening for GET and POST on http://127.0.0.1:8004
and nothing happen after that, I waited for 5 minutes, with no changes!