Thanks for this.
I had a few problems using DBD::ODBC and MS SQL Server.
With a table of 1000 rows:
What I found is the data grid displayed the first 70 rows repeatedly as you scrolled. I tracked this down to the SQL being run and then found SQL::Abstract::Limit says $order must be specified when $rows is specified. DBIx::LiveGrid only sets $order if you click on a column heading. I verified this with SQL::Abstract::Limit which produces the following incorrect SQL when $order is not specified:
SELECT * FROM
(
SELECT TOP 10 * FROM
(
SELECT TOP 30 f1, f2 FROM bench_char
) AS foo
) AS bar
and the following correct SQL when $order is specified:
SELECT * FROM
(
SELECT TOP 10 * FROM
(
SELECT TOP 30 f1, f2 FROM bench_char ORDER BY f1 ASC
) AS foo
ORDER BY f1 DESC
) AS bar
ORDER BY f1 ASC
I did a rough change to DBIx::LiveGrid to work around this:
sub query_database {
my($self,$dbh,$table_name,$fields,$where,$order)=@_;
my $rows = $self->get('ajax_page_size');
my $offset = $self->get('ajax_offset');
my $sort_dir = $self->get('ajax_sort_dir');
my $sort_col = $self->get('ajax_sort_col');
$sort_col = $self->clean_param('sort_col',$sort_col);
my @porder = ();
if ($sort_col) {
@porder = ("$sort_col $sort_dir");
$order = \@porder;
}
require SQL::Abstract::Limit;
my $abstract = SQL::Abstract::Limit->new( limit_dialect => $dbh );
my( $stmt, @bind ) = $abstract->select( $table_name
, $fields
, $where
, $order
, $rows
, $offset
);
and then changed livegrid.cgi:
my $dbh = DBI->connect("dbi:ODBC:test", "Martin_Evans", "easyso
+ft", {RaiseError=>1,PrintError=>0});
my $table_name = "bench_char";
my @fields = qw/f1 f2/;
my @order = qw/f1/;
DBIx::LiveGrid->run( undef, $dbh, $table_name, \@fields, undef, \@orde
+r );
I hope this helps.
BTW, I think there is a bug in IE 6.0.2800.1106 which means the row data is not updated every time when scrolling past the rowset points (70).
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.