problem with pagination in postgres

Issue #200 resolved
Sergey Burov created an issue

function TAnsiSQLGenerator.GeneratePagedQuery generate incorect sql syntax for postgres database

In postgres need use contruction LIMIT and OFFSET

perhaps should override function GeneratePagedQuery in class TPostgreSQLGenerator with code

function TPostgreSQLGenerator.GeneratePagedQuery(const sql: string; limit,
  offset: Integer): string;
var
  SqlStatement: string;
begin
  SqlStatement := sql;
  if EndsStr(';', SqlStatement) then
    SetLength(SqlStatement, Length(SqlStatement) - 1);

  if offset > 0 then
    SqlStatement := SqlStatement + Format(' OFFSET %d', [offset]);

  Result := SqlStatement + Format(' LIMIT %d%s',
    [limit, GetSplitStatementSymbol]);
end;

Comments (4)

  1. Log in to comment