Open hasan3ysf opened 10 years ago
Hi Hasan,
In 0.0.8 I added access to fields by name(getStringByName, getIntByName,...)
test('Test getStringByName, getIntByName', () {
OracleResultset resultset =
connection.select("select empno, ename from emp where EMPNO='7369'");
resultset.next();
expect(resultset.getString(1), equals("7369"));
expect(resultset.getStringByName("EMPNO"), equals("7369"));
expect(resultset.getInt(1), equals(7369));
expect(resultset.getIntByName("EMPNO"), equals(7369));
expect(resultset.getString(2), equals("SMITH"));
expect(resultset.getStringByName("ENAME"), equals("SMITH"));
});
and access to number of columns via resultset.getMetadataVector().getSize():
test('Test getMetadataVector', () {
OracleResultset resultset =
connection.select("select empno, ename from emp");
OracleMetadataVector metadata =
resultset.getMetadataVector();
expect(metadata.getSize(), equals(2))
Regarding number of rows - I don't think it is possible to easily figure out number of rows in resultset. I think generally speaking you would want to do 'select count(*) from emp' and then take getInt(1) from result of that query to figure out how many rows are in emp table.
Please let me know if this helps.
Hi Alex, I run this code, and got the below error:
var resultset = oracleConnection.select("select * from ppl where firstname='Maha'");
while(resultset.next()) {
print(i++);
print("${resultset.getString(3)} ${resultset.getStringByName('firstname')}");
}
output:
0 Dart_IntegerToInt64 expects argument 'integer' to be non-null.
Hi Alex, I tried another code, and got a loonger error, I tried this code, and got the error below:
var resultset = oracleConnection.select("select firstname from ppl where firstname='Maha'");
while(resultset.next()) {
print(i++);
print("${resultset.getString(3)} ${resultset.getStringByName('firstname')}");
}
the output I got is: 0 Uncaught Error: ORA-32109: invalid column or parameter position
Stack Trace:
Unhandled exception: ORA-32109: invalid column or parameter position
Hi Hasan,
try putting column names in all captial letters:
print("${resultset.getString(3)} ${resultset.getStringByName('FIRSTNAME')}");
I believe Oracle convention is to uppercase all identifiers.
Hi Ales, the first one worked, the second one still give same error.
i,e, select *, worked when the field name had been capitalized
var resultset = oracleConnection.select("select * from ppl where firstname='Maha'");
while(resultset.next()) {
print(i++);
print("${resultset.getString(3)} ${resultset.getStringByName('FIRSTNAME')}");
}
but the second one, with select firstname ... did not work var resultset = oracleConnection.select("select FIRSTNAME from ppl where firstname='Maha'");
thanks
Hi Alex, Can you provide the output in the form of text, like: resultset.output = {"firstName":"Hasan","lastName":"Yousef"}
then we can get the use https://pub.dartlang.org/packages/json_object to extract the JSON data.
thanks
Hi Alex, for displaying the output of the select * statement, I forced to write "print("${resultset.getInt(i)} for all the parameters I've, i.e. ${resultset.getString(1)} ${resultset.getString(2)} ${resultset.getString(3)} ... a shown in the attached.
I'm looking for the following:
thanks, Hasan