1997-02-13 11:01:05 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* pgcursordb.h
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
* Postgres Cursor Database Class:
|
|
|
|
* Query Postgres backend using a cursor
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Currently under construction.
|
|
|
|
*
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1997-02-13 11:01:05 +01:00
|
|
|
*
|
1999-05-23 03:04:07 +02:00
|
|
|
*
|
2000-04-23 00:39:15 +02:00
|
|
|
* $Id: pgcursordb.h,v 1.5 2000/04/22 22:39:15 tgl Exp $
|
1999-05-23 03:04:07 +02:00
|
|
|
*
|
1997-02-13 11:01:05 +01:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2000-04-23 00:39:15 +02:00
|
|
|
#ifndef PGCURSORDB_H
|
|
|
|
#define PGCURSORDB_H
|
1997-02-13 11:01:05 +01:00
|
|
|
|
2000-04-23 00:39:15 +02:00
|
|
|
#ifndef PGTRANSDB_H
|
1997-02-13 11:01:05 +01:00
|
|
|
#include "pgtransdb.h"
|
2000-04-23 00:39:15 +02:00
|
|
|
#endif
|
1997-02-13 11:01:05 +01:00
|
|
|
|
1999-05-23 03:04:07 +02:00
|
|
|
|
1997-02-13 11:01:05 +01:00
|
|
|
// ****************************************************************
|
|
|
|
//
|
|
|
|
// PgCursor - a class for querying databases using a cursor
|
|
|
|
//
|
|
|
|
// ****************************************************************
|
|
|
|
// This is the database access class that declares a cursor and
|
|
|
|
// manipulates data through it. The interface will introduce some
|
|
|
|
// ease of use through the methods that will allow cursor specific
|
|
|
|
// operations, like fetch, forward, etc.
|
|
|
|
class PgCursor : public PgTransaction {
|
|
|
|
public:
|
1999-05-23 03:04:07 +02:00
|
|
|
PgCursor(const char* conninfo, const char* cursor); // use reasonable & environment defaults
|
1997-02-13 11:01:05 +01:00
|
|
|
// connect to the database with given environment and database name
|
1999-06-01 04:37:33 +02:00
|
|
|
// PgCursor(const PgConnection&, const char* cursor);
|
1999-05-23 03:04:07 +02:00
|
|
|
~PgCursor(); // close connection and clean up
|
1997-02-13 11:01:05 +01:00
|
|
|
|
|
|
|
// Commands associated with cursor interface
|
|
|
|
int Declare(const string& query, int binary = 0); // Declare a cursor with given name
|
|
|
|
int Fetch(const char* dir = "FORWARD"); // Fetch ALL tuples in given direction
|
|
|
|
int Fetch(unsigned num, const char* dir = "FORWARD"); // Fetch specified amount of tuples
|
|
|
|
int Close(); // Close the cursor
|
|
|
|
|
|
|
|
// Accessors to the cursor name
|
|
|
|
const char* Cursor() const { return pgCursor.c_str(); }
|
|
|
|
void Cursor(const string& cursor) { pgCursor = cursor; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int Fetch(const string& num, const string& dir);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
string pgCursor;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
PgCursor() : PgTransaction() {} // Do not connect
|
2000-04-23 00:39:15 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
// We don't support copying of PgCursor objects,
|
|
|
|
// so make copy constructor and assignment op private.
|
|
|
|
PgCursor(const PgCursor&);
|
|
|
|
PgCursor& operator= (const PgCursor&);
|
1997-02-13 11:01:05 +01:00
|
|
|
}; // End PgCursor Class Declaration
|
|
|
|
|
2000-04-23 00:39:15 +02:00
|
|
|
#endif // PGCURSORDB_H
|