commit cb5ee3453ea8455febed5ea300cc68cd4807a46f
Author: Böszörményi Zoltán <zboszor@pr.hu>
Date:   Wed Apr 16 10:22:08 2014 +0200

    ECPG: Make NO SCROLL explicit for cursors where SCROLL is not
    specified. ecpg/test/sql/fetch.pgc had to be modified so the
    cursor is scrollable to avoid an infinite loop in the test.
    
    Pass the cursors' SCROLL/NO SCROLL flag to ECPGopen(). Use this
    information to reduce network roundtrip to the backend in case
    a known-non-scrollable cursor and backward movement are used
    together. Use the recently exposed ecpg_prologue(), etc.
    
    Also pass the direction and the amount of tuples to ECPGfetch().

diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml
index 7b825ef..b242fcc 100644
--- a/doc/src/sgml/ecpg.sgml
+++ b/doc/src/sgml/ecpg.sgml
@@ -5270,23 +5270,30 @@ while (1)
        The statement you are trying to use has not been prepared.
        (SQLSTATE 26000)
       </para>
      </listitem>
     </varlistentry>
 
     <varlistentry>
      <term>-231 (<symbol>ECPG_INVALID_CURSOR</symbol>)</term>
      <listitem>
       <para>
+       This error code may occur in the following conditions.
+      </para>
+      <para>
        The cursor name you are trying to use is invalid.
        (SQLSTATE 34000)
       </para>
+      <para>
+       The cursor was declared to be non-scrollable and you are
+       trying to move or fetch backward. (SQLSTATE 55000)
+      </para>
      </listitem>
     </varlistentry>
 
     <varlistentry>
      <term>-239 (<symbol>ECPG_INFORMIX_DUPLICATE_KEY</symbol>)</term>
      <listitem>
       <para>
        Duplicate key error, violation of unique constraint (Informix
        compatibility mode).  (SQLSTATE 23505)
       </para>
