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.
unsigned 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.
bool end_reached () const
 Is the end of result reached.
bool go_to_record (unsigned long long row, unsigned buf_pos=0)
 Move to record by index.

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 (  )  [inline, virtual]

Destroys object.


Member Function Documentation

unsigned long long wxPg::Query_browser::abs_pos (  )  const [inline]

Absolute position in result.

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

Returns:
index of currently active row.

unsigned wxPg::Query_browser::buffer_size (  )  const [inline]

Get buffer size.

Returns:
currently used size of buffer.

void wxPg::Query_browser::buffer_size ( unsigned  size  )  [inline]

Change buffer size.

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

Parameters:
size - new buffer size.

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::cursor_pos (  )  const [inline]

Database cursor position.

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

Returns:
current database cursor position.

bool wxPg::Query_browser::end_reached (  )  const [inline]

Is the end of result reached.

This method indicates, whether the end of result was reached at any time. The exact number of records in result is known only after the end of result is reached.

Returns:
true if end was reached, false otherwise.

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 void wxPg::Query_browser::first (  )  [virtual]

Go to first row in result.

bool wxPg::Query_browser::go_to_record ( unsigned long long  row,
unsigned  buf_pos = 0 
)

Move to record by index.

If requested record is in currently fetched buffer, only buffer position is changed. Otherwise a buffer with requested record is fetch, with attempt to fetch, that the requested record would be in buf_pos position in buffer.
In case of error returns back to the same record.

Parameters:
row - a 0-based number of row in result.
buf_pos - when fetch occurs, preferred buffer position.
Returns:
true on success, false on error.

bool wxPg::Query_browser::is_last (  )  const [inline]

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.

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

Go to last row in result.

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::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::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::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).

unsigned long long wxPg::Query_browser::record_count (  )  const [inline]

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 Wed Oct 7 23:14:40 2009 for wxPostgres by  doxygen 1.5.8