craftleft.gif (3002 bytes)QuickTable
Home | API | Tutorial | Download | Support | Contact topblack.gif (108 bytes)


QuickTable User Cp  |  Register  |  Members  |  Search  |  Help
    |- QuickTable Discussion Forums > JDBC/Database Issues Post New Topic   Post A Reply
grouping printer friendly version
next newest post | next oldest post
Author Messages
cneah{@}attbi.com
Unregistered
Edit or delete this message Reply w/Quote
Posted Wednesday, December 31, 1969 @ 23:59:59  

I am not sure if this is my jdbc driver or quick table,but
when i do a group by i only get one record back. if i add
any other statment such as set nocount off or put a begin and an end, then i get all the records back but then quick table instead of doing what normally does(bring a little, then bring some more while scrolling) brings all the records which takes a long time.any idea what is going on?
cneah{@}attbi.com
Unregistered
Edit or delete this message Reply w/Quote
Posted Wednesday, December 31, 1969 @ 23:59:59  

I am not sure if this is my jdbc driver or quick table,but
when i do a group by i only get one record back. if i add
any other statment such as set nocount off or put a begin and an end, then i get all the records back but then quick table instead of doing what normally does(bring a little, then bring some more while scrolling) brings all the records which takes a long time.any idea what is going on?

Ben
I am using the quicktable jar for the application. i also
bought the code and i compile it to look into this problem
in the table mode i changed

protected void createRowCountSql()
{
if( dbTable.selectSql == null)
throw new RuntimeException("Select sql not set for dbtable");

String sql = dbTable.selectSql.toUpperCase();
sql = sql.trim();
if(sql.indexOf("SELECT") != -1 )
{
if(sql.indexOf("ORDER BY") != -1)
dbTable.rowCountSql = "SELECT COUNT(*) " + dbTable.selectSql.substring(sql.indexOf("FROM"),sql.indexOf("ORDER BY"));

else
dbTable.rowCountSql = "SELECT COUNT(*) " + dbTable.selectSql.substring(sql.indexOf("FROM"));
}
}


to


protected void createRowCountSql()
{
if( dbTable.selectSql == null)
throw new RuntimeException("Select sql not set for dbtable");

String sql = dbTable.selectSql.toUpperCase();
sql = sql.trim();
if(sql.indexOf("SELECT") != -1 )
{
if(sql.indexOf("ORDER BY") != -1)
dbTable.rowCountSql = "SELECT COUNT(*) " + dbTable.selectSql.substring(sql.indexOf("FROM"),sql.indexOf("ORDER BY"));
if(sql.indexOf("GROUP BY") != -1)
dbTable.rowCountSql = "SELECT COUNT(*) " + dbTable.selectSql.substring(sql.indexOf("FROM"),sql.indexOf("GROUP BY"));

else
dbTable.rowCountSql = "SELECT COUNT(*) " + dbTable.selectSql.substring(sql.indexOf("FROM"));
}
}


obviously the count will be wrong. but now i get the
all the grouped by records (plus all the extra all null records)

cneah{@}attbi.com
Unregistered
Edit or delete this message Reply w/Quote
Posted Wednesday, December 31, 1969 @ 23:59:59  

I am not sure if this is my jdbc driver or quick table,but
when i do a group by i only get one record back. if i add
any other statment such as set nocount off or put a begin and an end, then i get all the records back but then quick table instead of doing what normally does(bring a little, then bring some more while scrolling) brings all the records which takes a long time.any idea what is going on?

Ben
I am using the quicktable jar for the application. i also
bought the code and i compile it to look into this problem
in the table mode i changed

protected void createRowCountSql()
{
if( dbTable.selectSql == null)
throw new RuntimeException("Select sql not set for dbtable");

String sql = dbTable.selectSql.toUpperCase();
sql = sql.trim();
if(sql.indexOf("SELECT") != -1 )
{
if(sql.indexOf("ORDER BY") != -1)
dbTable.rowCountSql = "SELECT COUNT(*) " + dbTable.selectSql.substring(sql.indexOf("FROM"),sql.indexOf("ORDER BY"));

else
dbTable.rowCountSql = "SELECT COUNT(*) " + dbTable.selectSql.substring(sql.indexOf("FROM"));
}
}


to


protected void createRowCountSql()
{
if( dbTable.selectSql == null)
throw new RuntimeException("Select sql not set for dbtable");

String sql = dbTable.selectSql.toUpperCase();
sql = sql.trim();
if(sql.indexOf("SELECT") != -1 )
{
if(sql.indexOf("ORDER BY") != -1)
dbTable.rowCountSql = "SELECT COUNT(*) " + dbTable.selectSql.substring(sql.indexOf("FROM"),sql.indexOf("ORDER BY"));
if(sql.indexOf("GROUP BY") != -1)
dbTable.rowCountSql = "SELECT COUNT(*) " + dbTable.selectSql.substring(sql.indexOf("FROM"),sql.indexOf("GROUP BY"));

else
dbTable.rowCountSql = "SELECT COUNT(*) " + dbTable.selectSql.substring(sql.indexOf("FROM"));
}
}


obviously the count will be wrong. but now i get the
all the grouped by records (plus all the extra all null records)



Ben:
fyi
i changed it to

protected void createRowCountSql()
{
if( dbTable.selectSql == null)
throw new RuntimeException("Select sql not set for dbtable");

String sql = dbTable.selectSql.toUpperCase();
sql = sql.trim();
if(sql.indexOf("SELECT") != -1 )
{
if(sql.indexOf("ORDER BY") != -1)
dbTable.rowCountSql = "SELECT COUNT(*) " + dbTable.selectSql.substring(sql.indexOf("FROM"),sql.indexOf("ORDER BY"));
if(sql.indexOf("GROUP BY") != -1)
dbTable.rowCountSql = "SELECT COUNT(*) " + dbTable.selectSql.substring(sql.indexOf("FROM"),sql.indexOf("GROUP BY"));

else
dbTable.rowCountSql = "SELECT DISTINCT " + dbTable.selectSql.substring(sql.indexOf("FROM"));
}
}


and now it works great on grouped by statements. this is a
great product

admin{@}quicktable.org
Unregistered
Edit or delete this message Reply w/Quote
Posted Wednesday, December 31, 1969 @ 23:59:59  

Thanks a lot, I will incorporate this change in quicktable. <p>I was on vaction, so I was not able to respond immediately.<p>Ben

In some cases quicktable cannot automatically create the rowcount sql properly. Group by statements is one of them. You can assign a rowcount sql using dbTable.setRowCountSql(), that should resolve this problem. Rowcountsqls are basically the sql which will return the number of rows for the assigned select sql/resultset/stored procedure.

Post New Topic   Post A Reply Jump to:
Contact Us | QuickTable - A Java DBGrid | Privacy Policy All times are GMT -5 Hours.
Welcome to QuickTable Forums, Guest!  
Login
Username :
Password :
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now!
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios