wxPg::Query_browser Class Reference

Class for executing SQL queries, that return large results. More...

Inheritance diagram for wxPg::Query_browser:

wxPg::Query wxPg::Result_data wxPg::Data_row wxPg::Result_data_provider wxPg::DB_client wxPg::Data_row_provider wxPg::Data_row_provider

List of all members.

Public Member Functions

 Query_browser (Database *db, unsigned buf_size=DEF_BUFFER_SIZE)
 Create new object.
virtual ~Query_browser ()
 Destroys object.
void buffer_size (unsigned size)
 Change buffer size.
unsigned buffer_size () const
 Get buffer size.
virtual void first ()
 Go to first row in result.
virtual void last ()
 Go to last row in result.
virtual bool next ()
 Go to next row in result.
virtual bool prev ()
 Go to previous row in result.
virtual bool open (const wxString &sql)
 Open query - execute sql statement.
virtual bool fetch (int rows, int flag=FM_FORWARD)
 Fetch data of some rows.
virtual bool move (int rows, int flag=FM_FORWARD)
 Move cursor to different row without fetching data.
virtual bool current (int new_curr)
 Set current row.
unsigned long long abs_pos () const
 Absolute position in result.
long long cursor_pos () const
 Database cursor position.
bool is_last () const
 Is currently active row last in result.
unsigned long long record_count () const
 Get number of rows in result.

Static Public Attributes

static const unsigned DEF_BUFFER_SIZE = 50
 Default buffer size.


Detailed Description

Class for executing SQL queries, that return large results.

An object of this class keep a certain amount rows fetched to local buffer and alows working with entire result without worying about record fetching. NOTE: its not recomended to use fetch() and move() methods of this class.


Constructor & Destructor Documentation

wxPg::Query_browser::Query_browser ( Database db,
unsigned  buf_size = DEF_BUFFER_SIZE 
) [explicit]

Create new object.

Parameters:
db - database connection.
buf_size - buffer size, specifies a number of rows to be fetched to local buffer.

virtual wxPg::Query_browser::~Query_browser (  )  [virtual]

Destroys object.


Member Function Documentation

void wxPg::Query_browser::buffer_size ( unsigned  size  ) 

Change buffer size.

It is strongly recomended NOT to call this method when Query_browser is open.

Parameters:
size - new buffer size.

unsigned wxPg::Query_browser::buffer_size (  )  const

Get buffer size.

Returns:
currently used size of buffer.

virtual void wxPg::Query_browser::first (  )  [virtual]

Go to first row in result.

virtual void wxPg::Query_browser::last (  )  [virtual]

Go to last row in result.

virtual bool wxPg::Query_browser::next (  )  [virtual]

Go to next row in result.

Returns:
true when success, false on error or when end of result is reached (current row is already last).

virtual bool wxPg::Query_browser::prev (  )  [virtual]

Go to previous row in result.

Returns:
true on success, false on error or when beginning of result is reached (current row is already the first one).

virtual bool wxPg::Query_browser::open ( const wxString &  sql  )  [virtual]

Open query - execute sql statement.

Call last_err() for error message. Call fetch() to get all or part of returned result.

Parameters:
sql specifies an SQL statement.
Returns:
- true on success and false on error.

Reimplemented from wxPg::Query.

virtual bool wxPg::Query_browser::fetch ( int  rows,
int  flag = FM_FORWARD 
) [virtual]

Fetch data of some rows.

You need to call this method to obtain any data from query.

Parameters:
rows - number of rows to be fetched. Ignored for some flags.
flag sould be one of fetch and move actions.
Returns:
- true on success, false on error.

Reimplemented from wxPg::Query.

virtual bool wxPg::Query_browser::move ( int  rows,
int  flag = FM_FORWARD 
) [virtual]

Move cursor to different row without fetching data.

Parameters:
rows specifiels number of rows to move. Ignored for some flags.
flag sould be one of fetch and move actions. Not all are accepted.
Returns:
- true on success, false on error.

Reimplemented from wxPg::Query.

virtual bool wxPg::Query_browser::current ( int  idx  )  [virtual]

Set current row.

Parameters:
idx - index of row to become current.
Returns:
true on success, false otherwise.

Reimplemented from wxPg::Result_data.

unsigned long long wxPg::Query_browser::abs_pos (  )  const

Absolute position in result.

Don't mix this with current(), which returns position in current buffer.

Returns:
index of currently active row.

long long wxPg::Query_browser::cursor_pos (  )  const

Database cursor position.

This function returns position of cursor, used for reading data from result.

Returns:
current database cursor position.

bool wxPg::Query_browser::is_last (  )  const

Is currently active row last in result.

This method returns false until the end of result is reached and the number of rows in result is known.

Returns:
true if current row is last in result, false otherwise.

unsigned long long wxPg::Query_browser::record_count (  )  const

Get number of rows in result.

The exact number of rows in result is unknown until the end of result is reached.

Returns:
currently known (exact if end was reached) number of rows in result.


Member Data Documentation

const unsigned wxPg::Query_browser::DEF_BUFFER_SIZE = 50 [static]

Default buffer size.

Such amount of rows is fetched by default from query.


Generated on Thu May 7 22:51:17 2009 for wxPostgres by  doxygen 1.5.6