Reputation: 164
I want to get to the value I am finding using the COUNT command of DQL.Normally I enter the column name I want to access into the getInt() getString() method. What I'm supposed to do when there is no specific colomn name.
{
String query = "select count(*) as count from dm_user;";
return query;
}
Code to fetch the result
{
IDfCollection total = dql.execute(session, IDfQuery.DF_READ_QUERY);
while (total.next()){
cint = total.getInt("count");
}
Tomcat Result
DfException:: THREAD: http-8080-2; MSG: [DM_QUERY_E_SYNTAX]error: "A Parser Error (syntax error) has occurred in the vicinity of: select count(*) as count"; ERRORCODE: 100; NEXT: null
Upvotes: 0
Views: 2025
Reputation: 1199
While @Miki answered it already but I like to add one small thing here that below code should work too if you haven't specified any alias.
{
IDfCollection total = dql.execute(session, IDfQuery.DF_READ_QUERY);
while (total.next()){
cint = total.getInt("count(*)");
}
}
Upvotes: 2
Reputation: 2517
You are using count
which is a keyword for your column custom name, the error you posted clearly says it: A Parser Error (syntax error)
This will do
select count(*) as quantity from dm_user;
and fetching result like
IDfCollection total = dql.execute(session, IDfQuery.DF_READ_QUERY);
while (total.next()){
cint = total.getInt("quantity");
will work
Upvotes: 4