vlad230
13 years agoContributor
[TC8 + JScript + ADO] SQL statement not returning the proper values
Hi all,
I'm trying to do some SQL selects on a Oracle Database and I'm not getting the proper results.
The odd thing is that if I do a query within Oracle SQL Developer I get 2 results and when I try to do this with TC8 I get no results although the query string is the same.
I've tried to do this using 2 methods using TC8 and JScript:
This doesn't log any messages.
This fails at the RecSet.MoveFirst(); line (because the RecSet is empty I guess).
Also, I would like to mention that I did get result for other select queries, but it seems that querying something related to dates doesn't return anything.
Can anyone help?
Thanks.
I'm trying to do some SQL selects on a Oracle Database and I'm not getting the proper results.
The odd thing is that if I do a query within Oracle SQL Developer I get 2 results and when I try to do this with TC8 I get no results although the query string is the same.
I've tried to do this using 2 methods using TC8 and JScript:
function test1(){
var query = "SELECT promoname FROM database.promotion WHERE promoenddate = '08-09-01'";
var field = "promoname";
var Qry;
// Create a query
Qry = ADO.CreateADOQuery();
// Specify the connection string
Qry.ConnectionString = "Provider=OraOLEDB.Oracle;Data Source=localhost:1521;User Id=username;Password=pass;OLEDB.NET=True;";
// Specify the SQL expression
Qry.SQL = query;
// Execute the query
Qry.Open();
// Process results and insert data into the test log
Qry.First();
while (! Qry.EOF){
Log.Message(Qry.FieldByName(field).Value);
Qry.Next();
}
// Closes the query
Qry.Close();
}
This doesn't log any messages.
function test2(){
var query = "SELECT promoname FROM database.promotion WHERE promoenddate = '08-09-01'";
var field = "promoname";
var RecSet, Cmd, query;
//create output array
var output = new Array();
// Create a new object
Cmd = ADO.CreateADOCommand();
// Specify the connection string
Cmd.ConnectionString = "Provider=OraOLEDB.Oracle;Data Source=localhost:1521;User Id=username;Password=pass;OLEDB.NET=True;";
// Specify the command text (the SQL expression)
Cmd.CommandText = query;
// Specify the command type
Cmd.CommandType = cmdText;
//Execute command
RecSet = Cmd.Execute();
//Process result
RecSet.MoveFirst();
while (! RecSet.EOF){
Log.Message(RecSet.Fields(field).Value);
RecSet.MoveNext();
}
}
This fails at the RecSet.MoveFirst(); line (because the RecSet is empty I guess).
Also, I would like to mention that I did get result for other select queries, but it seems that querying something related to dates doesn't return anything.
Can anyone help?
Thanks.