diff --git a/src/interfaces/ecpg/ecpglib/cursor.c b/src/interfaces/ecpg/ecpglib/cursor.c
index 44b6b37..9cbade6 100644
--- a/src/interfaces/ecpg/ecpglib/cursor.c
+++ b/src/interfaces/ecpg/ecpglib/cursor.c
@@ -90,21 +90,22 @@ find_cursor(struct connection *con, int lineno, const char *name, bool ignore,
 
 /*
  * Add a new cursor descriptor, maintain "mostly" alphabetic order.
  * - case sensitive alphabetic order for quoted cursor names
  * - case insensitive alphabetic order for non-quoted cursor names
  */
 static struct cursor_descriptor *
 add_cursor(int lineno, struct connection *con,
 					const char *name,
 					int subxact_level,
-					bool with_hold)
+					bool with_hold,
+					enum ECPG_cursor_scroll scrollable)
 {
 	struct cursor_descriptor *desc, *prev;
 
 	if (!name || name[0] == '\0')
 		return NULL;
 
 	if (find_cursor(con, lineno, name, true, &desc, &prev))
 		return desc;
 
 	desc = (struct cursor_descriptor *)
@@ -116,20 +117,21 @@ add_cursor(int lineno, struct connection *con,
 	/* Copy the name */
 	desc->name = ecpg_strdup(name, lineno);
 	if (!desc->name)
 	{
 		ecpg_free(desc);
 		return NULL;
 	}
 
 	desc->subxact_level = subxact_level;
 	desc->with_hold = with_hold;
+	desc->scrollable = scrollable;
 
 	if (prev)
 	{
 		desc->next = prev->next;
 		prev->next = desc;
 	}
 	else
 	{
 		desc->next = con->cursor_desc;
 		con->cursor_desc = desc;
@@ -236,21 +238,22 @@ ecpg_commit_cursors(int lineno, struct connection * conn,
 }
 
 /*
  * Declare the cursor in the backend and create a
  * minimalistic descriptor to make tracking possible.
  * This function is called when the ECPG code OPENs the cursor.
  */
 bool
 ECPGopen(const int lineno, const int compat, const int force_indicator,
 			const char *connection_name, const bool questionmarks,
-			const bool with_hold, const char *curname, const int st, const char *query, ...)
+			const bool with_hold, enum ECPG_cursor_scroll scrollable,
+			const char *curname, const int st, const char *query, ...)
 {
 	struct connection *con = ecpg_get_connection(connection_name);
 	int		subxact_level;
 	bool		ret;
 	va_list		args;
 
 	/*
 	 * Execute the DECLARE query in the backend.
 	 */
 	va_start(args, query);
@@ -263,54 +266,171 @@ ECPGopen(const int lineno, const int compat, const int force_indicator,
 	if (!ret)
 		return false;
 
 	/* Finally add the cursor to the connection. */
 	if (con->subxact_desc)
 		subxact_level = con->subxact_desc->level;
 	else
 		subxact_level =
 			(PQtransactionStatus(con->connection) != PQTRANS_IDLE ?
 										1 : 0);
-	add_cursor(lineno, con, curname, subxact_level, with_hold);
+	add_cursor(lineno, con, curname, subxact_level, with_hold, scrollable);
 
 	return true;
 }
 
 /*
+ * Canonicalize the amount of cursor movement.
+ */
+static bool
+ecpg_canonical_cursor_movement(enum ECPG_cursor_direction *direction, const char *amount,
+				bool *fetchall, int64 *amount_out)
+{
+	bool		negate = false;
+	int64		amount1;
+
+	/*
+	 * We might have got a constant string from the grammar.
+	 * We have to handle the negative and explicitely positive constants
+	 * here because e.g. '-2' arrives as '- 2' from the grammar.
+	 * strtoll() under Linux stops processing at the space.
+	 */
+	if (amount[0] == '-' || amount[0] == '+')
+	{
+		negate = (amount[0] == '-');
+		amount++;
+		while (*amount == ' ')
+			amount++;
+	}
+
+	/* FETCH/MOVE [ FORWARD | BACKWARD ] ALL */
+	if (strcmp(amount, "all") == 0)
+	{
+		*fetchall = true;
+		amount1 = 0;
+	}
+	else
+	{
+		char	   *endptr;
+
+		amount1 = strtoll(amount, &endptr, 10);
+
+		if (*endptr)
+			return false;
+
+		if (negate)
+			amount1 = -amount1;
+		*fetchall = false;
+	}
+
+	/*
+	 * Canonicalize ECPGc_backward but don't lose
+	 * FETCH BACKWARD ALL semantics.
+	 */
+	if ((*fetchall == false) && (*direction == ECPGc_backward))
+	{
+		amount1 = -amount1;
+		*direction = ECPGc_forward;
+	}
+
+	*amount_out = amount1;
+	return true;
+}
+
+/*
  * ECPGfetch
  * Execute a FETCH or MOVE statement for the application.
  *
  * This function maintains the internal cursor descriptor and
- * reduces the the network roundtrip by returning early for
- * an unknown cursor name.
+ * reduces the the network roundtrip by:
+ * - returning early for an unknown cursor name
+ * - checking whether the cursor is scrollable against the direction
  */
 bool
 ECPGfetch(const int lineno, const int compat, const int force_indicator,
 				const char *connection_name, const bool questionmarks,
+				enum ECPG_cursor_direction dir, const char *amount,
 				const char *curname, const int st, const char *query, ...)
 {
 	struct connection  *con = ecpg_get_connection(connection_name);
 	struct cursor_descriptor *cur;
-	bool		ret;
+	struct statement   *stmt;
+	int64		amount1;
+	bool		fetchall;
 	va_list		args;
 
 	if (!find_cursor(con, lineno, curname, false, &cur, NULL))
 		return false;
 
 	va_start(args, query);
-	ret = ecpg_do(lineno, compat, force_indicator, connection_name, questionmarks,
-									st,
-									query,
-									args);
+
+	if (!ecpg_do_prologue(lineno, compat, force_indicator,
+				connection_name, questionmarks,
+				(enum ECPG_statement_type) st,
+				query, args, &stmt))
+	{
+		ecpg_do_epilogue(stmt);
+		va_end(args);
+		return false;
+	}
+
 	va_end(args);
 
-	return ret;
+	if (!ecpg_build_params(stmt, (dir >= ECPGc_absolute_in_var)))
+	{
+		ecpg_do_epilogue(stmt);
+		return false;
+	}
+
+	if (dir >= ECPGc_absolute_in_var)
+	{
+		dir -= ECPGc_absolute_in_var;
+		amount = stmt->cursor_amount;
+	}
+
+	if (!ecpg_canonical_cursor_movement(&dir, amount, &fetchall, &amount1))
+	{
+		ecpg_do_epilogue(stmt);
+		ecpg_raise(lineno, ECPG_NUMERIC_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, amount);
+		con->client_side_error = true;
+		return false;
+	}
+
+	if (cur->scrollable == ECPGcs_no_scroll && (amount1 < 0 || dir == ECPGc_backward))
+	{
+		ecpg_do_epilogue(stmt);
+		ecpg_raise(lineno, ECPG_NUMERIC_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, amount);
+		con->client_side_error = true;
+		return false;
+	}
+
+	if (!ecpg_autostart_transaction(stmt))
+	{
+		ecpg_do_epilogue(stmt);
+		return false;
+	}
+
+	if (!ecpg_execute(stmt))
+	{
+		ecpg_do_epilogue(stmt);
+		return false;
+	}
+
+	if (!ecpg_process_output(stmt, 0, PQntuples(stmt->results), LOOP_FORWARD, 0, true, false))
+	{
+		ecpg_do_epilogue(stmt);
+		return false;
+	}
+
+	ecpg_do_epilogue(stmt);
+
+	return true;
 }
 
 /*
  * ECPGcursor_dml
  * Called for DELETE / UPDATE ... WHERE CURRENT OF cursorname
  */
 bool
 ECPGcursor_dml(const int lineno, const int compat, const int force_indicator,
 				const char *connection_name, const bool questionmarks,
 				const char *curname, const int st, const char *query, ...)
diff --git a/src/interfaces/ecpg/ecpglib/error.c b/src/interfaces/ecpg/ecpglib/error.c
index 0e5c2e1..ccf9ecc 100644
--- a/src/interfaces/ecpg/ecpglib/error.c
+++ b/src/interfaces/ecpg/ecpglib/error.c
@@ -211,20 +211,27 @@ ecpg_raise(int line, int code, const char *sqlstate, const char *str)
 			break;
 
 		case ECPG_INVALID_CURSOR:
 			if (strcmp(sqlstate, ECPG_SQLSTATE_INVALID_CURSOR_NAME) == 0)
 			{
 				snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
 			/*------
 			   translator: this string will be truncated at 149 characters expanded.  */
 					 ecpg_gettext("invalid cursorname \"%s\" on line %d"), str, line);
 			}
+			else if (strcmp(sqlstate, ECPG_SQLSTATE_OBJECT_NOT_IN_PREREQUISITE_STATE) == 0)
+			{
+				snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
+			/*------
+			   translator: this string will be truncated at 149 characters expanded.  */
+					 ecpg_gettext("cursor \"%s\" can only scan forward on line %d"), str, line);
+			}
 			else
 			{
 				snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
 			/*------
 			   translator: this string will be truncated at 149 characters expanded.  */
 					 ecpg_gettext("invalid cursor error %d on line %d"), code, line);
 			}
 			break;
 
 		default:
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index 5bc84af..f2a8fc7 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -98,20 +98,21 @@ free_variable(struct variable * var)
 static void
 free_statement(struct statement * stmt)
 {
 	if (stmt == NULL)
 		return;
 	free_variable(stmt->inlist);
 	free_variable(stmt->outlist);
 	ecpg_free(stmt->command);
 	ecpg_free(stmt->name);
 	ecpg_free(stmt->oldlocale);
+	ecpg_free(stmt->cursor_amount);
 	ecpg_free(stmt);
 }
 
 static int
 next_insert(char *text, int pos, bool questionmarks)
 {
 	bool		string = false;
 	int			p = pos;
 
 	for (; text[p] != '\0'; p++)
@@ -1148,21 +1149,21 @@ insert_tobeinserted(int position, int ph_len, struct statement * stmt, char *tob
 }
 
 /*
  * ecpg_build_params
  *		Build statement parameters
  *
  * The input values are taken from user variables, and the results are stored
  * in arrays which can be used by PQexecParams().
  */
 bool
-ecpg_build_params(struct statement * stmt)
+ecpg_build_params(struct statement * stmt, bool first_0_is_cursor_amount)
 {
 	struct variable *var;
 	int			desc_counter = 0;
 	int			position = 0;
 
 	/*
 	 * If the type is one of the fill in types then we take the argument and
 	 * enter it to our parameter array at the first position. Then if there
 	 * are any more fill in types we add more parameters.
 	 */
@@ -1380,20 +1381,31 @@ ecpg_build_params(struct statement * stmt)
 			tobeinserted = NULL;
 		}
 
 		/*
 		 * if the placeholder is '$0' we have to replace it on the client side
 		 * this is for places we want to support variables at that are not
 		 * supported in the backend
 		 */
 		else if (stmt->command[position] == '0')
 		{
+			if (first_0_is_cursor_amount)
+			{
+				stmt->cursor_amount = ecpg_strdup(tobeinserted, stmt->lineno);
+				if (stmt->cursor_amount == NULL)
+				{
+					ecpg_free_params(stmt, false);
+					return false;
+				}
+				first_0_is_cursor_amount = false;
+			}
+
 			if (!insert_tobeinserted(position, 2, stmt, tobeinserted))
 			{
 				ecpg_free_params(stmt, false);
 				return false;
 			}
 			tobeinserted = NULL;
 		}
 		else
 		{
 			char	  **paramvalues;
@@ -2101,21 +2113,21 @@ ecpg_do_epilogue(struct statement * stmt)
 bool
 ecpg_do(const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query, va_list args)
 {
 	struct statement *stmt = NULL;
 
 	if (!ecpg_do_prologue(lineno, compat, force_indicator, connection_name,
 						  questionmarks, (enum ECPG_statement_type) st,
 						  query, args, &stmt))
 		goto fail;
 
-	if (!ecpg_build_params(stmt))
+	if (!ecpg_build_params(stmt, false))
 		goto fail;
 
 	if (!ecpg_autostart_transaction(stmt))
 		goto fail;
 
 	if (!ecpg_execute(stmt))
 		goto fail;
 
 	if (!ecpg_process_output(stmt, 0, PQntuples(stmt->results), LOOP_FORWARD, 0, true, false))
 		goto fail;
diff --git a/src/interfaces/ecpg/ecpglib/extern.h b/src/interfaces/ecpg/ecpglib/extern.h
index 5bb7ecd..bc54a84 100644
--- a/src/interfaces/ecpg/ecpglib/extern.h
+++ b/src/interfaces/ecpg/ecpglib/extern.h
@@ -59,20 +59,21 @@ struct statement
 	struct connection *connection;
 	enum COMPAT_MODE compat;
 	bool		force_indicator;
 	enum ECPG_statement_type statement_type;
 	bool		questionmarks;
 	struct variable *inlist;
 	struct variable *outlist;
 	char	   *oldlocale;
 	int		nparams;
 	char	  **paramvalues;
+	char	   *cursor_amount;
 	PGresult   *results;
 };
 
 /* structure to store prepared statements for a connection */
 struct prepared_statement
 {
 	char	   *name;
 	bool		prepared;
 	struct statement *stmt;
 	struct prepared_statement *next;
@@ -91,20 +92,21 @@ struct cursor_descriptor {
 	char	   *name;
 
 	/*
 	 * The cursor was created in this level of * (sub-)transaction.
 	 * 0: WITH HOLD, committed successfully in a previous transaction
 	 * 1: cursor declared in the toplevel transaction
 	 * >=2: cursor declared in a named SAVEPOINT at the specified level
 	 */
 	int		subxact_level;
 	bool		with_hold;
+	enum ECPG_cursor_scroll scrollable;
 };
 
 /* structure to store connections */
 struct connection
 {
 	char	   *name;
 	PGconn	   *connection;
 	bool		autocommit;
 	bool		client_side_error;
 	struct ECPGtype_information_cache *cache_head;
@@ -195,21 +197,21 @@ struct prepared_statement *ecpg_find_prepared_statement(const char *,
 
 bool ecpg_store_result(const PGresult *results,
 				  int start, int ntuples, int direction, int act_field,
 				  const struct statement * stmt,
 				  struct variable * var, int var_index);
 bool		ecpg_store_input(const int, const bool, const struct variable *, char **, bool);
 void		ecpg_free_params(struct statement *stmt, bool print);
 bool		ecpg_do_prologue(int, const int, const int, const char *, const bool,
 				  enum ECPG_statement_type, const char *, va_list,
 				  struct statement **);
-bool		ecpg_build_params(struct statement *);
+bool		ecpg_build_params(struct statement *, bool);
 bool		ecpg_autostart_transaction(struct statement * stmt);
 bool		ecpg_execute(struct statement * stmt);
 bool		ecpg_process_output(struct statement *, int, int, int, int, bool, bool);
 void		ecpg_do_epilogue(struct statement *);
 bool		ecpg_do(const int, const int, const int, const char *, const bool,
 				  const int, const char *, va_list);
 
 bool		ecpg_check_PQresult(PGresult *, int, PGconn *, enum COMPAT_MODE);
 void		ecpg_raise(int line, int code, const char *sqlstate, const char *str);
 void		ecpg_raise_backend(int line, PGresult *result, PGconn *conn, int compat);
@@ -242,16 +244,17 @@ void		ecpg_commit_cursors(int lineno, struct connection * conn, bool rollback, i
 #define ECPG_SQLSTATE_ACTIVE_SQL_TRANSACTION		"25001"
 #define ECPG_SQLSTATE_NO_ACTIVE_SQL_TRANSACTION		"25P01"
 #define ECPG_SQLSTATE_IN_FAILED_SQL_TRANSACTION		"25P02"
 #define ECPG_SQLSTATE_INVALID_SQL_STATEMENT_NAME	"26000"
 #define ECPG_SQLSTATE_INVALID_SQL_DESCRIPTOR_NAME	"33000"
 #define ECPG_SQLSTATE_INVALID_CURSOR_NAME		"34000"
 #define ECPG_SQLSTATE_S_E_INVALID_SPECIFICATION		"3B001"
 #define ECPG_SQLSTATE_SYNTAX_ERROR			"42601"
 #define ECPG_SQLSTATE_DATATYPE_MISMATCH		"42804"
 #define ECPG_SQLSTATE_DUPLICATE_CURSOR		"42P03"
+#define ECPG_SQLSTATE_OBJECT_NOT_IN_PREREQUISITE_STATE	"55000"
 
 /* implementation-defined internal errors of ecpg */
 #define ECPG_SQLSTATE_ECPG_INTERNAL_ERROR	"YE000"
 #define ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY	"YE001"
 
 #endif   /* _ECPG_LIB_EXTERN_H */
diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h
index 1ac15d5..ace2d2c 100644
--- a/src/interfaces/ecpg/include/ecpglib.h
+++ b/src/interfaces/ecpg/include/ecpglib.h
@@ -58,22 +58,24 @@ bool		ECPGprepare(int, const char *, const bool, const char *, const char *);
 bool		ECPGdeallocate(int, int, const char *, const char *);
 bool		ECPGdeallocate_all(int, int, const char *);
 char	   *ECPGprepared_statement(const char *, const char *, int);
 PGconn	   *ECPGget_PGconn(const char *);
 PGTransactionStatusType ECPGtransactionStatus(const char *);
 
 char	   *ECPGerrmsg(void);
 
 /* Cursor functions */
 bool		ECPGopen(const int, const int, const int, const char *, const bool, const bool,
+				enum ECPG_cursor_scroll,
 				const char *, const int, const char *, ...);
 bool		ECPGfetch(const int, const int, const int, const char *, const bool,
+				enum ECPG_cursor_direction, const char *,
 				const char *, const int, const char *, ...);
 bool		ECPGcursor_dml(const int, const int, const int, const char *, const bool,
 				const char *, const int, const char *, ...);
 bool		ECPGclose(const int, const int, const int, const char *, const bool,
 				const char *, const int, const char *, ...);
 
  /* print an error message */
 void		sqlprint(void);
 
 /* define this for simplicity as well as compatibility */
diff --git a/src/interfaces/ecpg/include/ecpgtype.h b/src/interfaces/ecpg/include/ecpgtype.h
index 7cc47e9..72b8596 100644
--- a/src/interfaces/ecpg/include/ecpgtype.h
+++ b/src/interfaces/ecpg/include/ecpgtype.h
@@ -92,15 +92,34 @@ enum ECPGdtype
 
 /* we also have to handle different statement types */
 enum ECPG_statement_type
 {
 	ECPGst_normal,
 	ECPGst_execute,
 	ECPGst_exec_immediate,
 	ECPGst_prepnormal
 };
 
+enum ECPG_cursor_direction
+{
+	ECPGc_absolute,
+	ECPGc_relative,
+	ECPGc_forward,
+	ECPGc_backward,
+	ECPGc_absolute_in_var,
+	ECPGc_relative_in_var,
+	ECPGc_forward_in_var,
+	ECPGc_backward_in_var
+};
+
+enum ECPG_cursor_scroll
+{
+	ECPGcs_unspecified,
+	ECPGcs_no_scroll,
+	ECPGcs_scroll
+};
+
 #ifdef __cplusplus
 }
 #endif
 
 #endif   /* _ECPGTYPE_H */
diff --git a/src/interfaces/ecpg/preproc/ecpg.addons b/src/interfaces/ecpg/preproc/ecpg.addons
index df85424..a280de0 100644
--- a/src/interfaces/ecpg/preproc/ecpg.addons
+++ b/src/interfaces/ecpg/preproc/ecpg.addons
@@ -123,20 +123,24 @@ ECPG: TransactionStmtPREPARETRANSACTIONSconst addon
 ECPG: TransactionStmtCOMMITPREPAREDSconst addon
 		transact_prepared = true;
 		transact_start = false;
 		transact_rollback = false;
 		transact_name = NULL;
 ECPG: TransactionStmtROLLBACKPREPAREDSconst addon
 		transact_prepared = true;
 		transact_start = false;
 		transact_rollback = true;
 		transact_name = NULL;
+ECPG: cursor_optionscursor_optionsNOSCROLL addon
+		current_cursor_scrollable = ECPGcs_no_scroll;
+ECPG: cursor_optionscursor_optionsSCROLL addon
+		current_cursor_scrollable = ECPGcs_scroll;
 ECPG: stmtViewStmt rule
 	| ECPGAllocateDescr
 	{
 		fprintf(yyout,"ECPGallocate_desc(__LINE__, %s);",$1);
 		whenever_action(0);
 		free($1);
 	}
 	| ECPGConnect
 	{
 		if (connection)
@@ -296,72 +300,188 @@ ECPG: var_valueNumericOnly addon
 			free($1);
 			$1 = mm_strdup("$0");
 		}
 ECPG: fetch_argscursor_name addon
 		add_additional_variables($1, false);
 		if ($1[0] == ':')
 		{
 			free($1);
 			$1 = mm_strdup("$0");
 		}
+		current_cursor_direction = ECPGc_forward;
+		current_cursor_amount = mm_strdup("1");
 ECPG: fetch_argsfrom_incursor_name addon
 		add_additional_variables($2, false);
 		if ($2[0] == ':')
 		{
 			free($2);
 			$2 = mm_strdup("$0");
 		}
+		current_cursor_direction = ECPGc_forward;
+		current_cursor_amount = mm_strdup("1");
 ECPG: fetch_argsNEXTopt_from_incursor_name addon
+		add_additional_variables($3, false);
+		if ($3[0] == ':')
+		{
+			free($3);
+			$3 = mm_strdup("$0");
+		}
+		current_cursor_direction = ECPGc_forward;
+		current_cursor_amount = mm_strdup("1");
 ECPG: fetch_argsPRIORopt_from_incursor_name addon
+		add_additional_variables($3, false);
+		if ($3[0] == ':')
+		{
+			free($3);
+			$3 = mm_strdup("$0");
+		}
+		current_cursor_direction = ECPGc_backward;
+		current_cursor_amount = mm_strdup("1");
 ECPG: fetch_argsFIRST_Popt_from_incursor_name addon
+		add_additional_variables($3, false);
+		if ($3[0] == ':')
+		{
+			free($3);
+			$3 = mm_strdup("$0");
+		}
+		current_cursor_direction = ECPGc_absolute;
+		current_cursor_amount = mm_strdup("1");
 ECPG: fetch_argsLAST_Popt_from_incursor_name addon
+		add_additional_variables($3, false);
+		if ($3[0] == ':')
+		{
+			free($3);
+			$3 = mm_strdup("$0");
+		}
+		current_cursor_direction = ECPGc_absolute;
+		current_cursor_amount = mm_strdup("-1");
 ECPG: fetch_argsALLopt_from_incursor_name addon
 		add_additional_variables($3, false);
 		if ($3[0] == ':')
 		{
 			free($3);
 			$3 = mm_strdup("$0");
 		}
+		current_cursor_direction = ECPGc_forward;
+		current_cursor_amount = mm_strdup("all");
 ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
 		add_additional_variables($3, false);
 		if ($3[0] == ':')
 		{
 			free($3);
 			$3 = mm_strdup("$0");
 		}
 		if ($1[0] == '$')
 		{
 			free($1);
 			$1 = mm_strdup("$0");
+			current_cursor_direction = ECPGc_forward_in_var;
+			current_cursor_amount = NULL;
+		}
+		else
+		{
+			current_cursor_direction = ECPGc_forward;
+			current_cursor_amount = mm_strdup($1);
 		}
 ECPG: fetch_argsFORWARDALLopt_from_incursor_name addon
+		add_additional_variables($4, false);
+		if ($4[0] == ':')
+		{
+			free($4);
+			$4 = mm_strdup("$0");
+		}
+		current_cursor_direction = ECPGc_forward;
+		current_cursor_amount = mm_strdup("all");
 ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
 		add_additional_variables($4, false);
 		if ($4[0] == ':')
 		{
 			free($4);
 			$4 = mm_strdup("$0");
 		}
+		current_cursor_direction = ECPGc_backward;
+		current_cursor_amount = mm_strdup("all");
 ECPG: fetch_argsABSOLUTE_PSignedIconstopt_from_incursor_name addon
+		add_additional_variables($4, false);
+		if ($4[0] == ':')
+		{
+			free($4);
+			$4 = mm_strdup("$0");
+		}
+		if ($2[0] == '$')
+		{
+			free($2);
+			$2 = mm_strdup("$0");
+			current_cursor_direction = ECPGc_absolute_in_var;
+			current_cursor_amount = NULL;
+		}
+		else
+		{
+			current_cursor_direction = ECPGc_absolute;
+			current_cursor_amount = mm_strdup($2);
+		}
 ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_incursor_name addon
+		add_additional_variables($4, false);
+		if ($4[0] == ':')
+		{
+			free($4);
+			$4 = mm_strdup("$0");
+		}
+		if ($2[0] == '$')
+		{
+			free($2);
+			$2 = mm_strdup("$0");
+			current_cursor_direction = ECPGc_relative_in_var;
+			current_cursor_amount = NULL;
+		}
+		else
+		{
+			current_cursor_direction = ECPGc_relative;
+			current_cursor_amount = mm_strdup($2);
+		}
 ECPG: fetch_argsFORWARDSignedIconstopt_from_incursor_name addon
+		add_additional_variables($4, false);
+		if ($4[0] == ':')
+		{
+			free($4);
+			$4 = mm_strdup("$0");
+		}
+		if ($2[0] == '$')
+		{
+			free($2);
+			$2 = mm_strdup("$0");
+			current_cursor_direction = ECPGc_forward_in_var;
+			current_cursor_amount = NULL;
+		}
+		else
+		{
+			current_cursor_direction = ECPGc_forward;
+			current_cursor_amount = mm_strdup($2);
+		}
 ECPG: fetch_argsBACKWARDSignedIconstopt_from_incursor_name addon
 		add_additional_variables($4, false);
 		if ($4[0] == ':')
 		{
 			free($4);
 			$4 = mm_strdup("$0");
 		}
 		if ($2[0] == '$')
 		{
 			free($2);
 			$2 = mm_strdup("$0");
+			current_cursor_direction = ECPGc_backward_in_var;
+			current_cursor_amount = NULL;
+		}
+		else
+		{
+			current_cursor_direction = ECPGc_backward;
+			current_cursor_amount = mm_strdup($2);
 		}
 ECPG: cursor_namename block
 		{
 			current_cursor = mm_strdup($1);
 			current_cursor_vartype = ECPGt_const;
 			$$ = $1;
 		}
 	| char_civar
 		{
 			char *curname = mm_alloc(strlen($1) + 2);
@@ -405,21 +525,31 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
 
 		this = (struct cursor *) mm_alloc(sizeof(struct cursor));
 
 		this->next = cur;
 		this->name = $2;
 		this->function = (current_function ? mm_strdup(current_function) : NULL);
 		this->connection = connection;
 		this->opened = false;
 		this->with_hold = (strncmp($5, "with ", 5) == 0);
 		this->vartype = current_cursor_vartype;
-		this->command =  cat_str(7, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for"), $7);
+		if (current_cursor_scrollable == ECPGcs_unspecified)
+		{
+			this->scrollable = ECPGcs_no_scroll;
+			this->command =  cat_str(8, mm_strdup("declare"), cursor_marker, $3, mm_strdup("no scroll"), mm_strdup("cursor"), $5, mm_strdup("for"), $7);
+		}
+		else
+		{
+			this->scrollable = current_cursor_scrollable;
+			this->command =  cat_str(7, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for"), $7);
+			current_cursor_scrollable = ECPGcs_unspecified;
+		}
 		this->argsinsert = argsinsert;
 		this->argsinsert_oos = NULL;
 		this->argsresult = argsresult;
 		this->argsresult_oos = NULL;
 		argsinsert = argsresult = NULL;
 		cur = this;
 
 		c1 = mm_strdup(this->command);
 		if ((c2 = strstr(c1, "*/")) != NULL)
 		{
@@ -511,61 +641,77 @@ ECPG: VariableShowStmtSHOWALL block
 	}
 ECPG: FetchStmtMOVEfetch_args rule
 	| FETCH fetch_args ecpg_fetch_into
 	{
 		$$ = cat2_str(mm_strdup("fetch"), $2);
 	}
 	| FETCH FORWARD cursor_name opt_ecpg_fetch_into
 	{
 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
 		add_additional_variables($3, false);
+		current_cursor_direction = ECPGc_forward;
+		current_cursor_amount = mm_strdup("1");
 		$$ = cat_str(2, mm_strdup("fetch forward"), cursor_marker);
 	}
 	| FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
 	{
 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
 		add_additional_variables($4, false);
+		current_cursor_direction = ECPGc_forward;
+		current_cursor_amount = mm_strdup("1");
 		$$ = cat_str(2, mm_strdup("fetch forward from"), cursor_marker);
 	}
 	| FETCH BACKWARD cursor_name opt_ecpg_fetch_into
 	{
 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
 		add_additional_variables($3, false);
+		current_cursor_direction = ECPGc_backward;
+		current_cursor_amount = mm_strdup("1");
 		$$ = cat_str(2, mm_strdup("fetch backward"), cursor_marker);
 	}
 	| FETCH BACKWARD from_in cursor_name opt_ecpg_fetch_into
 	{
 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
 		add_additional_variables($4, false);
+		current_cursor_direction = ECPGc_backward;
+		current_cursor_amount = mm_strdup("1");
 		$$ = cat_str(2, mm_strdup("fetch backward from"), cursor_marker);
 	}
 	| MOVE FORWARD cursor_name
 	{
 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
 		add_additional_variables($3, false);
+		current_cursor_direction = ECPGc_forward;
+		current_cursor_amount = mm_strdup("1");
 		$$ = cat_str(2, mm_strdup("move forward"), cursor_marker);
 	}
 	| MOVE FORWARD from_in cursor_name
 	{
 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
 		add_additional_variables($4, false);
+		current_cursor_direction = ECPGc_forward;
+		current_cursor_amount = mm_strdup("1");
 		$$ = cat_str(2, mm_strdup("move forward from"), cursor_marker);
 	}
 	| MOVE BACKWARD cursor_name
 	{
 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
 		add_additional_variables($3, false);
+		current_cursor_direction = ECPGc_backward;
+		current_cursor_amount = mm_strdup("1");
 		$$ = cat_str(2, mm_strdup("move backward"), cursor_marker);
 	}
 	| MOVE BACKWARD from_in cursor_name
 	{
 		char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
 		add_additional_variables($4, false);
+		current_cursor_direction = ECPGc_backward;
+		current_cursor_amount = mm_strdup("1");
 		$$ = cat_str(2, mm_strdup("move backward from"), cursor_marker);
 	}
 ECPG: limit_clauseLIMITselect_limit_value','select_offset_value block
 	{
 		mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");
 		$$ = cat_str(4, mm_strdup("limit"), $2, mm_strdup(","), $4);
 	}
 ECPG: SignedIconstIconst rule
 	| civar	{ $$ = $1; }
diff --git a/src/interfaces/ecpg/preproc/ecpg.header b/src/interfaces/ecpg/preproc/ecpg.header
index eb3511c..1d15539 100644
--- a/src/interfaces/ecpg/preproc/ecpg.header
+++ b/src/interfaces/ecpg/preproc/ecpg.header
@@ -29,20 +29,24 @@
  */
 #define bison_gettext_dummy gettext_noop("syntax error")
 
 /*
  * Variables containing simple states.
  */
 int struct_level = 0;
 int braces_open; /* brace level counter */
 char *current_function;
 char *current_cursor = NULL;
+enum ECPGttype current_cursor_vartype;
+enum ECPG_cursor_direction current_cursor_direction;
+enum ECPG_cursor_scroll current_cursor_scrollable = ECPGcs_unspecified;
+char *current_cursor_amount = NULL;
 bool transact_prepared = false;
 bool transact_start = false;
 bool transact_rollback = false;
 char *transact_name = NULL;
 int ecpg_internal_var = 0;
 char	*connection = NULL;
 char	*input_filename = NULL;
 
 static int	FoundInto = 0;
 static int	initializer = 0;
diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer
index de77ece..124a036 100644
--- a/src/interfaces/ecpg/preproc/ecpg.trailer
+++ b/src/interfaces/ecpg/preproc/ecpg.trailer
@@ -311,21 +311,31 @@ ECPGCursorStmt:  DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared
 			this = (struct cursor *) mm_alloc(sizeof(struct cursor));
 
 			/* initial definition */
 			this->next = cur;
 			this->name = $2;
 			this->function = (current_function ? mm_strdup(current_function) : NULL);
 			this->connection = connection;
 			this->opened = false;
 			this->with_hold = (strncmp($5, "with ", 5) == 0);
 			this->vartype = current_cursor_vartype;
-			this->command =  cat_str(6, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for $1"));
+			if (current_cursor_scrollable == ECPGcs_unspecified)
+			{
+				this->scrollable = ECPGcs_no_scroll;
+				this->command =  cat_str(7, mm_strdup("declare"), cursor_marker, $3, mm_strdup("no scroll"), mm_strdup("cursor"), $5, mm_strdup("for $1"));
+			}
+			else
+			{
+				this->scrollable = current_cursor_scrollable;
+				this->command =  cat_str(6, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for $1"));
+				current_cursor_scrollable = ECPGcs_unspecified;
+			}
 			this->argsresult = NULL;
 			this->argsresult_oos = NULL;
 
 			thisquery->type = &ecpg_query;
 			thisquery->brace_level = 0;
 			thisquery->next = NULL;
 			thisquery->name = (char *) mm_alloc(sizeof("ECPGprepared_statement(, , __LINE__)") + strlen(con) + strlen($7));
 			sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);
 
 			this->argsinsert = NULL;
diff --git a/src/interfaces/ecpg/preproc/extern.h b/src/interfaces/ecpg/preproc/extern.h
index f3d39ce..134b581 100644
--- a/src/interfaces/ecpg/preproc/extern.h
+++ b/src/interfaces/ecpg/preproc/extern.h
@@ -24,21 +24,24 @@ extern bool autocommit,
 			force_indicator,
 			questionmarks,
 			regression_mode,
 			auto_prepare;
 extern int	braces_open,
 			ret_value,
 			struct_level,
 			ecpg_internal_var;
 extern char *current_function;
 extern char *current_cursor;
-enum ECPGttype current_cursor_vartype;
+extern enum ECPGttype current_cursor_vartype;
+extern enum ECPG_cursor_direction current_cursor_direction;
+extern enum ECPG_cursor_scroll current_cursor_scrollable;
+extern char *current_cursor_amount;
 extern char *descriptor_index;
 extern char *descriptor_name;
 extern char *connection;
 extern char *input_filename;
 extern char *yytext,
 		   *token_start;
 
 #ifdef YYDEBUG
 extern int	yydebug;
 #endif
diff --git a/src/interfaces/ecpg/preproc/output.c b/src/interfaces/ecpg/preproc/output.c
index a49b89c..22fb67e 100644
--- a/src/interfaces/ecpg/preproc/output.c
+++ b/src/interfaces/ecpg/preproc/output.c
@@ -118,20 +118,37 @@ hashline_number(void)
 	return EMPTY;
 }
 
 static char *ecpg_statement_type_name[] = {
 	"ECPGst_normal",
 	"ECPGst_execute",
 	"ECPGst_exec_immediate",
 	"ECPGst_prepnormal"
 };
 
+static char *ecpg_cursor_direction_name[] = {
+	"ECPGc_absolute",
+	"ECPGc_relative",
+	"ECPGc_forward",
+	"ECPGc_backward",
+	"ECPGc_absolute_in_var",
+	"ECPGc_relative_in_var",
+	"ECPGc_forward_in_var",
+	"ECPGc_backward_in_var"
+};
+
+static char *ecpg_cursor_scroll_name[] = {
+	"ECPGcs_unspecified",
+	"ECPGcs_no_scroll",
+	"ECPGcs_scroll"
+};
+
 static void output_cursor_name(struct cursor *ptr)
 {
 	if (current_cursor[0] == ':')
 	{
 		char *curname = current_cursor + 1;
 
 		fputs(curname, yyout);
 		if (ptr->vartype == ECPGt_varchar)
 			fputs(".arr", yyout);
 		fputs(", ", yyout);
@@ -219,33 +236,49 @@ output_deallocate_prepare_statement(char *name)
 	free(name);
 	if (connection != NULL)
 		free(connection);
 }
 
 void
 output_open_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st)
 {
 	struct cursor *ptr = get_cursor(current_cursor);
 
-	fprintf(yyout, "{ ECPGopen(__LINE__, %d, %d, %s, %d, %d, ", compat, force_indicator, connection ? connection : "NULL", questionmarks, ptr->with_hold);
+	fprintf(yyout, "{ ECPGopen(__LINE__, %d, %d, %s, %d, %d, %s, ",
+						compat, force_indicator, connection ? connection : "NULL", questionmarks,
+						ptr->with_hold, ecpg_cursor_scroll_name[ptr->scrollable]);
 	output_cursor_name(ptr);
 	output_statement_epilogue(stmt, whenever_mode, st);
 }
 
 void
 output_fetch_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st)
 {
 	struct cursor *ptr = get_cursor(current_cursor);
+	char	   *amount;
+
+	if (current_cursor_amount)
+	{
+		amount = mm_alloc(strlen(current_cursor_amount) + 3);
+		sprintf(amount, "\"%s\"", current_cursor_amount);
+		free(current_cursor_amount);
+	}
+	else
+		amount = mm_strdup("NULL");
 
-	fprintf(yyout, "{ ECPGfetch(__LINE__, %d, %d, %s, %d, ", compat, force_indicator, connection ? connection : "NULL", questionmarks);
+	fprintf(yyout, "{ ECPGfetch(__LINE__, %d, %d, %s, %d, %s, %s, ",
+						compat, force_indicator, connection ? connection : "NULL", questionmarks,
+						ecpg_cursor_direction_name[current_cursor_direction], amount);
 	output_cursor_name(ptr);
 	output_statement_epilogue(stmt, whenever_mode, st);
+	free(amount);
+	current_cursor_amount = NULL;
 }
 
 void
 output_cursor_dml_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st)
 {
 	struct cursor *ptr = get_cursor(current_cursor);
 
 	fprintf(yyout, "{ ECPGcursor_dml(__LINE__, %d, %d, %s, %d, ", compat, force_indicator, connection ? connection : "NULL", questionmarks);
 	output_cursor_name(ptr);
 	output_statement_epilogue(stmt, whenever_mode, st);
diff --git a/src/interfaces/ecpg/preproc/type.h b/src/interfaces/ecpg/preproc/type.h
index a293e9e..f0a26f5 100644
--- a/src/interfaces/ecpg/preproc/type.h
+++ b/src/interfaces/ecpg/preproc/type.h
@@ -124,20 +124,21 @@ struct _include_path
 
 struct cursor
 {
 	char	   *name;
 	char	   *function;
 	char	   *command;
 	char	   *connection;
 	bool		opened;
 	bool		with_hold;
 	enum ECPGttype	vartype;
+	enum ECPG_cursor_scroll scrollable;
 	struct arguments *argsinsert;
 	struct arguments *argsinsert_oos;
 	struct arguments *argsresult;
 	struct arguments *argsresult_oos;
 	struct cursor *next;
 };
 
 struct typedefs
 {
 	char	   *name;
diff --git a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
index e47b373..9b5ba19 100644
--- a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
+++ b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
@@ -229,43 +229,43 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "prepare");
 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
 #line 95 "sqlda.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 95 "sqlda.pgc"
 
 
 	strcpy(msg, "declare");
-	ECPG_informix_reset_sqlca(); /* declare mycur1 cursor for $1 */
+	ECPG_informix_reset_sqlca(); /* declare mycur1 no scroll cursor for $1 */
 #line 98 "sqlda.pgc"
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 0, "mycur1", ECPGst_normal, "declare mycur1 cursor for $1", 
+	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 0, ECPGcs_no_scroll, "mycur1", ECPGst_normal, "declare mycur1 no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 101 "sqlda.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 101 "sqlda.pgc"
 
 
 	/* exec sql whenever not found  break ; */
 #line 103 "sqlda.pgc"
 
 
 	rec = 0;
 	while (1)
 	{
 		strcpy(msg, "fetch");
-		{ ECPGfetch(__LINE__, 1, 1, NULL, 0, "mycur1", ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
+		{ ECPGfetch(__LINE__, 1, 1, NULL, 0, ECPGc_forward, "1", "mycur1", ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 109 "sqlda.pgc"
 
 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
 #line 109 "sqlda.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 109 "sqlda.pgc"
 
@@ -304,43 +304,43 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "prepare");
 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
 #line 132 "sqlda.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 132 "sqlda.pgc"
 
 
 	strcpy(msg, "declare");
-	ECPG_informix_reset_sqlca(); /* declare mycur2 cursor for $1 */
+	ECPG_informix_reset_sqlca(); /* declare mycur2 no scroll cursor for $1 */
 #line 135 "sqlda.pgc"
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 0, "mycur2", ECPGst_normal, "declare mycur2 cursor for $1", 
+	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 0, ECPGcs_no_scroll, "mycur2", ECPGst_normal, "declare mycur2 no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 138 "sqlda.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 138 "sqlda.pgc"
 
 
 	/* exec sql whenever not found  break ; */
 #line 140 "sqlda.pgc"
 
 
 	rec = 0;
 	while (1)
 	{
 		strcpy(msg, "fetch");
-		{ ECPGfetch(__LINE__, 1, 1, NULL, 0, "mycur2", ECPGst_normal, "fetch from mycur2", ECPGt_EOIT, 
+		{ ECPGfetch(__LINE__, 1, 1, NULL, 0, ECPGc_forward, "1", "mycur2", ECPGst_normal, "fetch from mycur2", ECPGt_EOIT, 
 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 146 "sqlda.pgc"
 
 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
 #line 146 "sqlda.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 146 "sqlda.pgc"
 
diff --git a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr
index 5cc5291..1ed5dde 100644
--- a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr
+++ b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr
@@ -17,21 +17,21 @@
 [NO_PID]: ecpg_execute on line 82: query: insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 4 , 'd' , 4.0 , 4 , 'd' ); with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 82: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 82: OK: INSERT 0 3
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 88: action "commit"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: prepare_common on line 95: name st_id1; query: "SELECT * FROM t1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 101: query: declare mycur1 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 101: query: declare mycur1 no scroll cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 101: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 101: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 109: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 109: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 109: correctly got 1 tuples with 5 fields
@@ -129,21 +129,21 @@
 [NO_PID]: ecpg_execute on line 118: query: close mycur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 118: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 118: OK: CLOSE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: deallocate_one on line 121: name st_id1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: prepare_common on line 132: name st_id2; query: "SELECT * FROM t1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 138: query: declare mycur2 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 138: query: declare mycur2 no scroll cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 138: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 138: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 146: query: fetch from mycur2; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 146: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 146: correctly got 1 tuples with 5 fields
diff --git a/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c b/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
index f88f9f2..71c65b3 100644
--- a/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
+++ b/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
@@ -141,31 +141,31 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
 	printf("SELECT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
 	if (sqlca.sqlcode != 0) { ECPGtrans(__LINE__, NULL, "rollback", 0, 0, 1, NULL);
 #line 46 "test_informix.pgc"
 
 if (sqlca.sqlcode < 0) dosqlprint ( );}
 #line 46 "test_informix.pgc"
 
 
 	sqlca.sqlcode = 100;
 	ECPGset_var( 0, &( i ), __LINE__);\
- ECPG_informix_reset_sqlca(); /* declare c cursor for select * from test where i <= $1  */
+ ECPG_informix_reset_sqlca(); /* declare c no scroll cursor for select * from test where i <= $1  */
 #line 49 "test_informix.pgc"
 
 	printf ("%ld\n", sqlca.sqlcode);
 	openit();
 
 	deccvint(0, &j);
 
 	while (1)
 	{
-		{ ECPGfetch(__LINE__, 1, 1, NULL, 0, "c", ECPGst_normal, "fetch forward c", ECPGt_EOIT, 
+		{ ECPGfetch(__LINE__, 1, 1, NULL, 0, ECPGc_forward, "1", "c", ECPGst_normal, "fetch forward c", ECPGt_EOIT, 
 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_string,(c),(long)10,(long)1,(10)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 57 "test_informix.pgc"
 
 if (sqlca.sqlcode < 0) dosqlprint ( );}
 #line 57 "test_informix.pgc"
@@ -237,19 +237,19 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
 
 if (sqlca.sqlcode < 0) dosqlprint ( );}
 #line 88 "test_informix.pgc"
 
 
 	return 0;
 }
 
 static void openit(void)
 {
-	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 0, "c", ECPGst_normal, "declare c cursor for select * from test where i <= $1 ", 
+	{ ECPGopen(__LINE__, 1, 1, NULL, 0, 0, ECPGcs_no_scroll, "c", ECPGst_normal, "declare c no scroll cursor for select * from test where i <= $1 ", 
 	ECPGt_int,&(*( int  *)(ECPGget_var( 0))),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 95 "test_informix.pgc"
 
 if (sqlca.sqlcode < 0) dosqlprint ( );}
 #line 95 "test_informix.pgc"
 
 }
diff --git a/src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr b/src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr
index 7d376c9..a5a1b3c 100644
--- a/src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr
+++ b/src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr
@@ -48,21 +48,21 @@ DETAIL:  Key (i)=(7) already exists.
 [NO_PID]: raising sqlstate 21000 (sqlcode -284): more than one row returned by a subquery used as an expression on line 40
 [NO_PID]: sqlca: code: -284, state: 21000
 [NO_PID]: ECPGtrans on line 41: action "rollback"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 44: query: select i from test where j = ( select j from test order by i limit 1 ); with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 44: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 44: correctly got 1 tuples with 1 fields
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 95: query: declare c cursor for select * from test where i <= $1 ; with 1 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 95: query: declare c no scroll cursor for select * from test where i <= $1 ; with 1 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 95: using PQexecParams
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_free_params on line 95: parameter 1 = 14
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 95: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 57: query: fetch forward c; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 57: using PQexec
diff --git a/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c b/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
index 715f960..3cbcb81 100644
--- a/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
+++ b/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
@@ -72,32 +72,32 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 if (sqlca.sqlcode < 0) sqlprint ( );}
 #line 30 "nan_test.pgc"
 
 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest1 ( id , d ) values ( 1 , 'nan' :: float8 ) , ( 2 , 'infinity' :: float8 ) , ( 3 , '-infinity' :: float8 )", ECPGt_EOIT, ECPGt_EORT);
 #line 31 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
 #line 31 "nan_test.pgc"
 
 
-	/* declare cur cursor for select id , d , d from nantest1 */
+	/* declare cur no scroll cursor for select id , d , d from nantest1 */
 #line 33 "nan_test.pgc"
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "cur", ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "cur", ECPGst_normal, "declare cur no scroll cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
 #line 34 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
 #line 34 "nan_test.pgc"
 
 	while (1)
 	{
-		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, "cur", ECPGst_normal, "fetch from cur", ECPGt_EOIT, 
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "cur", ECPGst_normal, "fetch from cur", ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_double,&(d),(long)1,(long)1,sizeof(double), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 37 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
 #line 37 "nan_test.pgc"
@@ -130,29 +130,29 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 #line 46 "nan_test.pgc"
 
 	}
 	{ ECPGclose(__LINE__, 0, 1, NULL, 0, "cur", ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT);
 #line 48 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
 #line 48 "nan_test.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "cur", ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "cur", ECPGst_normal, "declare cur no scroll cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
 #line 50 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
 #line 50 "nan_test.pgc"
 
 	while (1)
 	{
-		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, "cur", ECPGst_normal, "fetch from cur", ECPGt_EOIT, 
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "cur", ECPGst_normal, "fetch from cur", ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_double,&(d),(long)1,(long)1,sizeof(double), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 53 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
 #line 53 "nan_test.pgc"
@@ -211,32 +211,32 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 
 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into nantest2 ( id , d ) values ( 6 , $1  )", 
 	ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 73 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
 #line 73 "nan_test.pgc"
 
 
-	/* declare cur1 cursor for select id , d , d from nantest2 */
+	/* declare cur1 no scroll cursor for select id , d , d from nantest2 */
 #line 75 "nan_test.pgc"
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "cur1", ECPGst_normal, "declare cur1 cursor for select id , d , d from nantest2", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "cur1", ECPGst_normal, "declare cur1 no scroll cursor for select id , d , d from nantest2", ECPGt_EOIT, ECPGt_EORT);
 #line 76 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
 #line 76 "nan_test.pgc"
 
 	while (1)
 	{
-		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, "cur1", ECPGst_normal, "fetch from cur1", ECPGt_EOIT, 
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "cur1", ECPGst_normal, "fetch from cur1", ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_numeric,&(num),(long)1,(long)0,sizeof(numeric), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(val),(long)16,(long)1,(16)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 79 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
 #line 79 "nan_test.pgc"
diff --git a/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.stderr b/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.stderr
index 0c437a1..b07ed65 100644
--- a/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.stderr
+++ b/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.stderr
@@ -7,21 +7,21 @@
 [NO_PID]: ecpg_execute on line 30: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 30: OK: CREATE TABLE
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 31: query: insert into nantest1 ( id , d ) values ( 1 , 'nan' :: float8 ) , ( 2 , 'infinity' :: float8 ) , ( 3 , '-infinity' :: float8 ); with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 31: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 31: OK: INSERT 0 3
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 34: query: declare cur cursor for select id , d , d from nantest1; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 34: query: declare cur no scroll cursor for select id , d , d from nantest1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 34: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 34: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 37: query: fetch from cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 37: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 37: correctly got 1 tuples with 3 fields
@@ -123,21 +123,21 @@
 [NO_PID]: ecpg_process_output on line 37: correctly got 0 tuples with 3 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode 100 on line 37: no data found on line 37
 [NO_PID]: sqlca: code: 100, state: 02000
 [NO_PID]: ecpg_execute on line 48: query: close cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 48: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 48: OK: CLOSE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 50: query: declare cur cursor for select id , d , d from nantest1; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 50: query: declare cur no scroll cursor for select id , d , d from nantest1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 50: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 50: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: query: fetch from cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 53: correctly got 1 tuples with 3 fields
@@ -291,21 +291,21 @@
 [NO_PID]: ecpg_process_output on line 72: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 73: query: insert into nantest2 ( id , d ) values ( 6 , $1  ); with 1 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 73: using PQexecParams
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_free_params on line 73: parameter 1 = NaN
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 73: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 76: query: declare cur1 cursor for select id , d , d from nantest2; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 76: query: declare cur1 no scroll cursor for select id , d , d from nantest2; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 76: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 76: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 79: query: fetch from cur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 79: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 79: correctly got 1 tuples with 3 fields
diff --git a/src/interfaces/ecpg/test/expected/preproc-autoprep.c b/src/interfaces/ecpg/test/expected/preproc-autoprep.c
index 8872986..5bb6b1d 100644
--- a/src/interfaces/ecpg/test/expected/preproc-autoprep.c
+++ b/src/interfaces/ecpg/test/expected/preproc-autoprep.c
@@ -122,35 +122,35 @@ if (sqlca.sqlcode < 0) sqlprint();}
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
 #line 30 "autoprep.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 30 "autoprep.pgc"
 
 
   for (i=0; i<4; i++)
 	printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]);
 
-  /* declare C cursor for select Item1 from T */
+  /* declare C no scroll cursor for select Item1 from T */
 #line 35 "autoprep.pgc"
 
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "C", ECPGst_normal, "declare C cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "C", ECPGst_normal, "declare C no scroll cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT);
 #line 37 "autoprep.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
 #line 37 "autoprep.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 37 "autoprep.pgc"
 
 
-  { ECPGfetch(__LINE__, 0, 1, NULL, 0, "C", ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, 
+  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "C", ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, 
 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 39 "autoprep.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
 #line 39 "autoprep.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 39 "autoprep.pgc"
 
@@ -169,44 +169,44 @@ if (sqlca.sqlcode < 0) sqlprint();}
   { ECPGprepare(__LINE__, NULL, 0, "stmt1", sqlstr);
 #line 44 "autoprep.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
 #line 44 "autoprep.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 44 "autoprep.pgc"
 
 
-  /* declare cur1 cursor for $1 */
+  /* declare cur1 no scroll cursor for $1 */
 #line 46 "autoprep.pgc"
 
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "cur1", ECPGst_normal, "declare cur1 cursor for $1", 
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "cur1", ECPGst_normal, "declare cur1 no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 48 "autoprep.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
 #line 48 "autoprep.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 48 "autoprep.pgc"
 
 
   /* exec sql whenever not found  break ; */
 #line 50 "autoprep.pgc"
 
 
   i = 0;
   while (1)
   {
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, "cur1", ECPGst_normal, "fetch cur1", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "cur1", ECPGst_normal, "fetch cur1", ECPGt_EOIT, 
 	ECPGt_int,&(item1),(long)1,(long)1,sizeof(int), 
 	ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int), ECPGt_EORT);
 #line 55 "autoprep.pgc"
 
 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
 #line 55 "autoprep.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
 #line 55 "autoprep.pgc"
 
diff --git a/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr b/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr
index 7043761..d2b0828 100644
--- a/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr
+++ b/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr
@@ -59,21 +59,21 @@
 [NO_PID]: ecpg_process_output on line 30: correctly got 4 tuples with 1 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 30: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 30: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 30: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 30: RESULT:  offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 37: query: declare C cursor for select Item1 from T; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 37: query: declare C no scroll cursor for select Item1 from T; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 37: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 37: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 39: query: fetch 1 in C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 39: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 39: correctly got 1 tuples with 1 fields
@@ -81,21 +81,21 @@
 [NO_PID]: ecpg_get_data on line 39: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 42: query: close C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 42: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 42: OK: CLOSE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: prepare_common on line 44: name stmt1; query: "SELECT item2 FROM T ORDER BY item2 NULLS LAST"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 48: query: declare cur1 cursor for SELECT item2 FROM T ORDER BY item2 NULLS LAST; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 48: query: declare cur1 no scroll cursor for SELECT item2 FROM T ORDER BY item2 NULLS LAST; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 48: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 48: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 55: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 55: correctly got 1 tuples with 1 fields
@@ -219,21 +219,21 @@
 [NO_PID]: ecpg_process_output on line 30: correctly got 4 tuples with 1 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 30: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 30: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 30: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 30: RESULT:  offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 37: query: declare C cursor for select Item1 from T; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 37: query: declare C no scroll cursor for select Item1 from T; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 37: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 37: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 39: query: fetch 1 in C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 39: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 39: correctly got 1 tuples with 1 fields
@@ -241,21 +241,21 @@
 [NO_PID]: ecpg_get_data on line 39: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 42: query: close C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 42: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 42: OK: CLOSE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: prepare_common on line 44: name stmt1; query: "SELECT item2 FROM T ORDER BY item2 NULLS LAST"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 48: query: declare cur1 cursor for SELECT item2 FROM T ORDER BY item2 NULLS LAST; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 48: query: declare cur1 no scroll cursor for SELECT item2 FROM T ORDER BY item2 NULLS LAST; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 48: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 48: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 55: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 55: correctly got 1 tuples with 1 fields
diff --git a/src/interfaces/ecpg/test/expected/preproc-cursor.c b/src/interfaces/ecpg/test/expected/preproc-cursor.c
index 6f92797..8bd0f9f 100644
--- a/src/interfaces/ecpg/test/expected/preproc-cursor.c
+++ b/src/interfaces/ecpg/test/expected/preproc-cursor.c
@@ -175,125 +175,125 @@ if (sqlca.sqlcode < 0) exit (1);}
 #line 58 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 58 "cursor.pgc"
 
 
 	/* Dynamic cursorname test with INTO list in FETCH stmts */
 
 	strcpy(msg, "declare");
 	ECPGset_var( 0, &( curname1 ), __LINE__);\
- /* declare $0 cursor for select id , t from t1 */
+ /* declare $0 no scroll cursor for select id , t from t1 */
 #line 64 "cursor.pgc"
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, curname1, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, curname1, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 67 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 67 "cursor.pgc"
 
 
 	strcpy(msg, "fetch from");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname1, ECPGst_normal, "fetch forward from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname1, ECPGst_normal, "fetch forward from $0", 
 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 70 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 70 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname1, ECPGst_normal, "fetch forward $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname1, ECPGst_normal, "fetch forward $0", 
 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 74 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 74 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch 1 from");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname1, ECPGst_normal, "fetch 1 from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname1, ECPGst_normal, "fetch 1 from $0", 
 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 78 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 78 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch :count from");
 	count = 1;
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname1, ECPGst_normal, "fetch $0 from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, curname1, ECPGst_normal, "fetch $0 from $0", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 83 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 83 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "move in");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname1, ECPGst_normal, "move absolute 0 in $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_absolute, "0", curname1, ECPGst_normal, "move absolute 0 in $0", 
 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 87 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 87 "cursor.pgc"
 
 
 	strcpy(msg, "fetch 1");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname1, ECPGst_normal, "fetch 1 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname1, ECPGst_normal, "fetch 1 $0", 
 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 90 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 90 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch :count");
 	count = 1;
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname1, ECPGst_normal, "fetch $0 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, curname1, ECPGst_normal, "fetch $0 $0", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 95 "cursor.pgc"
 
@@ -311,133 +311,133 @@ if (sqlca.sqlcode < 0) exit (1);}
 if (sqlca.sqlcode < 0) exit (1);}
 #line 99 "cursor.pgc"
 
 
 	/* Dynamic cursorname test with INTO list in DECLARE stmt */
 
 	strcpy(msg, "declare");
 	ECPGset_var( 1, &( curname2 ), __LINE__);\
  ECPGset_var( 2, ( t ), __LINE__);\
  ECPGset_var( 3, &( id ), __LINE__);\
- /* declare $0 cursor for select id , t from t1 */
+ /* declare $0 no scroll cursor for select id , t from t1 */
 #line 105 "cursor.pgc"
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, curname2, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, curname2, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 108 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 108 "cursor.pgc"
 
 
 	strcpy(msg, "fetch from");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname2, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname2, ECPGst_normal, "fetch from $0", 
 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 111 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 111 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname2, ECPGst_normal, "fetch $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname2, ECPGst_normal, "fetch $0", 
 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 115 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 115 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch 1 from");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname2, ECPGst_normal, "fetch 1 from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname2, ECPGst_normal, "fetch 1 from $0", 
 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 119 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 119 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch :count from");
 	count = 1;
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname2, ECPGst_normal, "fetch $0 from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, curname2, ECPGst_normal, "fetch $0 from $0", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 124 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 124 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "move");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname2, ECPGst_normal, "move absolute 0 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_absolute, "0", curname2, ECPGst_normal, "move absolute 0 $0", 
 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 128 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 128 "cursor.pgc"
 
 
 	strcpy(msg, "fetch 1");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname2, ECPGst_normal, "fetch 1 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname2, ECPGst_normal, "fetch 1 $0", 
 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 131 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 131 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch :count");
 	count = 1;
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname2, ECPGst_normal, "fetch $0 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, curname2, ECPGst_normal, "fetch $0 $0", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 136 "cursor.pgc"
 
@@ -467,141 +467,141 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	{ ECPGprepare(__LINE__, "test2", 0, "st_id1", stmt1);
 #line 146 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 146 "cursor.pgc"
 
 
 	strcpy(msg, "declare");
 	ECPGset_var( 4, &( curname3 ), __LINE__);\
- /* declare $0 cursor for $1 */
+ /* declare $0 no scroll cursor for $1 */
 #line 149 "cursor.pgc"
 
 	ECPGset_var( 5, &( curname5 ), __LINE__);\
- /* declare $0 cursor for $1 */
+ /* declare $0 no scroll cursor for $1 */
 #line 150 "cursor.pgc"
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, curname3, ECPGst_normal, "declare $0 cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, curname3, ECPGst_normal, "declare $0 no scroll cursor for $1", 
 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char_variable,(ECPGprepared_statement("test1", "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 153 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 153 "cursor.pgc"
 
-	{ ECPGopen(__LINE__, 0, 1, "test2", 0, 0, curname5, ECPGst_normal, "declare $0 cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, "test2", 0, 0, ECPGcs_no_scroll, curname5, ECPGst_normal, "declare $0 no scroll cursor for $1", 
 	ECPGt_char,&(curname5),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char_variable,(ECPGprepared_statement("test2", "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 154 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 154 "cursor.pgc"
 
 
 	strcpy(msg, "fetch");
-	{ ECPGfetch(__LINE__, 0, 1, "test2", 0, curname5, ECPGst_normal, "fetch $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test2", 0, ECPGc_forward, "1", curname5, ECPGst_normal, "fetch $0", 
 	ECPGt_char,&(curname5),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 157 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 157 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch from");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname3, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname3, ECPGst_normal, "fetch from $0", 
 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 161 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 161 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch 1 from");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname3, ECPGst_normal, "fetch 1 from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname3, ECPGst_normal, "fetch 1 from $0", 
 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 165 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 165 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch :count from");
 	count = 1;
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname3, ECPGst_normal, "fetch $0 from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, curname3, ECPGst_normal, "fetch $0 from $0", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 170 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 170 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "move");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname3, ECPGst_normal, "move absolute 0 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_absolute, "0", curname3, ECPGst_normal, "move absolute 0 $0", 
 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 174 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 174 "cursor.pgc"
 
 
 	strcpy(msg, "fetch 1");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname3, ECPGst_normal, "fetch 1 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname3, ECPGst_normal, "fetch 1 $0", 
 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 177 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 177 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch :count");
 	count = 1;
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname3, ECPGst_normal, "fetch $0 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, curname3, ECPGst_normal, "fetch $0 $0", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 182 "cursor.pgc"
 
@@ -651,127 +651,127 @@ if (sqlca.sqlcode < 0) exit (1);}
 	strcpy(msg, "prepare");
 	{ ECPGprepare(__LINE__, "test1", 0, "st_id2", stmt1);
 #line 200 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 200 "cursor.pgc"
 
 
 	strcpy(msg, "declare");
 	ECPGset_var( 6, &( curname4 ), __LINE__);\
- /* declare $0 cursor for $1 */
+ /* declare $0 no scroll cursor for $1 */
 #line 203 "cursor.pgc"
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, curname4.arr, ECPGst_normal, "declare $0 cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, "test1", 0, 0, ECPGcs_no_scroll, curname4.arr, ECPGst_normal, "declare $0 no scroll cursor for $1", 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char_variable,(ECPGprepared_statement("test1", "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 206 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 206 "cursor.pgc"
 
 
 	strcpy(msg, "fetch from");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname4.arr, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname4.arr, ECPGst_normal, "fetch from $0", 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 209 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 209 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname4.arr, ECPGst_normal, "fetch $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname4.arr, ECPGst_normal, "fetch $0", 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 213 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 213 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch 1 from");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname4.arr, ECPGst_normal, "fetch 1 from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname4.arr, ECPGst_normal, "fetch 1 from $0", 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 217 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 217 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch :count from");
 	count = 1;
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname4.arr, ECPGst_normal, "fetch $0 from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, curname4.arr, ECPGst_normal, "fetch $0 from $0", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 222 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 222 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "move");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname4.arr, ECPGst_normal, "move absolute 0 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_absolute, "0", curname4.arr, ECPGst_normal, "move absolute 0 $0", 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 226 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 226 "cursor.pgc"
 
 
 	strcpy(msg, "fetch 1");
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname4.arr, ECPGst_normal, "fetch 1 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward, "1", curname4.arr, ECPGst_normal, "fetch 1 $0", 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 229 "cursor.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 229 "cursor.pgc"
 
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch :count");
 	count = 1;
-	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, curname4.arr, ECPGst_normal, "fetch $0 $0", 
+	{ ECPGfetch(__LINE__, 0, 1, "test1", 0, ECPGc_forward_in_var, NULL, curname4.arr, ECPGst_normal, "fetch $0 $0", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 234 "cursor.pgc"
 
diff --git a/src/interfaces/ecpg/test/expected/preproc-cursor.stderr b/src/interfaces/ecpg/test/expected/preproc-cursor.stderr
index 9020f09..6eb0ad8 100644
--- a/src/interfaces/ecpg/test/expected/preproc-cursor.stderr
+++ b/src/interfaces/ecpg/test/expected/preproc-cursor.stderr
@@ -49,21 +49,21 @@
 [NO_PID]: ecpg_execute on line 54: query: insert into t1 ( id , t ) values ( default , 'e' ); with 0 parameter(s) on connection test2
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 54: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 54: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 57: action "commit"; connection "test1"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 58: action "commit"; connection "test2"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 67: query: declare mycur cursor for select id , t from t1; with 0 parameter(s) on connection test1
+[NO_PID]: ecpg_execute on line 67: query: declare mycur no scroll cursor for select id , t from t1; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 67: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 67: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 70: query: fetch forward from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 70: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 70: correctly got 1 tuples with 2 fields
@@ -127,21 +127,21 @@
 [NO_PID]: ecpg_get_data on line 95: RESULT: 2 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 95: RESULT: b offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 99: query: close mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 99: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 99: OK: CLOSE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 108: query: declare mycur cursor for select id , t from t1; with 0 parameter(s) on connection test1
+[NO_PID]: ecpg_execute on line 108: query: declare mycur no scroll cursor for select id , t from t1; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 108: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 108: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 111: query: fetch from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 111: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 111: correctly got 1 tuples with 2 fields
@@ -209,27 +209,27 @@
 [NO_PID]: ecpg_execute on line 140: query: close mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 140: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 140: OK: CLOSE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: prepare_common on line 145: name st_id1; query: "SELECT id, t FROM t1"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: prepare_common on line 146: name st_id1; query: "SELECT id, t FROM t1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 153: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on connection test1
+[NO_PID]: ecpg_execute on line 153: query: declare mycur no scroll cursor for SELECT id, t FROM t1; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 153: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 153: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 154: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on connection test2
+[NO_PID]: ecpg_execute on line 154: query: declare mycur no scroll cursor for SELECT id, t FROM t1; with 0 parameter(s) on connection test2
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 154: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 154: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 157: query: fetch mycur; with 0 parameter(s) on connection test2
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 157: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 157: correctly got 1 tuples with 2 fields
@@ -305,21 +305,21 @@
 [NO_PID]: ecpg_execute on line 187: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 187: OK: CLOSE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: deallocate_one on line 190: name st_id1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: deallocate_one on line 191: name st_id1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: prepare_common on line 200: name st_id2; query: "SELECT id, t FROM t1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 206: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on connection test1
+[NO_PID]: ecpg_execute on line 206: query: declare mycur no scroll cursor for SELECT id, t FROM t1; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 206: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 206: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 209: query: fetch from mycur; with 0 parameter(s) on connection test1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 209: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 209: correctly got 1 tuples with 2 fields
diff --git a/src/interfaces/ecpg/test/expected/preproc-outofscope.c b/src/interfaces/ecpg/test/expected/preproc-outofscope.c
index a23522b..5117df0 100644
--- a/src/interfaces/ecpg/test/expected/preproc-outofscope.c
+++ b/src/interfaces/ecpg/test/expected/preproc-outofscope.c
@@ -180,35 +180,35 @@ get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
 #line 23 "outofscope.pgc"
  MYNULLTYPE * mynullvar = malloc ( sizeof ( MYNULLTYPE ) ) ;
 /* exec sql end declare section */
 #line 24 "outofscope.pgc"
 
 
 	/* Test DECLARE ... SELECT ... INTO with pointers */
 
 	ECPGset_var( 0, ( myvar ), __LINE__);\
  ECPGset_var( 1, ( mynullvar ), __LINE__);\
- /* declare mycur cursor for select * from a1 */
+ /* declare mycur no scroll cursor for select * from a1 */
 #line 28 "outofscope.pgc"
 
 
 	if (sqlca.sqlcode != 0)
 		exit(1);
 
 	*myvar0 = myvar;
 	*mynullvar0 = mynullvar;
 }
 
 static void
 open_cur1(void)
 {
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "mycur", ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT, 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "mycur", ECPGst_normal, "declare mycur no scroll cursor for select * from a1", ECPGt_EOIT, 
 	ECPGt_int,&((*( MYTYPE  *)(ECPGget_var( 0)) ).id),(long)1,(long)1,sizeof( struct mytype ), 
 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1)) ).id),(long)1,(long)1,sizeof( struct mynulltype ), 
 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0)) ).t),(long)64,(long)1,sizeof( struct mytype ), 
 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1)) ).t),(long)1,(long)1,sizeof( struct mynulltype ), 
 	ECPGt_double,&((*( MYTYPE  *)(ECPGget_var( 0)) ).d1),(long)1,(long)1,sizeof( struct mytype ), 
 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1)) ).d1),(long)1,(long)1,sizeof( struct mynulltype ), 
 	ECPGt_double,&((*( MYTYPE  *)(ECPGget_var( 0)) ).d2),(long)1,(long)1,sizeof( struct mytype ), 
 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1)) ).d2),(long)1,(long)1,sizeof( struct mynulltype ), 
 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0)) ).c),(long)30,(long)1,sizeof( struct mytype ), 
 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1)) ).c),(long)1,(long)1,sizeof( struct mynulltype ), ECPGt_EORT);
