add support for declared cursors

Declare a cursor with the Finder::declare_cursor() method and next get the cursor with get_cursor():
morm::Cursor<MyObject> cursor = finder.
  declare_cursor("mycursorname").
  select().
  raw("ORDER BY column_name ASC").
  get_cursor();

The cursor now can be used with fetch.*() methods and then get() or get_list():
MyObject myobject = cursor.fetch_next().get();
std::list<MyObject> myobjects = cursor.fetch_forward_count(10).get_list();
This commit is contained in:
2023-07-16 04:03:03 +02:00
parent 6619f3ecb5
commit 21f12a8a98
8 changed files with 448 additions and 80 deletions

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2018-2022, Tomasz Sowa
* Copyright (c) 2018-2023, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -63,12 +63,13 @@ public:
bool query_update(const char * query_str, QueryResult & query_result);
bool query_insert(const char * query_str, QueryResult & query_result);
bool query_remove(const char * query_str, QueryResult & query_result);
bool query_declare_cursor(const char * query_str, QueryResult & query_result);
bool query_select(const pt::TextStream & stream, QueryResult & query_result);
bool query_update(const pt::TextStream & stream, QueryResult & query_result);
bool query_insert(const pt::TextStream & stream, QueryResult & query_result);
bool query_remove(const pt::TextStream & stream, QueryResult & query_result);
bool query_declare_cursor(const pt::TextStream & stream, QueryResult & query_result);
/*
* https://www.postgresql.org/docs/14/libpq-connect.html#LIBPQ-CONNSTRING
@@ -145,6 +146,7 @@ protected:
virtual void connect();
virtual bool do_query(const char * query_str, PostgreSQLQueryResult * psql_result);
virtual bool query_command(const char * query_str, QueryResult & query_result, ExecStatusType expected_status);
virtual void allocate_default_expression();
virtual void overwrite(pt::TextStream & stream);
virtual const char * query_last_sequence(const wchar_t * sequence_table_name);