@@ -218,21 +218,21 @@ if (sqlca.sqlcode < 0) exit (1);}
 #line 40 "outofscope.pgc"
 
 
 	if (sqlca.sqlcode != 0)
 		exit(1);
 }
 
 static void
 get_record1(void)
 {
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, "mycur", ECPGst_normal, "fetch mycur", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "mycur", ECPGst_normal, "fetch mycur", ECPGt_EOIT, 
 	ECPGt_int,&((*( MYTYPE  *)(ECPGget_var( 0)) ).id),(long)1,(long)1,sizeof( struct mytype ), 
 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1)) ).id),(long)1,(long)1,sizeof( struct mynulltype ), 
 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0)) ).t),(long)64,(long)1,sizeof( struct mytype ), 
 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1)) ).t),(long)1,(long)1,sizeof( struct mynulltype ), 
 	ECPGt_double,&((*( MYTYPE  *)(ECPGget_var( 0)) ).d1),(long)1,(long)1,sizeof( struct mytype ), 
 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1)) ).d1),(long)1,(long)1,sizeof( struct mynulltype ), 
 	ECPGt_double,&((*( MYTYPE  *)(ECPGget_var( 0)) ).d2),(long)1,(long)1,sizeof( struct mytype ), 
 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1)) ).d2),(long)1,(long)1,sizeof( struct mynulltype ), 
 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0)) ).c),(long)30,(long)1,sizeof( struct mytype ), 
 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1)) ).c),(long)1,(long)1,sizeof( struct mynulltype ), ECPGt_EORT);
diff --git a/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr b/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr
index daa7bd1..76cedd9 100644
--- a/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr
+++ b/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr
@@ -27,21 +27,21 @@
 [NO_PID]: ecpg_process_output on line 85: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 86: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' ); with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 86: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 86: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 89: action "commit"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 40: query: declare mycur cursor for select * from a1; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 40: query: declare mycur no scroll cursor for select * from a1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 40: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 40: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 49: query: fetch mycur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 49: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 49: correctly got 1 tuples with 5 fields
diff --git a/src/interfaces/ecpg/test/expected/preproc-variable.c b/src/interfaces/ecpg/test/expected/preproc-variable.c
index 7d6d0d3..63084b9 100644
--- a/src/interfaces/ecpg/test/expected/preproc-variable.c
+++ b/src/interfaces/ecpg/test/expected/preproc-variable.c
@@ -39,21 +39,21 @@ typedef char* c;
  } */
 #line 11 "variable.pgc"
 
 typedef union { int integer; short smallint; } ind;
 
 #define BUFFERSIZ 8
 /* exec sql type str is [ BUFFERSIZ ] */
 #line 15 "variable.pgc"
 
 
-/* declare cur cursor for select name , born , age , married , children from family */
+/* declare cur no scroll cursor for select name , born , age , married , children from family */
 #line 18 "variable.pgc"
 
 
 int
 main (void)
 {
 	struct birthinfo { 
 #line 23 "variable.pgc"
  long born ;
  
@@ -183,37 +183,37 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "commit");
 	{ ECPGtrans(__LINE__, NULL, "commit", 0, 0, 0, NULL);
 #line 60 "variable.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 60 "variable.pgc"
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "cur", ECPGst_normal, "declare cur cursor for select name , born , age , married , children from family", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "cur", ECPGst_normal, "declare cur no scroll cursor for select name , born , age , married , children from family", ECPGt_EOIT, ECPGt_EORT);
 #line 63 "variable.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 63 "variable.pgc"
 
 
 	/* exec sql whenever not found  break ; */
 #line 65 "variable.pgc"
 
 
 	p=&personal;
 	i=&ind_personal;
 	memset(i, 0, sizeof(ind_personal));
 	while (1) {
 		strcpy(msg, "fetch");
-		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, "cur", ECPGst_normal, "fetch cur", ECPGt_EOIT, 
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "cur", ECPGst_normal, "fetch cur", ECPGt_EOIT, 
 	ECPGt_varchar,&(p->name),(long)BUFFERSIZ,(long)-1,sizeof( struct birthinfo ), 
 	ECPGt_int,&(i->ind_name),(long)1,(long)-1,sizeof( struct birthinfo ), 
 	ECPGt_long,&(p->birth.born),(long)1,(long)1,sizeof( struct birthinfo ), 
 	ECPGt_long,&(i->ind_birth.born),(long)1,(long)1,sizeof( struct birthinfo ), 
 	ECPGt_short,&(p->birth.age),(long)1,(long)1,sizeof( struct birthinfo ), 
 	ECPGt_short,&(i->ind_birth.age),(long)1,(long)1,sizeof( struct birthinfo ), 
 	ECPGt_char,&(married),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_long,&(ind_married),(long)1,(long)1,sizeof(long), 
 	ECPGt_int,&(children.integer),(long)1,(long)1,sizeof(int), 
 	ECPGt_short,&(ind_children.smallint),(long)1,(long)1,sizeof(short), ECPGt_EORT);
diff --git a/src/interfaces/ecpg/test/expected/preproc-variable.stderr b/src/interfaces/ecpg/test/expected/preproc-variable.stderr
index 4ae072f..0757d22 100644
--- a/src/interfaces/ecpg/test/expected/preproc-variable.stderr
+++ b/src/interfaces/ecpg/test/expected/preproc-variable.stderr
@@ -39,21 +39,21 @@
 [NO_PID]: ecpg_process_output on line 56: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 57: query: insert into family ( name , age ) values ( 'Child 3' , 9 ); with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 57: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 57: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 60: action "commit"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 63: query: declare cur cursor for select name , born , age , married , children from family; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 63: query: declare cur no scroll cursor for select name , born , age , married , children from family; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 63: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 63: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 72: query: fetch cur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 72: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 72: correctly got 1 tuples with 5 fields
diff --git a/src/interfaces/ecpg/test/expected/sql-binary.c b/src/interfaces/ecpg/test/expected/sql-binary.c
index 8826cca..c1233dc 100644
--- a/src/interfaces/ecpg/test/expected/sql-binary.c
+++ b/src/interfaces/ecpg/test/expected/sql-binary.c
@@ -101,29 +101,29 @@ main (void)
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
 #line 51 "binary.pgc"
 
   if (sqlca.sqlcode)
     {
       printf ("insert error = %ld\n", sqlca.sqlcode);
       exit (sqlca.sqlcode);
     }
 
   ECPGset_var( 0, &( empl.idnum ), __LINE__);\
- /* declare C cursor for select name , accs , byte from empl where idnum = $1  */
+ /* declare C no scroll cursor for select name , accs , byte from empl where idnum = $1  */
 #line 58 "binary.pgc"
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "C", ECPGst_normal, "declare C cursor for select name , accs , byte from empl where idnum = $1 ", 
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "C", ECPGst_normal, "declare C no scroll cursor for select name , accs , byte from empl where idnum = $1 ", 
 	ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
 #line 59 "binary.pgc"
 
-  { ECPGfetch(__LINE__, 0, 1, NULL, 0, "C", ECPGst_normal, "fetch C", ECPGt_EOIT, 
+  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "C", ECPGst_normal, "fetch C", ECPGt_EOIT, 
 	ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
 #line 60 "binary.pgc"
 
   if (sqlca.sqlcode)
     {
@@ -132,29 +132,29 @@ main (void)
     }
 
   printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte);
 
   { ECPGclose(__LINE__, 0, 1, NULL, 0, "C", ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT);}
 #line 69 "binary.pgc"
 
 
   memset(empl.name, 0, 21L);
   ECPGset_var( 1, &( empl.idnum ), __LINE__);\
- /* declare B binary cursor for select name , accs , byte from empl where idnum = $1  */
+ /* declare B binary no scroll cursor for select name , accs , byte from empl where idnum = $1  */
 #line 72 "binary.pgc"
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "B", ECPGst_normal, "declare B binary cursor for select name , accs , byte from empl where idnum = $1 ", 
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "B", ECPGst_normal, "declare B binary no scroll cursor for select name , accs , byte from empl where idnum = $1 ", 
 	ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
 #line 73 "binary.pgc"
 
-  { ECPGfetch(__LINE__, 0, 1, NULL, 0, "B", ECPGst_normal, "fetch B", ECPGt_EOIT, 
+  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "B", ECPGst_normal, "fetch B", ECPGt_EOIT, 
 	ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
 #line 74 "binary.pgc"
 
   if (sqlca.sqlcode)
     {
@@ -166,29 +166,29 @@ main (void)
 #line 81 "binary.pgc"
 
 
   /* do not print a.accs because big/little endian will have different outputs here */
   printf ("name=%s, byte=", empl.name);
   for (i=0; i<4; i++)
 	printf("(%o)", (unsigned char)empl.byte[i]);
   printf("\n");
 
   ECPGset_var( 2, &( empl.idnum ), __LINE__);\
- /* declare A binary cursor for select byte from empl where idnum = $1  */
+ /* declare A binary no scroll cursor for select byte from empl where idnum = $1  */
 #line 89 "binary.pgc"
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "A", ECPGst_normal, "declare A binary cursor for select byte from empl where idnum = $1 ", 
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "A", ECPGst_normal, "declare A binary no scroll cursor for select byte from empl where idnum = $1 ", 
 	ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
 #line 90 "binary.pgc"
 
-  { ECPGfetch(__LINE__, 0, 1, NULL, 0, "A", ECPGst_normal, "fetch A", ECPGt_EOIT, 
+  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "A", ECPGst_normal, "fetch A", ECPGt_EOIT, 
 	ECPGt_char,&(pointer),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
 #line 91 "binary.pgc"
 
   if (sqlca.sqlcode)
     {
       printf ("fetch error = %ld\n", sqlca.sqlcode);
       exit (sqlca.sqlcode);
     }
 
diff --git a/src/interfaces/ecpg/test/expected/sql-binary.stderr b/src/interfaces/ecpg/test/expected/sql-binary.stderr
index fd01a0e..03495b2 100644
--- a/src/interfaces/ecpg/test/expected/sql-binary.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-binary.stderr
@@ -15,21 +15,21 @@
 [NO_PID]: ecpg_process_output on line 43: OK: CREATE TABLE
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 51: query: insert into empl values ( 1 , 'first user' , 320 , $1  ); with 1 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 51: using PQexecParams
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_free_params on line 51: parameter 1 = \001\155\000\212
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 51: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 59: query: declare C cursor for select name , accs , byte from empl where idnum = $1 ; with 1 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 59: query: declare C no scroll cursor for select name , accs , byte from empl where idnum = $1 ; with 1 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 59: using PQexecParams
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_free_params on line 59: parameter 1 = 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 59: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 60: query: fetch C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 60: using PQexec
@@ -41,21 +41,21 @@
 [NO_PID]: ecpg_get_data on line 60: RESULT: 320 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 60: RESULT: \001m\000\212 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 69: query: close C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 69: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 69: OK: CLOSE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 73: query: declare B binary cursor for select name , accs , byte from empl where idnum = $1 ; with 1 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 73: query: declare B binary no scroll cursor for select name , accs , byte from empl where idnum = $1 ; with 1 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 73: using PQexecParams
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_free_params on line 73: parameter 1 = 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 73: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 74: query: fetch B; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 74: using PQexec
@@ -67,21 +67,21 @@
 [NO_PID]: ecpg_get_data on line 74: RESULT: BINARY offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 74: RESULT: BINARY offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 81: query: close B; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 81: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 81: OK: CLOSE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 90: query: declare A binary cursor for select byte from empl where idnum = $1 ; with 1 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 90: query: declare A binary no scroll cursor for select byte from empl where idnum = $1 ; with 1 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 90: using PQexecParams
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_free_params on line 90: parameter 1 = 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 90: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 91: query: fetch A; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 91: using PQexec
diff --git a/src/interfaces/ecpg/test/expected/sql-cursorsubxact.c b/src/interfaces/ecpg/test/expected/sql-cursorsubxact.c
index c13f94c..470549b 100644
--- a/src/interfaces/ecpg/test/expected/sql-cursorsubxact.c
+++ b/src/interfaces/ecpg/test/expected/sql-cursorsubxact.c
@@ -81,25 +81,25 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	/*
 	 * Cursor name passed in a variable unquoted.
 	 * It has to be treated as case-insensitive.
 	 */
 
 	printf("test case insensitive cursor name\n\n");
 
 	curname = CURNAME;
 
 	ECPGset_var( 0, &( curname ), __LINE__);\
- /* declare $0 cursor for select id , t from t1 */
+ /* declare $0 no scroll cursor for select id , t from t1 */
 #line 39 "cursorsubxact.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, curname, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 41 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 41 "cursorsubxact.pgc"
 
 	if (sqlca.sqlcode < 0)
 		printf("open %s (case insensitive) failed with SQLSTATE %5s\n", curname, sqlca.sqlstate);
 	else
@@ -122,21 +122,21 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	/*
 	 * Cursor name passed in a variable quoted.
 	 * It has to be treated as case-sensitive.
 	 */
 
 	printf("\ntest case sensitive cursor name\n\n");
 
 	curname = QUOTED_CURNAME;
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, curname, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 64 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 64 "cursorsubxact.pgc"
 
 	if (sqlca.sqlcode < 0)
 		printf("open %s (case sensitive) failed with SQLSTATE %5s\n", curname, sqlca.sqlstate);
 	else
@@ -189,21 +189,21 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	curname = QUOTED_CURNAME;
 
 	{ ECPGtrans(__LINE__, NULL, "savepoint a", 0, 1, 0, "a");
 #line 98 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 98 "cursorsubxact.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, curname, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 100 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 100 "cursorsubxact.pgc"
 
 	if (sqlca.sqlcode < 0)
 		printf("open %s (case sensitive) failed with SQLSTATE %5s\n", curname, sqlca.sqlstate);
 	else
@@ -250,21 +250,21 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 126 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 126 "cursorsubxact.pgc"
 
 	if (sqlca.sqlcode < 0)
 		printf("\"savepoint a\" failed with SQLSTATE %5s\n", sqlca.sqlstate);
 	else
 		printf("\"savepoint a\" succeeded\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, curname, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 132 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 132 "cursorsubxact.pgc"
 
 	if (sqlca.sqlcode < 0)
 		printf("open %s (case sensitive) failed with SQLSTATE %5s\n", curname, sqlca.sqlstate);
 	else
@@ -338,21 +338,21 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	if (sqlca.sqlcode < 0)
 		printf("\"rollback to a\" failed with SQLSTATE %5s\n", sqlca.sqlstate);
 	else
 		printf("\"rollback to a\" succeeded\n");
 
 	/*
 	 * The cursor was declared under savepoint "a", was forgotten
 	 */
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, curname, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", curname, ECPGst_normal, "fetch from $0", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id[0]),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_varchar,&(t[0]),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 188 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 188 "cursorsubxact.pgc"
@@ -425,34 +425,34 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 233 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 233 "cursorsubxact.pgc"
 
 	if (sqlca.sqlcode < 0)
 		printf("\"savepoint a\" failed with SQLSTATE %5s\n", sqlca.sqlstate);
 	else
 		printf("\"savepoint a\" succeeded\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, curname, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 239 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 239 "cursorsubxact.pgc"
 
 	if (sqlca.sqlcode < 0)
 		printf("open %s (case sensitive) failed with SQLSTATE %5s\n", curname, sqlca.sqlstate);
 	else
 		printf("open %s (case sensitive) succeeded\n", curname);
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, curname, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", curname, ECPGst_normal, "fetch from $0", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id[0]),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_varchar,&(t[0]),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 245 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 245 "cursorsubxact.pgc"
@@ -470,21 +470,21 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	if (sqlca.sqlcode < 0)
 		printf("\"rollback to a\" failed with SQLSTATE %5s\n", sqlca.sqlstate);
 	else
 		printf("\"rollback to a\" succeeded\n");
 
 	/*
 	 * There's no cursor now, fails with error code 34000
 	 */
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, curname, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", curname, ECPGst_normal, "fetch from $0", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id[1]),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_varchar,&(t[1]),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 261 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 261 "cursorsubxact.pgc"
@@ -492,21 +492,21 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	if (sqlca.sqlcode < 0)
 		printf("fetch from %s (case sensitive) failed with SQLSTATE %5s (expected 34000)\n", curname, sqlca.sqlstate);
 	else
 		printf("fetch from %s (case sensitive) unexpectedly succeeded (expected 34000)\n", curname);
 
 	/*
 	 * Try to open it again, should fail because the
 	 * transaction has failed above.
 	 */
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, curname, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 272 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 272 "cursorsubxact.pgc"
 
 	if (sqlca.sqlcode < 0)
 		printf("open %s (case sensitive) failed with SQLSTATE %5s (expected 25P02)\n", curname, sqlca.sqlstate);
 	else
@@ -523,21 +523,21 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 285 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 285 "cursorsubxact.pgc"
 
 	if (sqlca.sqlcode < 0)
 		printf("\"rollback to a\" failed with SQLSTATE %5s\n", sqlca.sqlstate);
 	else
 		printf("\"rollback to a\" succeeded\n");
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, curname, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, curname, ECPGst_normal, "declare $0 no scroll cursor for select id , t from t1", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 291 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 291 "cursorsubxact.pgc"
 
 	if (sqlca.sqlcode < 0)
 		printf("open %s (case sensitive) failed with SQLSTATE %5s\n", curname, sqlca.sqlstate);
 	else
@@ -551,21 +551,21 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 301 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 301 "cursorsubxact.pgc"
 
 	if (sqlca.sqlcode < 0)
 		printf("\"savepoint a\" failed with SQLSTATE %5s\n", sqlca.sqlstate);
 	else
 		printf("\"savepoint a\" succeeded\n");
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, curname, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", curname, ECPGst_normal, "fetch from $0", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id[2]),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_varchar,&(t[2]),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 307 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 307 "cursorsubxact.pgc"
@@ -585,21 +585,21 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 319 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 319 "cursorsubxact.pgc"
 
 	if (sqlca.sqlcode < 0)
 		printf("\"rollback to a\" failed with SQLSTATE %5s\n", sqlca.sqlstate);
 	else
 		printf("\"rollback to a\" succeeded\n");
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, curname, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", curname, ECPGst_normal, "fetch from $0", 
 	ECPGt_char,&(curname),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(id[3]),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_varchar,&(t[3]),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 325 "cursorsubxact.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 325 "cursorsubxact.pgc"
diff --git a/src/interfaces/ecpg/test/expected/sql-cursorsubxact.stderr b/src/interfaces/ecpg/test/expected/sql-cursorsubxact.stderr
index cc13c59..b48379d 100644
--- a/src/interfaces/ecpg/test/expected/sql-cursorsubxact.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-cursorsubxact.stderr
@@ -9,64 +9,64 @@
 [NO_PID]: ecpg_process_output on line 26: OK: CREATE TABLE
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 27: query: insert into t1 ( t ) values ( 'a' ) , ( 'b' ) , ( 'c' ); with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 27: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 27: OK: INSERT 0 3
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 28: action "commit"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 41: query: declare MyCur cursor for select id , t from t1; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 41: query: declare MyCur no scroll cursor for select id , t from t1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 41: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 41: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 49: query: close myCur; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 49: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 49: OK: CLOSE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 64: query: declare "MyCur" cursor for select id , t from t1; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 64: query: declare "MyCur" no scroll cursor for select id , t from t1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 64: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 64: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode -231 on line 73: invalid cursorname ""myCur"" on line 73
 [NO_PID]: sqlca: code: -231, state: 34000
 SQL error: invalid cursorname ""myCur"" on line 73
 [NO_PID]: raising sqlcode -401 on line 81: current transaction is aborted, commands ignored until end of transaction block on line 81
 [NO_PID]: sqlca: code: -401, state: 25P02
 SQL error: current transaction is aborted, commands ignored until end of transaction block on line 81
 [NO_PID]: ECPGtrans on line 87: action "rollback"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 98: action "savepoint a"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 100: query: declare "MyCur" cursor for select id , t from t1; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 100: query: declare "MyCur" no scroll cursor for select id , t from t1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 100: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 100: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 110: action "rollback to a"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode -231 on line 112: invalid cursorname ""MyCur"" on line 112
 [NO_PID]: sqlca: code: -231, state: 34000
 SQL error: invalid cursorname ""MyCur"" on line 112
 [NO_PID]: ECPGtrans on line 118: action "rollback"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 126: action "savepoint a"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 132: query: declare "MyCur" cursor for select id , t from t1; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 132: query: declare "MyCur" no scroll cursor for select id , t from t1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 132: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 132: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 138: action "savepoint b"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 148: action "rollback to c"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_check_PQresult on line 148: bad response - ERROR:  no such savepoint
@@ -96,21 +96,21 @@ SQL error: invalid cursorname ""MyCur"" on line 188
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_check_PQresult on line 218: bad response - ERROR:  no such savepoint
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlstate 3B001 (sqlcode -400): no such savepoint on line 218
 [NO_PID]: sqlca: code: -400, state: 3B001
 SQL error: no such savepoint on line 218
 [NO_PID]: ECPGtrans on line 224: action "rollback"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 233: action "savepoint a"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 239: query: declare "MyCur" cursor for select id , t from t1; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 239: query: declare "MyCur" no scroll cursor for select id , t from t1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 239: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 239: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 245: query: fetch from "MyCur"; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 245: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 245: correctly got 1 tuples with 2 fields
@@ -122,21 +122,21 @@ SQL error: no such savepoint on line 218
 [NO_PID]: ECPGtrans on line 251: action "rollback to a"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: raising sqlcode -231 on line 261: invalid cursorname ""MyCur"" on line 261
 [NO_PID]: sqlca: code: -231, state: 34000
 SQL error: invalid cursorname ""MyCur"" on line 261
 [NO_PID]: raising sqlcode -401 on line 272: current transaction is aborted, commands ignored until end of transaction block on line 272
 [NO_PID]: sqlca: code: -401, state: 25P02
 SQL error: current transaction is aborted, commands ignored until end of transaction block on line 272
 [NO_PID]: ECPGtrans on line 285: action "rollback to a"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 291: query: declare "MyCur" cursor for select id , t from t1; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 291: query: declare "MyCur" no scroll cursor for select id , t from t1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 291: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 291: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 301: action "savepoint a"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 307: query: fetch from "MyCur"; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 307: using PQexec
diff --git a/src/interfaces/ecpg/test/expected/sql-desc.c b/src/interfaces/ecpg/test/expected/sql-desc.c
index f618e33..4fc1393 100644
--- a/src/interfaces/ecpg/test/expected/sql-desc.c
+++ b/src/interfaces/ecpg/test/expected/sql-desc.c
@@ -239,35 +239,35 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	{ ECPGget_desc(__LINE__, (desc1), 1,ECPGd_data,
 	ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), ECPGd_EODT);
 
 #line 55 "desc.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 55 "desc.pgc"
 
 	printf("output = %s\n", val2output);
 
-	/* declare c1 cursor for $1 */
+	/* declare c1 no scroll cursor for $1 */
 #line 58 "desc.pgc"
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "c1", ECPGst_normal, "declare c1 cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "c1", ECPGst_normal, "declare c1 no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "foo2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_descriptor, "indesc", 1L, 1L, 1L, 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 59 "desc.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 59 "desc.pgc"
 
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, "c1", ECPGst_normal, "fetch next from c1", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "c1", ECPGst_normal, "fetch next from c1", ECPGt_EOIT, 
 	ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), 
 	ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int), 
 	ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), 
 	ECPGt_int,&(ind2),(long)1,(long)1,sizeof(int), ECPGt_EORT);
 #line 61 "desc.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 61 "desc.pgc"
 
 	printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n",
@@ -289,35 +289,35 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	{ ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
 	ECPGt_const,"2",(long)1,(long)1,strlen("2"), ECPGd_EODT);
 
 #line 68 "desc.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 68 "desc.pgc"
 
 
-	/* declare c2 cursor for $1 */
+	/* declare c2 no scroll cursor for $1 */
 #line 70 "desc.pgc"
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "c2", ECPGst_normal, "declare c2 cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "c2", ECPGst_normal, "declare c2 no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "foo3", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_descriptor, "indesc", 1L, 1L, 1L, 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 71 "desc.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 71 "desc.pgc"
 
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, "c2", ECPGst_normal, "fetch next from c2", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "c2", ECPGst_normal, "fetch next from c2", ECPGt_EOIT, 
 	ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), 
 	ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT);
 #line 73 "desc.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 73 "desc.pgc"
 
 	printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
diff --git a/src/interfaces/ecpg/test/expected/sql-desc.stderr b/src/interfaces/ecpg/test/expected/sql-desc.stderr
index 6533643..b2ee131 100644
--- a/src/interfaces/ecpg/test/expected/sql-desc.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-desc.stderr
@@ -57,21 +57,21 @@
 [NO_PID]: ecpg_free_params on line 53: parameter 2 = one
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 53: correctly got 1 tuples with 2 fields
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 53: putting result (1 tuples) into descriptor outdesc
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGget_desc: reading items for tuple 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 55: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 59: query: declare c1 cursor for SELECT * from test1 where a = $1 and b = $2; with 2 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 59: query: declare c1 no scroll cursor for SELECT * from test1 where a = $1 and b = $2; with 2 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 59: using PQexecParams
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_free_params on line 59: parameter 1 = 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_free_params on line 59: parameter 2 = one
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 59: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 61: query: fetch next from c1; with 0 parameter(s) on connection regress1
@@ -83,21 +83,21 @@
 [NO_PID]: ecpg_get_data on line 61: RESULT: 1 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 61: RESULT: one offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 65: query: close c1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 65: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 65: OK: CLOSE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 71: query: declare c2 cursor for SELECT * from test1 where $1 = a; with 1 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 71: query: declare c2 no scroll cursor for SELECT * from test1 where $1 = a; with 1 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 71: using PQexecParams
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_free_params on line 71: parameter 1 = 2
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 71: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 73: query: fetch next from c2; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 73: using PQexec
diff --git a/src/interfaces/ecpg/test/expected/sql-dyntest.c b/src/interfaces/ecpg/test/expected/sql-dyntest.c
index 6ed6cfe..798e93a 100644
--- a/src/interfaces/ecpg/test/expected/sql-dyntest.c
+++ b/src/interfaces/ecpg/test/expected/sql-dyntest.c
@@ -250,36 +250,36 @@ if (sqlca.sqlcode < 0) error ( );}
 if (sqlca.sqlcode < 0) error ( );}
 #line 55 "dyntest.pgc"
 
 
   { ECPGprepare(__LINE__, NULL, 0, "myquery", QUERY);
 #line 57 "dyntest.pgc"
 
 if (sqlca.sqlcode < 0) error ( );}
 #line 57 "dyntest.pgc"
 
-  /* declare MYCURS cursor for $1 */
+  /* declare MYCURS no scroll cursor for $1 */
 #line 58 "dyntest.pgc"
 
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "MYCURS", ECPGst_normal, "declare MYCURS cursor for $1", 
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "MYCURS", ECPGst_normal, "declare MYCURS no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "myquery", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 60 "dyntest.pgc"
 
 if (sqlca.sqlcode < 0) error ( );}
 #line 60 "dyntest.pgc"
 
 
   while (1)
     {
-      { ECPGfetch(__LINE__, 0, 1, NULL, 0, "MYCURS", ECPGst_normal, "fetch in MYCURS", ECPGt_EOIT, 
+      { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "MYCURS", ECPGst_normal, "fetch in MYCURS", ECPGt_EOIT, 
 	ECPGt_descriptor, "MYDESC", 1L, 1L, 1L, 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 64 "dyntest.pgc"
 
 if (sqlca.sqlcode < 0) error ( );}
 #line 64 "dyntest.pgc"
 
 
       if (sqlca.sqlcode)
 	break;
diff --git a/src/interfaces/ecpg/test/expected/sql-dyntest.stderr b/src/interfaces/ecpg/test/expected/sql-dyntest.stderr
index 453c5bf..dd15cad 100644
--- a/src/interfaces/ecpg/test/expected/sql-dyntest.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-dyntest.stderr
@@ -21,21 +21,21 @@
 [NO_PID]: ecpg_process_output on line 54: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 55: query: insert into dyntest values ( 'second entry' , 1407.87 , 1407 , 987065403210 , false , 'The elephant never forgets.' , '1999-11-5' ); with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 55: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 55: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: prepare_common on line 57: name myquery; query: "select * from dyntest"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 60: query: declare MYCURS cursor for select * from dyntest; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 60: query: declare MYCURS no scroll cursor for select * from dyntest; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 60: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 60: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 64: query: fetch in MYCURS; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 64: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 64: correctly got 1 tuples with 7 fields
diff --git a/src/interfaces/ecpg/test/expected/sql-execute.c b/src/interfaces/ecpg/test/expected/sql-execute.c
index 326a3c3..c6c5501 100644
--- a/src/interfaces/ecpg/test/expected/sql-execute.c
+++ b/src/interfaces/ecpg/test/expected/sql-execute.c
@@ -129,33 +129,33 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 
 	sprintf (command, "select * from test");
 
 	{ ECPGprepare(__LINE__, NULL, 0, "f", command);
 #line 49 "execute.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 49 "execute.pgc"
 
-	/* declare CUR cursor for $1 */
+	/* declare CUR no scroll cursor for $1 */
 #line 50 "execute.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "CUR", ECPGst_normal, "declare CUR cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "CUR", ECPGst_normal, "declare CUR no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 52 "execute.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 52 "execute.pgc"
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, "CUR", ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "8", "CUR", ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT, 
 	ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_int,(amount),(long)1,(long)8,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 53 "execute.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 53 "execute.pgc"
@@ -194,35 +194,35 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 
 	sprintf (command, "select * from test where amount = $1");
 
 	{ ECPGprepare(__LINE__, NULL, 0, "f", command);
 #line 71 "execute.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 71 "execute.pgc"
 
-	/* declare CUR2 cursor for $1 */
+	/* declare CUR2 no scroll cursor for $1 */
 #line 72 "execute.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "CUR2", ECPGst_normal, "declare CUR2 cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "CUR2", ECPGst_normal, "declare CUR2 no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_const,"1",(long)1,(long)1,strlen("1"), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 74 "execute.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 74 "execute.pgc"
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, "CUR2", ECPGst_normal, "fetch in CUR2", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "CUR2", ECPGst_normal, "fetch in CUR2", ECPGt_EOIT, 
 	ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_int,(amount),(long)1,(long)8,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 75 "execute.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 75 "execute.pgc"
diff --git a/src/interfaces/ecpg/test/expected/sql-execute.stderr b/src/interfaces/ecpg/test/expected/sql-execute.stderr
index 83848e5..6adb523 100644
--- a/src/interfaces/ecpg/test/expected/sql-execute.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-execute.stderr
@@ -35,21 +35,21 @@
 [NO_PID]: ecpg_execute on line 41: using PQexecPrepared for "insert into test (name, amount, letter) select name, amount+$1, letter from test"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_free_params on line 41: parameter 1 = 100
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 41: OK: INSERT 0 4
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 45: action "commit"; connection "main"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: prepare_common on line 49: name f; query: "select * from test"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 52: query: declare CUR cursor for select * from test; with 0 parameter(s) on connection main
+[NO_PID]: ecpg_execute on line 52: query: declare CUR no scroll cursor for select * from test; with 0 parameter(s) on connection main
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 52: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 52: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: query: fetch 8 in CUR; with 0 parameter(s) on connection main
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 53: correctly got 8 tuples with 3 fields
@@ -105,21 +105,21 @@
 [NO_PID]: ecpg_execute on line 66: query: close CUR; with 0 parameter(s) on connection main
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 66: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 66: OK: CLOSE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: deallocate_one on line 67: name f
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: prepare_common on line 71: name f; query: "select * from test where amount = $1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 74: query: declare CUR2 cursor for select * from test where amount = $1; with 1 parameter(s) on connection main
+[NO_PID]: ecpg_execute on line 74: query: declare CUR2 no scroll cursor for select * from test where amount = $1; with 1 parameter(s) on connection main
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 74: using PQexecParams
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_free_params on line 74: parameter 1 = 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 74: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 75: query: fetch in CUR2; with 0 parameter(s) on connection main
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 75: using PQexec
diff --git a/src/interfaces/ecpg/test/expected/sql-fetch.c b/src/interfaces/ecpg/test/expected/sql-fetch.c
index 48bdaaf..6f8bcad 100644
--- a/src/interfaces/ecpg/test/expected/sql-fetch.c
+++ b/src/interfaces/ecpg/test/expected/sql-fetch.c
@@ -88,39 +88,39 @@ if (sqlca.sqlcode < 0) sqlprint();}
   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 4 , 'text4' )", ECPGt_EOIT, ECPGt_EORT);
 #line 24 "fetch.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
 #line 24 "fetch.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 24 "fetch.pgc"
 
 
-  /* declare C cursor for select * from My_Table */
+  /* declare C scroll cursor for select * from My_Table */
 #line 26 "fetch.pgc"
 
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "C", ECPGst_normal, "declare C cursor for select * from My_Table", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, "C", ECPGst_normal, "declare C scroll cursor for select * from My_Table", ECPGt_EOIT, ECPGt_EORT);
 #line 28 "fetch.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
 #line 28 "fetch.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 28 "fetch.pgc"
 
 
   /* exec sql whenever not found  break ; */
 #line 30 "fetch.pgc"
 
   while (1) {
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, "C", ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "C", ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, 
 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 32 "fetch.pgc"
 
 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
 #line 32 "fetch.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -128,31 +128,31 @@ if (sqlca.sqlwarn[0] == 'W') sqlprint();
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 32 "fetch.pgc"
 
 	printf("%d: %s\n", i, str);
   }
 
   /* exec sql whenever not found  continue ; */
 #line 36 "fetch.pgc"
 
-  { ECPGfetch(__LINE__, 0, 1, NULL, 0, "C", ECPGst_normal, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_backward, "2", "C", ECPGst_normal, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT);
 #line 37 "fetch.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
 #line 37 "fetch.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 37 "fetch.pgc"
 
 
-  { ECPGfetch(__LINE__, 0, 1, NULL, 0, "C", ECPGst_normal, "fetch $0 in C", 
+  { ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward_in_var, NULL, "C", ECPGst_normal, "fetch $0 in C", 
 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 39 "fetch.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
 #line 39 "fetch.pgc"
@@ -165,41 +165,41 @@ if (sqlca.sqlcode < 0) sqlprint();}
   { ECPGclose(__LINE__, 0, 1, NULL, 0, "C", ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT);
 #line 42 "fetch.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
 #line 42 "fetch.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 42 "fetch.pgc"
 
 
-  /* declare D cursor for select * from My_Table where Item1 = $1 */
+  /* declare D scroll cursor for select * from My_Table where Item1 = $1 */
 #line 44 "fetch.pgc"
 
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "D", ECPGst_normal, "declare D cursor for select * from My_Table where Item1 = $1", 
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_scroll, "D", ECPGst_normal, "declare D scroll cursor for select * from My_Table where Item1 = $1", 
 	ECPGt_const,"1",(long)1,(long)1,strlen("1"), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 46 "fetch.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
 #line 46 "fetch.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 46 "fetch.pgc"
 
 
   /* exec sql whenever not found  break ; */
 #line 48 "fetch.pgc"
 
   while (1) {
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, "D", ECPGst_normal, "fetch 1 in D", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "D", ECPGst_normal, "fetch 1 in D", ECPGt_EOIT, 
 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 50 "fetch.pgc"
 
 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
 #line 50 "fetch.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
diff --git a/src/interfaces/ecpg/test/expected/sql-fetch.stderr b/src/interfaces/ecpg/test/expected/sql-fetch.stderr
index d3389c5..a7c3a77 100644
--- a/src/interfaces/ecpg/test/expected/sql-fetch.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-fetch.stderr
@@ -25,21 +25,21 @@
 [NO_PID]: ecpg_execute on line 23: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 23: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 24: query: insert into My_Table values ( 4 , 'text4' ); with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 24: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 24: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 28: query: declare C cursor for select * from My_Table; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 28: query: declare C scroll cursor for select * from My_Table; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 28: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 28: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 32: query: fetch 1 in C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 32: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 32: correctly got 1 tuples with 2 fields
@@ -101,21 +101,21 @@
 [NO_PID]: ecpg_get_data on line 39: RESULT: 4 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_get_data on line 39: RESULT: text4 offset: -1; array: no
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 42: query: close C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 42: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 42: OK: CLOSE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 46: query: declare D cursor for select * from My_Table where Item1 = $1; with 1 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 46: query: declare D scroll cursor for select * from My_Table where Item1 = $1; with 1 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 46: using PQexecParams
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_free_params on line 46: parameter 1 = 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 46: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 50: query: fetch 1 in D; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 50: using PQexec
diff --git a/src/interfaces/ecpg/test/expected/sql-oldexec.c b/src/interfaces/ecpg/test/expected/sql-oldexec.c
index a3f8948..5e456a4 100644
--- a/src/interfaces/ecpg/test/expected/sql-oldexec.c
+++ b/src/interfaces/ecpg/test/expected/sql-oldexec.c
@@ -129,33 +129,33 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 
 	sprintf (command, "select * from test");
 
 	{ ECPGprepare(__LINE__, NULL, 1, "f", command);
 #line 49 "oldexec.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 49 "oldexec.pgc"
 
-	/* declare CUR cursor for $1 */
+	/* declare CUR no scroll cursor for $1 */
 #line 50 "oldexec.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 1, 0, "CUR", ECPGst_normal, "declare CUR cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 1, 0, ECPGcs_no_scroll, "CUR", ECPGst_normal, "declare CUR no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 52 "oldexec.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 52 "oldexec.pgc"
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 1, "CUR", ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 1, ECPGc_forward, "8", "CUR", ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT, 
 	ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_int,(amount),(long)1,(long)8,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 53 "oldexec.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 53 "oldexec.pgc"
@@ -188,35 +188,35 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 
 	sprintf (command, "select * from test where ? = amount");
 
 	{ ECPGprepare(__LINE__, NULL, 1, "f", command);
 #line 70 "oldexec.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 70 "oldexec.pgc"
 
-	/* declare CUR3 cursor for $1 */
+	/* declare CUR3 no scroll cursor for $1 */
 #line 71 "oldexec.pgc"
 
 
-	{ ECPGopen(__LINE__, 0, 1, NULL, 1, 0, "CUR3", ECPGst_normal, "declare CUR3 cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 1, 0, ECPGcs_no_scroll, "CUR3", ECPGst_normal, "declare CUR3 no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "f", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_const,"1",(long)1,(long)1,strlen("1"), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 73 "oldexec.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 73 "oldexec.pgc"
 
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 1, "CUR3", ECPGst_normal, "fetch in CUR3", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 1, ECPGc_forward, "1", "CUR3", ECPGst_normal, "fetch in CUR3", ECPGt_EOIT, 
 	ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_int,(amount),(long)1,(long)8,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 74 "oldexec.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 74 "oldexec.pgc"
diff --git a/src/interfaces/ecpg/test/expected/sql-oldexec.stderr b/src/interfaces/ecpg/test/expected/sql-oldexec.stderr
index bc26b96..fda8531 100644
--- a/src/interfaces/ecpg/test/expected/sql-oldexec.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-oldexec.stderr
@@ -35,21 +35,21 @@
 [NO_PID]: ecpg_execute on line 41: using PQexecPrepared for "insert into test (name, amount, letter) select name, amount+$1, letter from test"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_free_params on line 41: parameter 1 = 100
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 41: OK: INSERT 0 4
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 45: action "commit"; connection "main"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: prepare_common on line 49: name f; query: "select * from test"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 52: query: declare CUR cursor for select * from test; with 0 parameter(s) on connection main
+[NO_PID]: ecpg_execute on line 52: query: declare CUR no scroll cursor for select * from test; with 0 parameter(s) on connection main
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 52: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 52: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: query: fetch 8 in CUR; with 0 parameter(s) on connection main
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 53: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 53: correctly got 8 tuples with 3 fields
@@ -105,21 +105,21 @@
 [NO_PID]: ecpg_execute on line 66: query: close CUR; with 0 parameter(s) on connection main
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 66: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 66: OK: CLOSE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: deallocate_one on line 70: name f
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: prepare_common on line 70: name f; query: "select * from test where $1 = amount"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 73: query: declare CUR3 cursor for select * from test where $1 = amount; with 1 parameter(s) on connection main
+[NO_PID]: ecpg_execute on line 73: query: declare CUR3 no scroll cursor for select * from test where $1 = amount; with 1 parameter(s) on connection main
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 73: using PQexecParams
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_free_params on line 73: parameter 1 = 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 73: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 74: query: fetch in CUR3; with 0 parameter(s) on connection main
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 74: using PQexec
diff --git a/src/interfaces/ecpg/test/expected/sql-quote.c b/src/interfaces/ecpg/test/expected/sql-quote.c
index bfb75ca..e34f58e 100644
--- a/src/interfaces/ecpg/test/expected/sql-quote.c
+++ b/src/interfaces/ecpg/test/expected/sql-quote.c
@@ -151,41 +151,41 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
   { ECPGtrans(__LINE__, NULL, "begin", 0, 1, 0, NULL);
 #line 42 "quote.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
 #line 42 "quote.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 42 "quote.pgc"
 
-  /* declare C cursor for select * from \"My_Table\" */
+  /* declare C no scroll cursor for select * from \"My_Table\" */
 #line 43 "quote.pgc"
 
 
-  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "C", ECPGst_normal, "declare C cursor for select * from \"My_Table\"", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "C", ECPGst_normal, "declare C no scroll cursor for select * from \"My_Table\"", ECPGt_EOIT, ECPGt_EORT);
 #line 45 "quote.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
 #line 45 "quote.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 45 "quote.pgc"
 
 
   /* exec sql whenever not found  break ; */
 #line 47 "quote.pgc"
 
 
   while (true)
   {
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, "C", ECPGst_normal, "fetch C", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "C", ECPGst_normal, "fetch C", ECPGt_EOIT, 
 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 	ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 51 "quote.pgc"
 
 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
 #line 51 "quote.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
diff --git a/src/interfaces/ecpg/test/expected/sql-quote.stderr b/src/interfaces/ecpg/test/expected/sql-quote.stderr
index 8e2db6a..e867377 100644
--- a/src/interfaces/ecpg/test/expected/sql-quote.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-quote.stderr
@@ -62,21 +62,21 @@ SQL error: nonstandard use of \\ in a string literal
 [NO_PID]: ecpg_process_output on line 38: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 40: query: insert into "My_Table" values ( 2 , E'a\\\\b' ); with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 40: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 40: OK: INSERT 0 1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 42: action "begin"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 45: query: declare C cursor for select * from "My_Table"; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 45: query: declare C no scroll cursor for select * from "My_Table"; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 45: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 45: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 51: query: fetch C; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 51: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 51: correctly got 1 tuples with 2 fields
diff --git a/src/interfaces/ecpg/test/expected/sql-sqlda.c b/src/interfaces/ecpg/test/expected/sql-sqlda.c
index 83804f5..277c14e 100644
--- a/src/interfaces/ecpg/test/expected/sql-sqlda.c
+++ b/src/interfaces/ecpg/test/expected/sql-sqlda.c
@@ -239,43 +239,43 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "prepare");
 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
 #line 97 "sqlda.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 97 "sqlda.pgc"
 
 
 	strcpy(msg, "declare");
-	/* declare mycur1 cursor for $1 */
+	/* declare mycur1 no scroll cursor for $1 */
 #line 100 "sqlda.pgc"
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "mycur1", ECPGst_normal, "declare mycur1 cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "mycur1", ECPGst_normal, "declare mycur1 no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 103 "sqlda.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 103 "sqlda.pgc"
 
 
 	/* exec sql whenever not found  break ; */
 #line 105 "sqlda.pgc"
 
 
 	rec = 0;
 	while (1)
 	{
 		strcpy(msg, "fetch");
-		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, "mycur1", ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
+		{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "1", "mycur1", ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 111 "sqlda.pgc"
 
 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
 #line 111 "sqlda.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 111 "sqlda.pgc"
 
@@ -312,36 +312,36 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "prepare");
 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
 #line 132 "sqlda.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 132 "sqlda.pgc"
 
 
 	strcpy(msg, "declare");
-	/* declare mycur2 cursor for $1 */
+	/* declare mycur2 no scroll cursor for $1 */
 #line 135 "sqlda.pgc"
 
 
 	strcpy(msg, "open");
-	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, "mycur2", ECPGst_normal, "declare mycur2 cursor for $1", 
+	{ ECPGopen(__LINE__, 0, 1, NULL, 0, 0, ECPGcs_no_scroll, "mycur2", ECPGst_normal, "declare mycur2 no scroll cursor for $1", 
 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 138 "sqlda.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 138 "sqlda.pgc"
 
 
 	strcpy(msg, "fetch");
-	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, "mycur2", ECPGst_normal, "fetch all from mycur2", ECPGt_EOIT, 
+	{ ECPGfetch(__LINE__, 0, 1, NULL, 0, ECPGc_forward, "all", "mycur2", ECPGst_normal, "fetch all from mycur2", ECPGt_EOIT, 
 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 #line 141 "sqlda.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
 #line 141 "sqlda.pgc"
 
 
 	outp_sqlda1 = outp_sqlda;
 	rec = 0;
diff --git a/src/interfaces/ecpg/test/expected/sql-sqlda.stderr b/src/interfaces/ecpg/test/expected/sql-sqlda.stderr
index 9eb54f2..6ed6605 100644
--- a/src/interfaces/ecpg/test/expected/sql-sqlda.stderr
+++ b/src/interfaces/ecpg/test/expected/sql-sqlda.stderr
@@ -17,21 +17,21 @@
 [NO_PID]: ecpg_execute on line 84: query: insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 4 , 'd' , 4.0 , 4 , 'd' ); with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 84: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 84: OK: INSERT 0 3
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGtrans on line 90: action "commit"; connection "regress1"
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: prepare_common on line 97: name st_id1; query: "SELECT * FROM t1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 103: query: declare mycur1 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 103: query: declare mycur1 no scroll cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 103: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 103: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 111: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 111: correctly got 1 tuples with 5 fields
@@ -125,21 +125,21 @@
 [NO_PID]: ecpg_execute on line 120: query: close mycur1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 120: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 120: OK: CLOSE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: deallocate_one on line 123: name st_id1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: prepare_common on line 132: name st_id2; query: "SELECT * FROM t1"
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 138: query: declare mycur2 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+[NO_PID]: ecpg_execute on line 138: query: declare mycur2 no scroll cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 138: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 138: OK: DECLARE CURSOR
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 141: query: fetch all from mycur2; with 0 parameter(s) on connection regress1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_execute on line 141: using PQexec
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_process_output on line 141: correctly got 3 tuples with 5 fields
diff --git a/src/interfaces/ecpg/test/sql/fetch.pgc b/src/interfaces/ecpg/test/sql/fetch.pgc
index aade678..a07c143 100644
--- a/src/interfaces/ecpg/test/sql/fetch.pgc
+++ b/src/interfaces/ecpg/test/sql/fetch.pgc
@@ -16,39 +16,39 @@ int main() {
   EXEC SQL WHENEVER SQLWARNING SQLPRINT;
   EXEC SQL WHENEVER SQLERROR SQLPRINT;
 
   EXEC SQL CREATE TABLE My_Table ( Item1 int, Item2 text );
 
   EXEC SQL INSERT INTO My_Table VALUES ( 1, 'text1');
   EXEC SQL INSERT INTO My_Table VALUES ( 2, 'text2');
   EXEC SQL INSERT INTO My_Table VALUES ( 3, 'text3');
   EXEC SQL INSERT INTO My_Table VALUES ( 4, 'text4');
 
-  EXEC SQL DECLARE C CURSOR FOR SELECT * FROM My_Table;
+  EXEC SQL DECLARE C SCROLL CURSOR FOR SELECT * FROM My_Table;
 
   EXEC SQL OPEN C;
 
   EXEC SQL WHENEVER NOT FOUND DO BREAK;
   while (1) {
 	EXEC SQL FETCH 1 IN C INTO :i, :str;
 	printf("%d: %s\n", i, str);
   }
 
   EXEC SQL WHENEVER NOT FOUND CONTINUE;
   EXEC SQL MOVE BACKWARD 2 IN C;
 
   EXEC SQL FETCH :count IN C INTO :i, :str;
   printf("%d: %s\n", i, str);
 
   EXEC SQL CLOSE C;
 
-  EXEC SQL DECLARE D CURSOR FOR SELECT * FROM My_Table WHERE Item1 = $1;
+  EXEC SQL DECLARE D SCROLL CURSOR FOR SELECT * FROM My_Table WHERE Item1 = $1;
 
   EXEC SQL OPEN D using 1;
 
   EXEC SQL WHENEVER NOT FOUND DO BREAK;
   while (1) {
 	EXEC SQL FETCH 1 IN D INTO :i, :str;
 	printf("%d: %s\n", i, str);
   }
   EXEC SQL CLOSE D;
 
