diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml
index b8021cb..f882d83 100644
--- a/doc/src/sgml/ecpg.sgml
+++ b/doc/src/sgml/ecpg.sgml
@@ -6683,6 +6683,107 @@ EXEC SQL DECLARE cur1 CURSOR FOR stmt1;
    </refsect1>
   </refentry>
 
+  <refentry id="ecpg-sql-declare-statement">
+   <refnamediv>
+    <refname>DECLARE STATEMENT</refname>
+    <refpurpose>declares SQL statement identifier associated with connection</refpurpose>
+   </refnamediv>
+
+   <refsynopsisdiv>
+<synopsis>
+EXEC SQL [ AT connection_name ] DECLARE <replaceable class="PARAMETER">statement_name</replaceable> STATEMENT
+</synopsis>
+   </refsynopsisdiv>
+
+   <refsect1>
+    <title>Description</title>
+
+    <para>
+     <command>DECLARE STATEMENT</command> declares SQL statement identifier.
+     SQL statement identifier is associated with connection.
+    </para>
+
+    <para>
+     <command>DELARE CURSOR</command> with a SQL statement identifier can be written before PREPARE.
+    </para>
+   </refsect1>
+
+   <refsect1>
+    <title>Parameters</title>
+
+    <variablelist>
+     <varlistentry>
+      <term><replaceable class="PARAMETER">connection_name</replaceable></term>
+      <listitem>
+       <para>
+        A database connection name established by the <command>CONNECT</command> command.
+       </para>
+       <para>
+        If AT clause is omitted, an SQL statement identifier is associated with the DEFAULT connection.   
+       </para>
+      </listitem>
+     </varlistentry>
+    </variablelist>
+
+    <variablelist>
+     <varlistentry>
+      <term><replaceable class="PARAMETER">statement_name</replaceable></term>
+      <listitem>
+       <para>
+        The name of a SQL statement identifier, either as an SQL identifier or a host variable.
+       </para>
+      </listitem>
+     </varlistentry>
+    </variablelist>
+   </refsect1>
+
+   <refsect1>
+    <title>Notes</title>
+    
+    <para>
+     An SQL statement with a SQL statement identifier must use a same connection 
+     as the connection that the SQL statement identifier is associated with.
+    </para>
+     
+    <para>
+     AT clause cannot be used with the SQL statement which have been identified by <command>DECLARE STATEMENT</command>
+    </para>
+   </refsect1>
+
+   <refsect1>
+    <title>Examples</title>
+
+<programlisting>
+EXEC SQL CONNECT TO postgres AS con1;
+EXEC SQL AT con1 DECLARE sql_stmt STATEMENT;
+EXEC SQL DECLARE cursor_name CURSOR FOR sql_stmt;
+EXEC SQL PREPARE sql_stmt FROM :dyn_string;
+EXEC SQL OPEN cursor_name;
+EXEC SQL FETCH cursor_name INTO :column1;
+EXEC SQL CLOSE cursor_name;
+</programlisting>
+   </refsect1>
+
+   <refsect1>
+    <title>Compatibility</title>
+
+    <para>
+     <command>DECLARE STATEMENT</command> is a PostgreSQL extension of the SQL standard,
+     but can be used in Oracle and DB2.
+    </para>
+   </refsect1>
+
+   <refsect1>
+    <title>See Also</title>
+
+    <simplelist type="inline">
+     <member><xref linkend="ecpg-sql-connect"></member>
+     <member><xref linkend="ecpg-sql-declare"></member>
+     <member><xref linkend="ecpg-sql-open"></member>
+    </simplelist>
+   </refsect1>
+  </refentry>
+
   <refentry id="ecpg-sql-describe">
    <refnamediv>
     <refname>DESCRIBE</refname>
diff --git a/src/interfaces/ecpg/ecpglib/Makefile b/src/interfaces/ecpg/ecpglib/Makefile
index fbb1407..132e53a 100644
--- a/src/interfaces/ecpg/ecpglib/Makefile
+++ b/src/interfaces/ecpg/ecpglib/Makefile
@@ -26,7 +26,7 @@ override CFLAGS += $(PTHREAD_CFLAGS)
 LIBS := $(filter-out -lpgport, $(LIBS))
 
 OBJS= execute.o typename.o descriptor.o sqlda.o data.o error.o prepare.o memory.o \
-	connect.o misc.o path.o pgstrcasecmp.o \
+	connect.o misc.o path.o pgstrcasecmp.o cursor.o \
 	$(filter snprintf.o strlcpy.o win32setlocale.o isinf.o, $(LIBOBJS)) $(WIN32RES)
 
 # thread.c is needed only for non-WIN32 implementation of path.c
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c
index c90f13d..ddbc08c 100644
--- a/src/interfaces/ecpg/ecpglib/connect.c
+++ b/src/interfaces/ecpg/ecpglib/connect.c
@@ -340,6 +340,8 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
 		return false;
 	}
 
+	memset(this, 0, sizeof(struct connection));
+
 	if (dbname != NULL)
 	{
 		/* get the detail information from dbname */
@@ -684,12 +686,15 @@ ECPGdisconnect(int lineno, const char *connection_name)
 
 	if (strcmp(connection_name, "ALL") == 0)
 	{
+		struct connection *f = NULL;
+
 		ecpg_init_sqlca(sqlca);
 		for (con = all_connections; con;)
 		{
-			struct connection *f = con;
+			f = con;
 
 			con = con->next;
+			ecpg_release_declared_statement(f->name);
 			ecpg_finish(f);
 		}
 	}
@@ -705,7 +710,10 @@ ECPGdisconnect(int lineno, const char *connection_name)
 			return (false);
 		}
 		else
+		{
+			ecpg_release_declared_statement(connection_name);
 			ecpg_finish(con);
+		}
 	}
 
 #ifdef ENABLE_THREAD_SAFETY
diff --git a/src/interfaces/ecpg/ecpglib/cursor.c b/src/interfaces/ecpg/ecpglib/cursor.c
new file mode 100644
index 0000000..2188827
--- /dev/null
+++ b/src/interfaces/ecpg/ecpglib/cursor.c
@@ -0,0 +1,265 @@
+/* src/interfaces/ecpg/ecpglib/cursor.c */
+
+#define POSTGRES_ECPG_INTERNAL
+#include "postgres_fe.h"
+
+#include <ctype.h>
+#include <locale.h>
+#include <string.h>
+
+#include "ecpgtype.h"
+#include "ecpglib.h"
+#include "ecpgerrno.h"
+#include "extern.h"
+#include "sqlca.h"
+
+static void add_cursor(const int, const char *, const char *);
+static void remove_cursor(const char *, struct connection *);
+static bool find_cursor(const char *, const struct connection *);
+
+/***
+ *	Function: Handle the EXEC SQL OPEN cursor statement:
+ *	Input:
+ *		cursor_name --- cursor name
+ *		prepared_name --- prepared name
+ *		others --- keep same as the parameters in ECPGdo() function
+ **/
+bool
+ECPGopen(const char *cursor_name,const char *prepared_name,
+		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;
+	bool		status;
+	const char	*real_connection_name = NULL;
+
+	if (!query)
+	{
+		ecpg_raise(lineno, ECPG_EMPTY, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL);
+		return (false);
+	}
+
+	/****
+	 * If the declared name is referred by the PREPARE statement then the
+	 * prepared_name is same as declared name
+	 * */
+	real_connection_name = ecpg_get_con_name_by_declared_name(prepared_name);
+	if(real_connection_name)
+	{
+		/* Add the cursor name into the declared node */
+		ecpg_update_declare_statement(prepared_name, cursor_name, lineno);
+	}
+	else
+	{
+		/****
+		 * If can't get the connection name by declared name then using connection name
+		 * coming from the parameter connection_name
+		 * */
+		real_connection_name = connection_name;
+	}
+
+
+	/* Add the cursor into the connection */
+	add_cursor(lineno, cursor_name, real_connection_name);
+
+	va_start(args, query);
+
+	status = ecpg_do(lineno, compat, force_indicator, real_connection_name, questionmarks, st, query, args);
+
+	va_end(args);
+
+	return (status);
+}
+
+
+/***
+ *	Function: Handle the EXEC SQL FETCH/MOVE CURSOR statements:
+ *	Input:
+ *		cursor_name --- cursor name
+ *		others --- keep same as the parameters in ECPGdo() function
+ **/
+bool
+ECPGfetch(const char *cursor_name,
+		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;
+	bool		status;
+	const char	*real_connection_name = NULL;
+
+	if (!query)
+	{
+		ecpg_raise(lineno, ECPG_EMPTY, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL);
+		return (false);
+	}
+
+	real_connection_name = ecpg_get_con_name_by_cursor_name(cursor_name);
+	if(real_connection_name == NULL)
+	{
+		/****
+		 * If can't get the connection name by cursor name then using connection name
+		 * coming from the parameter connection_name
+		 * */
+		real_connection_name = connection_name;
+	}
+
+	va_start(args, query);
+
+	status = ecpg_do(lineno, compat, force_indicator, real_connection_name, questionmarks, st, query, args);
+
+	va_end(args);
+
+	return (status);
+}
+
+
+/***
+ *	Function: Handle the EXEC SQL CLOSE CURSOR statements:
+ *	Input:
+ *		cursor_name --- cursor name
+ *		others --- keep same as the parameters in ECPGdo() function
+ **/
+bool
+ECPGclose(const char *cursor_name,
+		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;
+	bool		status;
+	const char	*real_connection_name = NULL;
+	struct connection *con = NULL;
+
+	if (!query)
+	{
+		ecpg_raise(lineno, ECPG_EMPTY, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL);
+		return (false);
+	}
+
+	real_connection_name = ecpg_get_con_name_by_cursor_name(cursor_name);
+	if(real_connection_name == NULL)
+	{
+		/****
+		 * If can't get the connection name by cursor name then using connection name
+		 * coming from the parameter connection_name
+		 * */
+		real_connection_name = connection_name;
+	}
+
+	con = ecpg_get_connection(real_connection_name);
+
+	/* check the existence of the cursor in the connection */
+	if(false == find_cursor(cursor_name, con))
+	{
+		ecpg_raise(lineno, ECPG_INVALID_CURSOR, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL);
+		return false;
+	}
+
+	va_start(args, query);
+
+	status = ecpg_do(lineno, compat, force_indicator, real_connection_name, questionmarks, st, query, args);
+
+	va_end(args);
+
+	remove_cursor(cursor_name, con);
+
+	return (status);
+}
+
+/***
+ * Function: Add a cursor into the connection
+ */
+static void
+add_cursor(const int lineno, const char *cursor_name, const char *connection_name)
+{
+	struct connection *con;
+	struct cursor_statement *new = NULL;
+
+	if(!cursor_name)
+		return ;
+
+	con = ecpg_get_connection(connection_name);
+	if (!con)
+	{
+		return;
+	}
+
+	if(find_cursor(cursor_name, con))
+	{
+		/* Should never goto here, because ECPG has checked the duplication of
+		 * the cursor in pre-compile stage.
+		 */
+		return;
+	}
+
+	/* allocate a node to store the new cursor */
+	new = (struct cursor_statement *)ecpg_alloc(sizeof(struct cursor_statement), lineno);
+	if(new)
+	{
+		new->name = ecpg_strdup(cursor_name, lineno);
+		new->next = con->cursor_stmts;
+		con->cursor_stmts = new;
+	}
+}
+
+/***
+ * Function: Remove the cursor from the connection
+ */
+static void
+remove_cursor(const char *cursor_name, struct connection *connection)
+{
+	struct cursor_statement *cur = NULL;
+	struct cursor_statement *prev = NULL;
+
+	if(!connection || !cursor_name)
+		return ;
+
+	cur = connection->cursor_stmts;
+	while(cur)
+	{
+		if(strcmp(cur->name, cursor_name) == 0)
+		{
+			if(!prev)
+			{
+				connection->cursor_stmts = cur->next;
+			}
+			else
+			{
+				prev->next = cur->next;
+			}
+
+			ecpg_free(cur->name);
+			ecpg_free(cur);
+
+			break;
+		}
+		prev = cur;
+		cur = cur->next;
+	}
+}
+
+/***
+ * Function: Find whether the cursor is existence in the connection or not
+ * Return: true ---Found
+ *		   false --- Not found
+ */
+static bool
+find_cursor(const char *cursor_name, const struct connection *connection)
+{
+	struct cursor_statement *cur = NULL;
+
+	if(!connection || !cursor_name)
+		return false;
+
+	for(cur = connection->cursor_stmts; cur != NULL; cur = cur->next)
+	{
+		if(strcmp(cur->name, cursor_name) == 0)
+		{
+			return true;
+		}
+	}
+
+	return false;
+}
diff --git a/src/interfaces/ecpg/ecpglib/descriptor.c b/src/interfaces/ecpg/ecpglib/descriptor.c
index 15fd7a0..a1665c8 100644
--- a/src/interfaces/ecpg/ecpglib/descriptor.c
+++ b/src/interfaces/ecpg/ecpglib/descriptor.c
@@ -818,6 +818,7 @@ ECPGdescribe(int line, int compat, bool input, const char *connection_name, cons
 	struct prepared_statement *prep;
 	PGresult   *res;
 	va_list		args;
+	const char *real_connection_name = NULL;
 
 	/* DESCRIBE INPUT is not yet supported */
 	if (input)
@@ -826,13 +827,21 @@ ECPGdescribe(int line, int compat, bool input, const char *connection_name, cons
 		return ret;
 	}
 
-	con = ecpg_get_connection(connection_name);
-	if (!con)
+	real_connection_name = ecpg_get_con_name_by_declared_name(stmt_name);
+	if (real_connection_name == NULL)
 	{
-		ecpg_raise(line, ECPG_NO_CONN, ECPG_SQLSTATE_CONNECTION_DOES_NOT_EXIST,
-				   connection_name ? connection_name : ecpg_gettext("NULL"));
-		return ret;
+		/***
+		 * If can't get the connection name by declared name then using connection name
+		 * coming from the parameter connection_name
+		 * */
+		real_connection_name = connection_name;
+
 	}
+
+	con = ecpg_get_connection(real_connection_name);
+	if (!ecpg_init(con, real_connection_name, line))
+		return false;
+
 	prep = ecpg_find_prepared_statement(stmt_name, con, NULL);
 	if (!prep)
 	{
diff --git a/src/interfaces/ecpg/ecpglib/error.c b/src/interfaces/ecpg/ecpglib/error.c
index 656b2c4..11a1a7c 100644
--- a/src/interfaces/ecpg/ecpglib/error.c
+++ b/src/interfaces/ecpg/ecpglib/error.c
@@ -200,6 +200,13 @@ ecpg_raise(int line, int code, const char *sqlstate, const char *str)
 					 ecpg_gettext("could not connect to database \"%s\" on line %d"), str, line);
 			break;
 
+		case ECPG_INVALID_CURSOR:
+			 snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
+			/*------
+				translator: this string will be truncated at 149 characters expanded.  */
+				ecpg_gettext("The cursor is invalid on line %d"),line);
+			break;
+
 		default:
 			snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
 			/*------
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index a3ae92e..b7646fd 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -2032,9 +2032,31 @@ ECPGdo(const int lineno, const int compat, const int force_indicator, const char
 {
 	va_list		args;
 	bool		ret;
+	const char  *real_connection_name = NULL;
+
+	real_connection_name = connection_name;
+
+	if (!query)	{
+		ecpg_raise(lineno, ECPG_EMPTY, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, NULL);
+		return (false);
+	}
+
+	/* Handle the EXEC SQL EXECUTE... statement */
+	if(ECPGst_execute == st)
+	{
+		real_connection_name = ecpg_get_con_name_by_declared_name(query);
+		if(real_connection_name == NULL)
+		{
+			/****
+			* If can't get the connection name by declared name then using connection name
+			* coming from the parameter connection_name
+			* */
+			real_connection_name = connection_name;
+		 }
+	}
 
 	va_start(args, query);
-	ret = ecpg_do(lineno, compat, force_indicator, connection_name,
+	ret = ecpg_do(lineno, compat, force_indicator, real_connection_name,
 				  questionmarks, st, query, args);
 	va_end(args);
 
diff --git a/src/interfaces/ecpg/ecpglib/exports.txt b/src/interfaces/ecpg/ecpglib/exports.txt
index 69e9617..f39212c 100644
--- a/src/interfaces/ecpg/ecpglib/exports.txt
+++ b/src/interfaces/ecpg/ecpglib/exports.txt
@@ -25,7 +25,11 @@ ECPGsetconn                      22
 ECPGstatus                       23
 ECPGtrans                        24
 sqlprint                         25
-ECPGget_PGconn			 26
-ECPGtransactionStatus		 27
-ECPGset_var			 28
-ECPGget_var			 29
+ECPGget_PGconn		        	 26
+ECPGtransactionStatus		     27
+ECPGset_var			             28
+ECPGget_var			             29
+ECPGdeclare                      30
+ECPGopen                         31
+ECPGfetch                        32
+ECPGclose                        33
diff --git a/src/interfaces/ecpg/ecpglib/extern.h b/src/interfaces/ecpg/ecpglib/extern.h
index c3082be..20bea1d 100644
--- a/src/interfaces/ecpg/ecpglib/extern.h
+++ b/src/interfaces/ecpg/ecpglib/extern.h
@@ -66,6 +66,15 @@ struct statement
 	PGresult   *results;
 };
 
+/* structure to store declared statements */
+struct declared_statement
+{
+	char	   *name; /* declare name */
+	char		*connection_name;
+	char		*cursor_name;
+	struct declared_statement *next;
+};
+
 /* structure to store prepared statements for a connection */
 struct prepared_statement
 {
@@ -75,6 +84,12 @@ struct prepared_statement
 	struct prepared_statement *next;
 };
 
+struct cursor_statement
+{
+	char	   *name; /*cursor name*/
+	struct cursor_statement *next;
+};
+
 /* structure to store connections */
 struct connection
 {
@@ -83,6 +98,7 @@ struct connection
 	bool		autocommit;
 	struct ECPGtype_information_cache *cache_head;
 	struct prepared_statement *prep_stmts;
+	struct cursor_statement *cursor_stmts;
 	struct connection *next;
 };
 
@@ -165,6 +181,11 @@ struct descriptor *ecpg_find_desc(int line, const char *name);
 struct prepared_statement *ecpg_find_prepared_statement(const char *,
 						  struct connection *, struct prepared_statement **);
 
+void ecpg_update_declare_statement(const char *, const char *, const int);
+char *ecpg_get_con_name_by_declared_name(const char *);
+const char *ecpg_get_con_name_by_cursor_name(const char *);
+void ecpg_release_declared_statement(const char *);
+
 bool ecpg_store_result(const PGresult *results, int act_field,
 				  const struct statement * stmt, struct variable * var);
 bool		ecpg_store_input(const int, const bool, const struct variable *, char **, bool);
@@ -220,4 +241,4 @@ void		ecpg_set_native_sqlda(int, struct sqlda_struct **, const PGresult *, int,
 #define ECPG_SQLSTATE_ECPG_INTERNAL_ERROR	"YE000"
 #define ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY	"YE001"
 
-#endif   /* _ECPG_LIB_EXTERN_H */
+#endif	 /* _ECPG_LIB_EXTERN_H */
diff --git a/src/interfaces/ecpg/ecpglib/prepare.c b/src/interfaces/ecpg/ecpglib/prepare.c
index 983b242..530883f 100644
--- a/src/interfaces/ecpg/ecpglib/prepare.c
+++ b/src/interfaces/ecpg/ecpglib/prepare.c
@@ -26,9 +26,11 @@ static int	nextStmtID = 1;
 static const int stmtCacheNBuckets = 2039;		/* # buckets - a prime # */
 static const int stmtCacheEntPerBucket = 8;		/* # entries/bucket		*/
 static stmtCacheEntry stmtCacheEntries[16384] = {{0, {0}, 0, 0, 0}};
+static struct declared_statement *g_declared_list;
 
 static bool deallocate_one(int lineno, enum COMPAT_MODE c, struct connection * con,
 		 struct prepared_statement * prev, struct prepared_statement * this);
+static struct declared_statement *ecpg_find_declared_statement(const char *);
 
 static bool
 isvarchar(unsigned char c)
@@ -117,6 +119,7 @@ prepare_common(int lineno, struct connection * con, const char *name, const char
 		ecpg_free(this);
 		return false;
 	}
+	memset(stmt,0,sizeof(struct statement));
 
 	/* create statement */
 	stmt->lineno = lineno;
@@ -163,11 +166,22 @@ ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, c
 	struct connection *con;
 	struct prepared_statement *this,
 			   *prev;
+	const char *real_connection_name = NULL;
 
 	(void) questionmarks;		/* quiet the compiler */
-	con = ecpg_get_connection(connection_name);
 
-	if (!ecpg_init(con, connection_name, lineno))
+	real_connection_name = ecpg_get_con_name_by_declared_name(name);
+	if(real_connection_name == NULL)
+	{
+		/****
+		 * If can't get the connection name by declared name then using connection name
+		 * coming from the parameter connection_name
+		 * */
+		real_connection_name = connection_name;
+	}
+
+	con = ecpg_get_connection(real_connection_name);
+	if (!ecpg_init(con, real_connection_name, lineno))
 		return false;
 
 	/* check if we already have prepared this statement */
@@ -255,9 +269,19 @@ ECPGdeallocate(int lineno, int c, const char *connection_name, const char *name)
 	struct connection *con;
 	struct prepared_statement *this,
 			   *prev;
+	const char *real_connection_name = NULL;
 
-	con = ecpg_get_connection(connection_name);
+	real_connection_name = ecpg_get_con_name_by_declared_name(name);
+	if(real_connection_name == NULL)
+	{
+		/****
+		 * If can't get the connection name by declared name then using connection name
+		 * coming from the parameter connection_name
+		 * */
+		real_connection_name = connection_name;
+	}
 
+	con = ecpg_get_connection(real_connection_name);
 	if (!ecpg_init(con, connection_name, lineno))
 		return false;
 
@@ -305,8 +329,21 @@ ecpg_prepared(const char *name, struct connection * con)
 char *
 ECPGprepared_statement(const char *connection_name, const char *name, int lineno)
 {
+	const char *real_connection_name = NULL;
+
 	(void) lineno;				/* keep the compiler quiet */
-	return ecpg_prepared(name, ecpg_get_connection(connection_name));
+
+	real_connection_name = ecpg_get_con_name_by_declared_name(name);
+	if(real_connection_name == NULL)
+	{
+		/****
+		 * If can't get the connection name by declared name then using connection name
+		 * coming from the parameter connection_name
+		 * */
+		real_connection_name = connection_name;
+	}
+
+	return ecpg_prepared(name, ecpg_get_connection(real_connection_name));
 }
 
 /*
@@ -324,7 +361,7 @@ HashStmt(const char *ecpgQuery)
 
 	stmtLeng = strlen(ecpgQuery);
 	hashLeng = 50;				/* use 1st 50 characters of statement		*/
-	if (hashLeng > stmtLeng)	/* if the statement isn't that long         */
+	if (hashLeng > stmtLeng)	/* if the statement isn't that long			*/
 		hashLeng = stmtLeng;	/* use its actual length			   */
 
 	hashVal = 0;
@@ -337,7 +374,7 @@ HashStmt(const char *ecpgQuery)
 	}
 
 	bucketNo = hashVal % stmtCacheNBuckets;
-	bucketNo += 1;				/* don't use bucket # 0         */
+	bucketNo += 1;				/* don't use bucket # 0			*/
 
 	return (bucketNo * stmtCacheEntPerBucket);
 }
@@ -367,7 +404,7 @@ SearchStmtCache(const char *ecpgQuery)
 		++entNo;				/* incr entry #		*/
 	}
 
-/* if entry wasn't found - set entry # to zero  */
+/* if entry wasn't found - set entry # to zero	*/
 	if (entIx >= stmtCacheEntPerBucket)
 		entNo = 0;
 
@@ -388,7 +425,7 @@ ecpg_freeStmtCacheEntry(int lineno, int compat, int entNo)		/* entry # to free *
 			   *prev;
 
 	entry = &stmtCacheEntries[entNo];
-	if (!entry->stmtID[0])		/* return if the entry isn't in use     */
+	if (!entry->stmtID[0])		/* return if the entry isn't in use		*/
 		return (0);
 
 	con = ecpg_get_connection(entry->connection);
@@ -513,3 +550,215 @@ ecpg_auto_prepare(int lineno, const char *connection_name, const int compat, cha
 
 	return (true);
 }
+
+/***
+ * Function: handle the EXEC SQL DECLARE STATEMENT
+ * Input: connection_name -- connection name
+ *		  name -- declare name
+ */
+bool
+ECPGdeclare(int lineno, const char *connection_name, const char *name)
+{
+	struct connection *con = NULL;
+	struct declared_statement *p = NULL;
+
+	if(name == NULL)
+	{
+		/* Should never go to here because ECPG pre-compiler will check it */
+		return false;
+	}
+
+	if(connection_name == NULL)
+	{
+		/***
+		 * Going to here means without using AT clause in the DECLARE STATEMENT
+		 * We don't allocate a node to store the declared name because the
+		 * DECLARE STATEMENT without using AT clause will be ignored.
+		 */
+		return true;
+	}
+
+	con = ecpg_get_connection(connection_name);
+	if (!ecpg_init(con, connection_name, lineno))
+		return false;
+
+	if(ecpg_find_declared_statement(name))
+	{
+		/* Should not go to here because the pre-compiler has check the duplicate name */
+		return false;
+	}
+
+	/* allocate a declared_statement as a new node */
+	p = (struct declared_statement *) ecpg_alloc(sizeof(struct declared_statement), lineno);
+	if (!p)
+	{
+		return false;
+	}
+
+	memset(p,0,sizeof(struct declared_statement));
+
+	ecpg_log("ECPGdeclare on line %d: declared name %s on connection: \"%s\"\n", lineno, name, connection_name);
+
+	p->name = ecpg_strdup(name, lineno);
+	p->connection_name = ecpg_strdup(connection_name, lineno);
+
+	/* Add the new node into the g_declared_list */
+	if(g_declared_list != NULL)
+	{
+		p->next = g_declared_list;
+		g_declared_list = p;
+	}
+	else
+	{
+		g_declared_list = p;
+	}
+
+	return true;
+}
+
+/***
+ * Function: Find a declare node by declared name
+ * Input: name -- declared name
+ * Return: Found -- The pointer points to the declared node
+ *		   Not found -- NULL
+ */
+static struct declared_statement *
+ecpg_find_declared_statement(const char *name)
+{
+	struct declared_statement *p;
+
+	if(name == NULL)
+	{
+		return NULL;
+	}
+
+	p = g_declared_list;
+	while(p)
+	{
+		if (strcmp(p->name, name) == 0)
+		{
+			return p;
+		}
+		p = p->next;
+	}
+
+	return NULL;
+}
+
+/***
+ * Function: Build the relationship between the declared name and cursor name
+ * Input: declared_name -- the name declared in the DECLARE STATEMENT
+ *		  cursor_name -- cursor name declared in the DECLARE/OPEN CURSOR statement
+ */
+void
+ecpg_update_declare_statement(const char *declared_name, const char *cursor_name, const int lineno)
+{
+	struct declared_statement *p = NULL;
+
+	if(!declared_name || !cursor_name)
+	{
+		return;
+	}
+
+	/* Find the declare node by declared name */
+	p = ecpg_find_declared_statement(declared_name);
+	if(p)
+	{
+		p->cursor_name = ecpg_strdup(cursor_name,lineno);
+	}
+}
+
+/***
+ * Function: Find and return the connection name referred by the declared name
+ * Input: declared_name -- the name declared in the DECLARE STATEMENT
+ * Return: Found -- The connection name
+ *		   Not found -- NULL
+ */
+char *
+ecpg_get_con_name_by_declared_name(const char *declared_name)
+{
+	struct declared_statement *p;
+
+	p = ecpg_find_declared_statement(declared_name);
+	if(p)
+	{
+		return p->connection_name;
+	}
+
+	return NULL;
+}
+
+/***
+ * Function: Find the declared name referred by the cursor, then return the
+ *			 connection name used by the declared name.
+ * Input: cursor_name -- the cursor name
+ * Return: Found -- The connection name
+ *		   Not found -- NULL
+ */
+const char *
+ecpg_get_con_name_by_cursor_name(const char *cursor_name)
+{
+	struct declared_statement *p;
+
+	if(cursor_name == NULL)
+	{
+		return NULL;
+	}
+
+	p = g_declared_list;
+	while(p)
+	{
+		/* Search the cursor name in the declare list */
+		if(p->cursor_name && (strcmp(p->cursor_name, cursor_name) == 0))
+		{
+			return p->connection_name;
+		}
+		p = p->next;
+	}
+
+	return NULL;
+}
+
+/***
+ * Function: Release the declare node from the g_declared_list which refer the connection_name
+ * Input: connection_name -- connection name
+ */
+void
+ecpg_release_declared_statement(const char *connection_name)
+{
+	struct declared_statement *cur = NULL;
+	struct declared_statement *prev = NULL;
+
+	if(connection_name == NULL)
+	{
+		return;
+	}
+
+	cur = g_declared_list;
+	while(cur)
+	{
+		if (strcmp(cur->connection_name, connection_name) == 0)
+		{
+			/* If find then release the declare node from the list */
+			if(prev)
+			{
+				prev->next = cur->next;
+			}
+			else
+			{
+				g_declared_list = cur->next;
+			}
+
+			ecpg_log("ecpg_release_declared_statement: declared name %s is released\n", cur->name);
+
+			ecpg_free(cur->name);
+			ecpg_free(cur->connection_name);
+			ecpg_free(cur->cursor_name);
+			ecpg_free(cur);
+
+			/*One connection can be used by multiple declared name, so no break here */
+		}
+		prev = cur;
+		cur = cur->next;
+	}
+}
diff --git a/src/interfaces/ecpg/include/ecpgerrno.h b/src/interfaces/ecpg/include/ecpgerrno.h
index 36b15b7..fae9440 100644
--- a/src/interfaces/ecpg/include/ecpgerrno.h
+++ b/src/interfaces/ecpg/include/ecpgerrno.h
@@ -44,6 +44,7 @@
 #define ECPG_UNKNOWN_DESCRIPTOR_ITEM	-242
 #define ECPG_VAR_NOT_NUMERIC		-243
 #define ECPG_VAR_NOT_CHAR		-244
+#define ECPG_INVALID_CURSOR		-245
 
 /* finally the backend error messages, they start at 400 */
 #define ECPG_PGSQL			-400
diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h
index c32df6c..8c91212 100644
--- a/src/interfaces/ecpg/include/ecpglib.h
+++ b/src/interfaces/ecpg/include/ecpglib.h
@@ -55,6 +55,10 @@ bool		ECPGdisconnect(int, const char *);
 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 *);
+bool		ECPGdeclare(int, const char *, const char *);
+bool		ECPGopen(const char*, const char*, const int, const int, const int, const char *, const bool, const int, const char *,...);
+bool		ECPGfetch(const char*, const int, const int, const int, const char *, const bool, const int, const char *,...);
+bool		ECPGclose(const char*, const int, const int, const int, const char *, const bool, const int, const char *,...);
 char	   *ECPGprepared_statement(const char *, const char *, int);
 PGconn	   *ECPGget_PGconn(const char *);
 PGTransactionStatusType ECPGtransactionStatus(const char *);
diff --git a/src/interfaces/ecpg/include/ecpgtype.h b/src/interfaces/ecpg/include/ecpgtype.h
index 7cc47e9..2c3f348 100644
--- a/src/interfaces/ecpg/include/ecpgtype.h
+++ b/src/interfaces/ecpg/include/ecpgtype.h
@@ -99,8 +99,15 @@ enum ECPG_statement_type
 	ECPGst_prepnormal
 };
 
+enum ECPG_cursor_statement_type
+{
+	ECPGcst_declare,
+	ECPGcst_open,
+	ECPGcst_fetch,
+	ECPGcst_close
+};
 #ifdef __cplusplus
 }
 #endif
 
-#endif   /* _ECPGTYPE_H */
+#endif	 /* _ECPGTYPE_H */
diff --git a/src/interfaces/ecpg/preproc/ecpg.addons b/src/interfaces/ecpg/preproc/ecpg.addons
index ca3efad..bfc18ab 100644
--- a/src/interfaces/ecpg/preproc/ecpg.addons
+++ b/src/interfaces/ecpg/preproc/ecpg.addons
@@ -15,7 +15,7 @@ ECPG: stmtClosePortalStmt block
 			}
 		}
 
-		output_statement($1, 0, ECPGst_normal);
+		$1 = $1;
 	}
 ECPG: stmtDeallocateStmt block
 	{
@@ -25,7 +25,11 @@ ECPG: stmtDeclareCursorStmt block
 	{ output_simple_statement($1); }
 ECPG: stmtDiscardStmt block
 ECPG: stmtFetchStmt block
-	{ output_statement($1, 1, ECPGst_normal); }
+	{
+		/* g_cursor_name is set in the fetch_args block and freed in the output_cursor_statement */
+		output_cursor_statement(ECPGcst_fetch, g_cursor_name, NULL, $1, 1, ECPGst_normal);
+		 g_cursor_name = NULL;
+	}
 ECPG: stmtDeleteStmt block
 ECPG: stmtInsertStmt block
 ECPG: stmtSelectStmt block
@@ -63,6 +67,10 @@ ECPG: stmtViewStmt rule
 		whenever_action(2);
 		free($1);
 	}
+	| ECPGDeclareStmt
+	{
+		output_declare_statement($1);
+	}
 	| ECPGCursorStmt
 	{
 		output_simple_statement($1);
@@ -132,7 +140,14 @@ ECPG: stmtViewStmt rule
 		if ((ptr = add_additional_variables($1, true)) != NULL)
 		{
 			connection = ptr->connection ? mm_strdup(ptr->connection) : NULL;
-			output_statement(mm_strdup(ptr->command), 0, ECPGst_normal);
+			if(ptr->prepared_name)
+			{
+				output_cursor_statement(ECPGcst_open, $1, mm_strdup(ptr->prepared_name), mm_strdup(ptr->command), 0, ECPGst_normal);
+			}
+			else
+			{
+				 output_cursor_statement(ECPGcst_open, $1, NULL, mm_strdup(ptr->command), 0, ECPGst_normal);
+			}
 			ptr->opened = true;
 		}
 	}
@@ -204,6 +219,7 @@ ECPG: var_valueNumericOnly addon
 		}
 ECPG: fetch_argscursor_name addon
 		add_additional_variables($1, false);
+		g_cursor_name = mm_strdup($1);
 		if ($1[0] == ':')
 		{
 			free($1);
@@ -211,6 +227,7 @@ ECPG: fetch_argscursor_name addon
 		}
 ECPG: fetch_argsfrom_incursor_name addon
 		add_additional_variables($2, false);
+		g_cursor_name = mm_strdup($2);
 		if ($2[0] == ':')
 		{
 			free($2);
@@ -222,6 +239,7 @@ ECPG: fetch_argsFIRST_Popt_from_incursor_name addon
 ECPG: fetch_argsLAST_Popt_from_incursor_name addon
 ECPG: fetch_argsALLopt_from_incursor_name addon
 		add_additional_variables($3, false);
+		g_cursor_name = mm_strdup($3);
 		if ($3[0] == ':')
 		{
 			free($3);
@@ -229,6 +247,7 @@ ECPG: fetch_argsALLopt_from_incursor_name addon
 		}
 ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
 		add_additional_variables($3, false);
+		g_cursor_name = mm_strdup($3);
 		if ($3[0] == ':')
 		{
 			free($3);
@@ -242,6 +261,7 @@ ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
 ECPG: fetch_argsFORWARDALLopt_from_incursor_name addon
 ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
 		add_additional_variables($4, false);
+		g_cursor_name = mm_strdup($4);
 		if ($4[0] == ':')
 		{
 			free($4);
@@ -252,6 +272,7 @@ ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_incursor_name addon
 ECPG: fetch_argsFORWARDSignedIconstopt_from_incursor_name addon
 ECPG: fetch_argsBACKWARDSignedIconstopt_from_incursor_name addon
 		add_additional_variables($4, false);
+		g_cursor_name = mm_strdup($4);
 		if ($4[0] == ':')
 		{
 			free($4);
@@ -304,6 +325,7 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
 		}
 
 		this = (struct cursor *) mm_alloc(sizeof(struct cursor));
+		memset(this, 0 ,sizeof(struct cursor));
 
 		this->next = cur;
 		this->name = $2;
@@ -336,8 +358,31 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
 	}
 ECPG: ClosePortalStmtCLOSEcursor_name block
 	{
+		char *stmt = NULL;
+		char *cursor_name = NULL;
 		char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : $2;
-		$$ = cat2_str(mm_strdup("close"), cursor_marker);
+
+		cursor_name = mm_strdup($2);
+
+		stmt = cat2_str(mm_strdup("close"), cursor_marker);
+
+		if (INFORMIX_MODE)
+		{
+			if (pg_strcasecmp(stmt+strlen("close "), "database") == 0)
+			{
+				if (connection)
+					mmerror(PARSE_ERROR, ET_ERROR, "AT option not allowed in CLOSE DATABASE statement");
+
+				fprintf(base_yyout, "{ ECPGdisconnect(__LINE__, \"CURRENT\");");
+				whenever_action(2);
+				free(stmt);
+				break;
+			}
+		}
+
+		output_cursor_statement(ECPGcst_close, cursor_name, NULL, stmt, 0, ECPGst_normal);
+
+		$$ = EMPTY;
 	}
 ECPG: opt_hold block
 	{
@@ -394,14 +439,14 @@ ECPG: AexprConstNULL_P rule
 	| civar			{ $$ = $1; }
 	| civarind		{ $$ = $1; }
 ECPG: ColIdcol_name_keyword rule
-	| ECPGKeywords                  { $$ = $1; }
-	| ECPGCKeywords                 { $$ = $1; }
-	| CHAR_P                        { $$ = mm_strdup("char"); }
-	| VALUES                        { $$ = mm_strdup("values"); }
+	| ECPGKeywords					{ $$ = $1; }
+	| ECPGCKeywords					{ $$ = $1; }
+	| CHAR_P						{ $$ = mm_strdup("char"); }
+	| VALUES						{ $$ = mm_strdup("values"); }
 ECPG: type_function_nametype_func_name_keyword rule
-	| ECPGKeywords                          { $$ = $1; }
-	| ECPGTypeName                          { $$ = $1; }
-	| ECPGCKeywords                         { $$ = $1; }
+	| ECPGKeywords							{ $$ = $1; }
+	| ECPGTypeName							{ $$ = $1; }
+	| ECPGCKeywords							{ $$ = $1; }
 ECPG: VariableShowStmtSHOWALL block
 	{
 		mmerror(PARSE_ERROR, ET_ERROR, "SHOW ALL is not implemented");
@@ -416,48 +461,56 @@ ECPG: FetchStmtMOVEfetch_args rule
 	{
 		char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
 		add_additional_variables($3, false);
+		g_cursor_name = mm_strdup($3);
 		$$ = 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);
+		g_cursor_name = mm_strdup($4);
 		$$ = 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);
+		g_cursor_name = mm_strdup($3);
 		$$ = 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);
+		g_cursor_name = mm_strdup($4);
 		$$ = 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);
+		g_cursor_name = mm_strdup($3);
 		$$ = 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);
+		g_cursor_name = mm_strdup($4);
 		$$ = 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);
+		g_cursor_name = mm_strdup($3);
 		$$ = 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);
+		g_cursor_name = mm_strdup($4);
 		$$ = cat_str(2, mm_strdup("move backward from"), cursor_marker);
 	}
 ECPG: limit_clauseLIMITselect_limit_value','select_offset_value block
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c
index fa80bb2..0fc4932 100644
--- a/src/interfaces/ecpg/preproc/ecpg.c
+++ b/src/interfaces/ecpg/preproc/ecpg.c
@@ -28,6 +28,7 @@ struct _include_path *include_paths = NULL;
 struct cursor *cur = NULL;
 struct typedefs *types = NULL;
 struct _defines *defines = NULL;
+struct declared_name_st *g_declared_list = NULL;
 
 static void
 help(const char *progname)
@@ -111,6 +112,54 @@ add_preprocessor_define(char *define)
 	defines->next = pd;
 }
 
+static void
+free_argument(struct arguments *arg)
+{
+	if(arg == NULL)
+	{
+		return;
+	}
+
+	free_argument(arg->next);
+
+	/*
+	*  Don't free variables in it because the original codes don't free it either
+	*  variables are static structures instead of allocating
+	*/
+	free(arg);
+}
+
+static void
+free_cursor(struct cursor *c)
+{
+	if(c == NULL)
+	{
+		return;
+	}
+
+	free_cursor(c->next);
+	free_argument(c->argsinsert);
+	free_argument(c->argsresult);
+
+	free(c->name);
+	free(c->function);
+	free(c->command);
+	free(c->prepared_name);
+	free(c);
+}
+
+static void
+free_declared_stmt(struct declared_name_st *st)
+{
+	if(st == NULL)
+	{
+		return;
+	}
+
+	free_declared_stmt(st->next);
+	free(st);
+}
+
 #define ECPG_GETOPT_LONG_REGRESSION		1
 int
 main(int argc, char *const argv[])
@@ -343,29 +392,18 @@ main(int argc, char *const argv[])
 				struct typedefs *typeptr;
 
 				/* remove old cursor definitions if any are still there */
-				for (ptr = cur; ptr != NULL;)
+				if(cur)
 				{
-					struct cursor *this = ptr;
-					struct arguments *l1,
-							   *l2;
-
-					free(ptr->command);
-					free(ptr->connection);
-					free(ptr->name);
-					for (l1 = ptr->argsinsert; l1; l1 = l2)
-					{
-						l2 = l1->next;
-						free(l1);
-					}
-					for (l1 = ptr->argsresult; l1; l1 = l2)
-					{
-						l2 = l1->next;
-						free(l1);
-					}
-					ptr = ptr->next;
-					free(this);
+					free_cursor(cur);
+					cur = NULL;
+				}
+
+				/* remove old declared statements if any are still there */
+				if(g_declared_list)
+				{
+					free_declared_stmt(g_declared_list);
+					g_declared_list = NULL;
 				}
-				cur = NULL;
 
 				/* remove non-pertinent old defines as well */
 				while (defines && !defines->pertinent)
@@ -479,6 +517,18 @@ main(int argc, char *const argv[])
 
 			free(input_filename);
 		}
+
+		if(g_declared_list)
+		{
+			free_declared_stmt(g_declared_list);
+			g_declared_list = NULL;
+		}
+
+		if(cur)
+		{
+			free_cursor(cur);
+			cur = NULL;
+		}
 	}
 	return ret_value;
 }
diff --git a/src/interfaces/ecpg/preproc/ecpg.header b/src/interfaces/ecpg/preproc/ecpg.header
index 672f0b4..bda7214 100644
--- a/src/interfaces/ecpg/preproc/ecpg.header
+++ b/src/interfaces/ecpg/preproc/ecpg.header
@@ -38,6 +38,7 @@ char *current_function;
 int ecpg_internal_var = 0;
 char	*connection = NULL;
 char	*input_filename = NULL;
+char	*g_cursor_name = 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 31e765c..49f7fa6 100644
--- a/src/interfaces/ecpg/preproc/ecpg.trailer
+++ b/src/interfaces/ecpg/preproc/ecpg.trailer
@@ -284,6 +284,38 @@ prepared_name: name
 		;
 
 /*
+ * Declare Statement
+ */
+ECPGDeclareStmt: DECLARE prepared_name STATEMENT
+		{
+			struct declared_name_st *ptr = NULL;
+
+			/* Check whether the declared name has been defined or not */
+			for (ptr = g_declared_list; ptr != NULL; ptr = ptr->next)
+			{
+				if (strcmp($2, ptr->name) == 0)
+				{
+					/* re-definition is a bug */
+					mmerror(PARSE_ERROR, ET_ERROR, "declared name %s is already defined", ptr->name);
+				}
+			}
+
+			/* Add a new declared name into the g_declared_list */
+			ptr = NULL;
+			ptr = (struct declared_name_st *) mm_alloc(sizeof(struct declared_name_st));
+			if(ptr)
+			{
+				/* initial definition */
+				ptr->name = $2;
+				ptr->next = g_declared_list;
+				g_declared_list = ptr;
+			}
+
+			$$ = mm_strdup($2);
+		}
+;
+
+/*
  * Declare a prepared cursor. The syntax is different from the standard
  * declare statement, so we create a new rule.
  */
@@ -309,6 +341,7 @@ ECPGCursorStmt:  DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared
 			}
 
 			this = (struct cursor *) mm_alloc(sizeof(struct cursor));
+			memset(this, 0 ,sizeof(struct cursor));
 
 			/* initial definition */
 			this->next = cur;
@@ -318,6 +351,7 @@ ECPGCursorStmt:  DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared
 			this->command =  cat_str(6, mm_strdup("declare"), cursor_marker, $3, mm_strdup("cursor"), $5, mm_strdup("for $1"));
 			this->argsresult = NULL;
 			this->argsresult_oos = NULL;
+			this->prepared_name = $7;
 
 			thisquery->type = &ecpg_query;
 			thisquery->brace_level = 0;
diff --git a/src/interfaces/ecpg/preproc/ecpg.type b/src/interfaces/ecpg/preproc/ecpg.type
index ac6aa00..978be84 100644
--- a/src/interfaces/ecpg/preproc/ecpg.type
+++ b/src/interfaces/ecpg/preproc/ecpg.type
@@ -9,6 +9,7 @@
 %type <str> ECPGDeallocateDescr
 %type <str> ECPGDeclaration
 %type <str> ECPGDeclare
+%type <str> ECPGDeclareStmt
 %type <str> ECPGDescribe
 %type <str> ECPGDisconnect
 %type <str> ECPGExecuteImmediateStmt
diff --git a/src/interfaces/ecpg/preproc/extern.h b/src/interfaces/ecpg/preproc/extern.h
index 0ce3a6e..dcfdc06 100644
--- a/src/interfaces/ecpg/preproc/extern.h
+++ b/src/interfaces/ecpg/preproc/extern.h
@@ -50,6 +50,7 @@ extern struct _include_path *include_paths;
 extern struct cursor *cur;
 extern struct typedefs *types;
 extern struct _defines *defines;
+extern struct declared_name_st *g_declared_list;
 extern struct ECPGtype ecpg_no_indicator;
 extern struct variable no_indicator;
 extern struct arguments *argsinsert;
@@ -72,6 +73,8 @@ extern void output_statement(char *, int, enum ECPG_statement_type);
 extern void output_prepare_statement(char *, char *);
 extern void output_deallocate_prepare_statement(char *);
 extern void output_simple_statement(char *);
+extern void output_declare_statement(char *);
+extern void output_cursor_statement(int , char *, char *, char *, int , enum ECPG_statement_type);
 extern char *hashline_number(void);
 extern int	base_yyparse(void);
 extern int	base_yylex(void);
diff --git a/src/interfaces/ecpg/preproc/output.c b/src/interfaces/ecpg/preproc/output.c
index 59d5d30..083458b 100644
--- a/src/interfaces/ecpg/preproc/output.c
+++ b/src/interfaces/ecpg/preproc/output.c
@@ -5,6 +5,7 @@
 #include "extern.h"
 
 static void output_escaped_str(char *cmd, bool quoted);
+static void output_cursor_name(char *str);
 
 void
 output_line_number(void)
@@ -195,7 +196,16 @@ static void
 output_escaped_str(char *str, bool quoted)
 {
 	int			i = 0;
-	int			len = strlen(str);
+	int			len = 0;
+
+	if(str == NULL)
+	{
+		fputs("NULL", base_yyout);
+
+		return;
+	}
+
+	len = strlen(str);
 
 	if (quoted && str[0] == '"' && str[len - 1] == '"') /* do not escape quotes
 														 * at beginning and end
@@ -244,3 +254,150 @@ output_escaped_str(char *str, bool quoted)
 	if (quoted && str[0] == '"' && str[len] == '"')
 		fputs("\"", base_yyout);
 }
+
+/****
+ * This is a tool function used by the output_cursor_statement function to print
+ * cursor name after the string such as "ECPGopen(","ECPGfetch(","ECPGclose(".
+ * */
+static void
+output_cursor_name(char *str)
+{
+	int			i = 0;
+	int			len = 0;
+
+	if(str == NULL)
+	{
+		fputs("NULL",base_yyout);
+
+		return;
+	}
+
+	len = strlen(str);
+	fputs("\"", base_yyout);
+	if (str[0] == '\"' && str[len - 1] == '\"')
+	{
+		i = 1;
+		len--;
+		fputs("\\\"", base_yyout);
+
+		/* output this char by char as we have to filter " and \n */
+		for (; i < len; i++)
+		{
+			if (str[i] == '"')
+				fputs("\\\"", base_yyout);
+			else if (str[i] == '\n')
+				fputs("\\\n", base_yyout);
+			else if (str[i] == '\\')
+			{
+				int			j = i;
+
+				/*
+				 * check whether this is a continuation line if it is, do not
+				 * output anything because newlines are escaped anyway
+				 */
+
+				/* accept blanks after the '\' as some other compilers do too */
+				do
+				{
+					j++;
+				} while (str[j] == ' ' || str[j] == '\t');
+
+				if ((str[j] != '\n') && (str[j] != '\r' || str[j + 1] != '\n'))		/* not followed by a
+																					 * newline */
+					fputs("\\\\",base_yyout);
+			}
+			else if (str[i] == '\r' && str[i + 1] == '\n')
+			{
+				fputs("\\\r\n", base_yyout);
+				i++;
+			}
+			else
+				fputc(str[i], base_yyout);
+		}
+
+		fputs("\\\"", base_yyout);
+	}
+	else
+	{
+		fputs(str, base_yyout);
+	}
+	fputs("\"", base_yyout);
+}
+
+/***
+ * Translate the EXEC SQL DECLARE STATEMENT into ECPGdeclare function
+ */
+void
+output_declare_statement(char *name)
+{
+	/* connection is set in "at:" token in ecpg.trailer file */
+	fprintf(base_yyout, "{ ECPGdeclare(__LINE__, %s, ", connection ? connection : "NULL");
+	output_escaped_str(name, true);
+	fputs(");", base_yyout);
+
+	whenever_action(2);
+	free(name);
+	if (connection != NULL)
+		free(connection);
+}
+
+/***
+ * Translate the EXEC SQL CURSOR STATEMENT such as OPEN/FETCH/CLOSE cursor into
+ * ECPGopen/ECPGfetch/ECPGclose function
+ */
+void
+output_cursor_statement(int cursor_stmt, char *cursor_name, char *prepared_name, char *stmt, int whenever_mode, enum ECPG_statement_type st)
+{
+	switch(cursor_stmt)
+	{
+	case ECPGcst_open:
+		fprintf(base_yyout, "{ ECPGopen(");
+		output_cursor_name(cursor_name);
+		fprintf(base_yyout,", ");
+		output_escaped_str(prepared_name, true);
+		fprintf(base_yyout,", __LINE__, %d, %d, %s, %d, ",
+				compat, force_indicator, connection ? connection : "NULL", questionmarks);
+		break;
+	case ECPGcst_fetch:
+		fprintf(base_yyout, "{ ECPGfetch(");
+		output_cursor_name(cursor_name);
+		fprintf(base_yyout,", __LINE__, %d, %d, %s, %d, ",
+				compat, force_indicator, connection ? connection : "NULL", questionmarks);
+		break;
+	case ECPGcst_close:
+		fprintf(base_yyout, "{ ECPGclose(");
+		output_cursor_name(cursor_name);
+		fprintf(base_yyout,", __LINE__, %d, %d, %s, %d, ",
+				compat, force_indicator, connection ? connection : "NULL", questionmarks);
+		break;
+	}
+
+	if (st == ECPGst_execute || st == ECPGst_exec_immediate)
+	{
+		fprintf(base_yyout, "%s, %s, ", ecpg_statement_type_name[st], stmt);
+	}
+	else
+	{
+		if (st == ECPGst_prepnormal && auto_prepare)
+			fputs("ECPGst_prepnormal, \"", base_yyout);
+		else
+			fputs("ECPGst_normal, \"", base_yyout);
+
+		output_escaped_str(stmt, false);
+		fputs("\", ", base_yyout);
+	}
+
+	/* dump variables to C file */
+	dump_variables(argsinsert, 1);
+	fputs("ECPGt_EOIT, ", base_yyout);
+	dump_variables(argsresult, 1);
+	fputs("ECPGt_EORT);", base_yyout);
+	reset_variables();
+
+	whenever_action(whenever_mode | 2);
+	free(cursor_name);
+	free(prepared_name);
+	free(stmt);
+	if (connection != NULL)
+		free(connection);
+}
diff --git a/src/interfaces/ecpg/preproc/type.h b/src/interfaces/ecpg/preproc/type.h
index cd0d1da..82db1fc 100644
--- a/src/interfaces/ecpg/preproc/type.h
+++ b/src/interfaces/ecpg/preproc/type.h
@@ -129,6 +129,7 @@ struct cursor
 	char	   *command;
 	char	   *connection;
 	bool		opened;
+	char	   *prepared_name;
 	struct arguments *argsinsert;
 	struct arguments *argsinsert_oos;
 	struct arguments *argsresult;
@@ -136,6 +137,13 @@ struct cursor
 	struct cursor *next;
 };
 
+/* structure to store declared name */
+struct declared_name_st
+{
+	char	*name; /* declare name */
+	struct	declared_name_st *next;
+};
+
 struct typedefs
 {
 	char	   *name;
diff --git a/src/interfaces/ecpg/test/Makefile b/src/interfaces/ecpg/test/Makefile
index 28f02fe..53a50c3 100644
--- a/src/interfaces/ecpg/test/Makefile
+++ b/src/interfaces/ecpg/test/Makefile
@@ -75,7 +75,7 @@ $(remaining_files_build): $(abs_builddir)/%: $(srcdir)/%
 endif
 
 # Common options for tests. Also pick up anything passed in EXTRA_REGRESS_OPTS
-REGRESS_OPTS = --dbname=ecpg1_regression,ecpg2_regression --create-role=regress_ecpg_user1,regress_ecpg_user2 $(EXTRA_REGRESS_OPTS)
+REGRESS_OPTS = --dbname=ecpg1_regression,ecpg2_regression,ecpg3_regression --create-role=regress_ecpg_user1,regress_ecpg_user2 $(EXTRA_REGRESS_OPTS)
 
 check: all
 	$(with_temp_install) ./pg_regress $(REGRESS_OPTS) --temp-instance=./tmp_check $(TEMP_CONF) --bindir= $(pg_regress_locale_flags) $(THREAD) --schedule=$(srcdir)/ecpg_schedule
diff --git a/src/interfaces/ecpg/test/ecpg_schedule b/src/interfaces/ecpg/test/ecpg_schedule
index c3ec125..5f7fe5b 100644
--- a/src/interfaces/ecpg/test/ecpg_schedule
+++ b/src/interfaces/ecpg/test/ecpg_schedule
@@ -48,6 +48,7 @@ test: sql/quote
 test: sql/show
 test: sql/insupd
 test: sql/parser
+test: sql/declare
 test: thread/thread
 test: thread/thread_implicit
 test: thread/prep
diff --git a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
index 1f316fb..b4a7c44 100644
--- a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
+++ b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
@@ -241,7 +241,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", 
+	{ ECPGopen("mycur1", "st_id1", __LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur1 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"
@@ -258,7 +258,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	while (1)
 	{
 		strcpy(msg, "fetch");
-		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
+		{ ECPGfetch("mycur1", __LINE__, 1, 1, NULL, 0, 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"
@@ -279,7 +279,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "close");
-	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGclose("mycur1", __LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
 #line 118 "sqlda.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
@@ -316,7 +316,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", 
+	{ ECPGopen("mycur2", "st_id2", __LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur2 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"
@@ -333,7 +333,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	while (1)
 	{
 		strcpy(msg, "fetch");
-		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from mycur2", ECPGt_EOIT, 
+		{ ECPGfetch("mycur2", __LINE__, 1, 1, NULL, 0, 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"
@@ -354,7 +354,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "close");
-	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGclose("mycur2", __LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
 #line 155 "sqlda.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
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 9934947..48b9197 100644
--- a/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
+++ b/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
@@ -158,7 +158,7 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
 
 	while (1)
 	{
-		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch forward c", ECPGt_EOIT, 
+		{ ECPGfetch("c", __LINE__, 1, 1, NULL, 0, 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), 
@@ -244,7 +244,7 @@ if (sqlca.sqlcode < 0) dosqlprint ( );}
 
 static void openit(void)
 {
-	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare c cursor for select * from test where i <= $1 ", 
+	{ ECPGopen("c", NULL, __LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare c 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"
diff --git a/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c b/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
index a56513a..ffa5687 100644
--- a/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
+++ b/src/interfaces/ecpg/test/expected/pgtypeslib-nan_test.c
@@ -82,7 +82,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 	/* declare cur cursor for select id , d , d from nantest1 */
 #line 33 "nan_test.pgc"
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen("cur", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
 #line 34 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
@@ -90,7 +90,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 
 	while (1)
 	{
-		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur", ECPGt_EOIT, 
+		{ ECPGfetch("cur", __LINE__, 0, 1, NULL, 0, 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), 
@@ -130,14 +130,14 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 #line 46 "nan_test.pgc"
 
 	}
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGclose("cur", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT);
 #line 48 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
 #line 48 "nan_test.pgc"
 
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen("cur", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select id , d , d from nantest1", ECPGt_EOIT, ECPGt_EORT);
 #line 50 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
@@ -145,7 +145,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 
 	while (1)
 	{
-		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur", ECPGt_EOIT, 
+		{ ECPGfetch("cur", __LINE__, 0, 1, NULL, 0, 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), 
@@ -164,7 +164,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 		if (isnan(d))
 			printf("%d  NaN '%s'\n", id, val);
 	}
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGclose("cur", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT);
 #line 61 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
@@ -221,7 +221,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 	/* declare cur1 cursor for select id , d , d from nantest2 */
 #line 75 "nan_test.pgc"
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur1 cursor for select id , d , d from nantest2", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen("cur1", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur1 cursor for select id , d , d from nantest2", ECPGt_EOIT, ECPGt_EORT);
 #line 76 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
@@ -229,7 +229,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 
 	while (1)
 	{
-		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from cur1", ECPGt_EOIT, 
+		{ ECPGfetch("cur1", __LINE__, 0, 1, NULL, 0, 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), 
@@ -245,7 +245,7 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
 			break;
 		printf("%d %s '%s'\n", id, (num->sign == NUMERIC_NAN ? "NaN" : "not NaN"), val);
 	}
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGclose("cur1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT);
 #line 84 "nan_test.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint ( );}
diff --git a/src/interfaces/ecpg/test/expected/preproc-autoprep.c b/src/interfaces/ecpg/test/expected/preproc-autoprep.c
index 10ede3e..e3abb29 100644
--- a/src/interfaces/ecpg/test/expected/preproc-autoprep.c
+++ b/src/interfaces/ecpg/test/expected/preproc-autoprep.c
@@ -133,7 +133,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 35 "autoprep.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGopen("C", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT);
 #line 37 "autoprep.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -143,7 +143,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 37 "autoprep.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, 
+  { ECPGfetch("C", __LINE__, 0, 1, NULL, 0, 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"
@@ -156,7 +156,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
   printf("i = %d\n", i);
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGclose("C", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT);
 #line 42 "autoprep.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -180,7 +180,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 46 "autoprep.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur1 cursor for $1", 
+  { ECPGopen("cur1", "stmt1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur1 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"
@@ -199,7 +199,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
   i = 0;
   while (1)
   {
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur1", ECPGt_EOIT, 
+	{ ECPGfetch("cur1", __LINE__, 0, 1, NULL, 0, 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"
@@ -217,7 +217,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	i++;
   }
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGclose("cur1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT);
 #line 60 "autoprep.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
diff --git a/src/interfaces/ecpg/test/expected/preproc-cursor.c b/src/interfaces/ecpg/test/expected/preproc-cursor.c
index f7da753..ad86a56 100644
--- a/src/interfaces/ecpg/test/expected/preproc-cursor.c
+++ b/src/interfaces/ecpg/test/expected/preproc-cursor.c
@@ -187,7 +187,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+	{ ECPGopen(":curname1", NULL, __LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 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"
@@ -197,7 +197,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch from");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch forward from $0", 
+	{ ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, 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), 
@@ -212,7 +212,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch forward $0", 
+	{ ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, 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), 
@@ -227,7 +227,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch 1 from");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0", 
+	{ ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, 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), 
@@ -243,7 +243,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "fetch :count from");
 	count = 1;
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0", 
+	{ ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, 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), 
@@ -260,7 +260,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "move in");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 in $0", 
+	{ ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, 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"
@@ -270,7 +270,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch 1");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0", 
+	{ ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, 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), 
@@ -286,7 +286,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "fetch :count");
 	count = 1;
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0", 
+	{ ECPGfetch(":curname1", __LINE__, 0, 1, "test1", 0, 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), 
@@ -303,7 +303,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "close");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0", 
+	{ ECPGclose(":curname1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0", 
 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 99 "cursor.pgc"
@@ -323,7 +323,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+	{ ECPGopen(":curname2", NULL, __LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 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), 
@@ -337,7 +337,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch from");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, 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), 
@@ -352,7 +352,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0", 
+	{ ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, 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), 
@@ -367,7 +367,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch 1 from");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0", 
+	{ ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, 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), 
@@ -383,7 +383,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "fetch :count from");
 	count = 1;
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0", 
+	{ ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, 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), 
@@ -400,7 +400,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "move");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0", 
+	{ ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, 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), 
@@ -414,7 +414,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch 1");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0", 
+	{ ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, 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), 
@@ -430,7 +430,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "fetch :count");
 	count = 1;
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0", 
+	{ ECPGfetch(":curname2", __LINE__, 0, 1, "test1", 0, 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), 
@@ -447,7 +447,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "close");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0", 
+	{ ECPGclose(":curname2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0", 
 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 140 "cursor.pgc"
@@ -483,7 +483,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for $1", 
+	{ ECPGopen(":curname3", "st_id1", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 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), 
@@ -493,7 +493,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 if (sqlca.sqlcode < 0) exit (1);}
 #line 153 "cursor.pgc"
 
-	{ ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "declare $0 cursor for $1", 
+	{ ECPGopen(":curname5", "st_id1", __LINE__, 0, 1, "test2", 0, ECPGst_normal, "declare $0 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), 
@@ -505,7 +505,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch");
-	{ ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "fetch $0", 
+	{ ECPGfetch(":curname5", __LINE__, 0, 1, "test2", 0, 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), 
@@ -520,7 +520,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch from");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, 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), 
@@ -535,7 +535,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch 1 from");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0", 
+	{ ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, 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), 
@@ -551,7 +551,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "fetch :count from");
 	count = 1;
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0", 
+	{ ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, 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), 
@@ -568,7 +568,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "move");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0", 
+	{ ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, 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"
@@ -578,7 +578,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch 1");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0", 
+	{ ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, 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), 
@@ -594,7 +594,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "fetch :count");
 	count = 1;
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0", 
+	{ ECPGfetch(":curname3", __LINE__, 0, 1, "test1", 0, 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), 
@@ -611,7 +611,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "close");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0", 
+	{ ECPGclose(":curname3", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0", 
 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 186 "cursor.pgc"
@@ -619,7 +619,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 if (sqlca.sqlcode < 0) exit (1);}
 #line 186 "cursor.pgc"
 
-	{ ECPGdo(__LINE__, 0, 1, "test2", 0, ECPGst_normal, "close $0", 
+	{ ECPGclose(":curname5", __LINE__, 0, 1, "test2", 0, ECPGst_normal, "close $0", 
 	ECPGt_char,&(curname5),(long)0,(long)1,(1)*sizeof(char), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 187 "cursor.pgc"
@@ -663,7 +663,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 cursor for $1", 
+	{ ECPGopen(":curname4", "st_id2", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "declare $0 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), 
@@ -675,7 +675,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch from");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch from $0", 
+	{ ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, 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), 
@@ -690,7 +690,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0", 
+	{ ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, 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), 
@@ -705,7 +705,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "fetch 1 from");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 from $0", 
+	{ ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, 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), 
@@ -721,7 +721,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "fetch :count from");
 	count = 1;
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 from $0", 
+	{ ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, 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), 
@@ -738,7 +738,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "move");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "move absolute 0 $0", 
+	{ ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, 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"
@@ -748,7 +748,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch 1");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch 1 $0", 
+	{ ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, 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), 
@@ -764,7 +764,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 	strcpy(msg, "fetch :count");
 	count = 1;
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "fetch $0 $0", 
+	{ ECPGfetch(":curname4", __LINE__, 0, 1, "test1", 0, 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), 
@@ -781,7 +781,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	printf("%d %s\n", id, t);
 
 	strcpy(msg, "close");
-	{ ECPGdo(__LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0", 
+	{ ECPGclose(":curname4", __LINE__, 0, 1, "test1", 0, ECPGst_normal, "close $0", 
 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_1), 
 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 238 "cursor.pgc"
diff --git a/src/interfaces/ecpg/test/expected/preproc-outofscope.c b/src/interfaces/ecpg/test/expected/preproc-outofscope.c
index 348e843..23ce610 100644
--- a/src/interfaces/ecpg/test/expected/preproc-outofscope.c
+++ b/src/interfaces/ecpg/test/expected/preproc-outofscope.c
@@ -201,7 +201,7 @@ get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
 static void
 open_cur1(void)
 {
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT, 
+	{ ECPGopen("mycur", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur 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 ), 
@@ -225,7 +225,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 static void
 get_record1(void)
 {
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT, 
+	{ ECPGfetch("mycur", __LINE__, 0, 1, NULL, 0, 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 ), 
@@ -249,7 +249,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 static void
 close_cur1(void)
 {
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGclose("mycur", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
 #line 58 "outofscope.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
diff --git a/src/interfaces/ecpg/test/expected/preproc-variable.c b/src/interfaces/ecpg/test/expected/preproc-variable.c
index 7fd03ba..722c02e 100644
--- a/src/interfaces/ecpg/test/expected/preproc-variable.c
+++ b/src/interfaces/ecpg/test/expected/preproc-variable.c
@@ -190,7 +190,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select name , born , age , married , children from family", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGopen("cur", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur cursor for select name , born , age , married , children from family", ECPGt_EOIT, ECPGt_EORT);
 #line 63 "variable.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
@@ -206,7 +206,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	memset(i, 0, sizeof(ind_personal));
 	while (1) {
 		strcpy(msg, "fetch");
-		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur", ECPGt_EOIT, 
+		{ ECPGfetch("cur", __LINE__, 0, 1, NULL, 0, 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 ), 
@@ -241,7 +241,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	}
 
 	strcpy(msg, "close");
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGclose("cur", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur", ECPGt_EOIT, ECPGt_EORT);
 #line 89 "variable.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
diff --git a/src/interfaces/ecpg/test/expected/sql-binary.c b/src/interfaces/ecpg/test/expected/sql-binary.c
index b91ab7b..ce64de5 100644
--- a/src/interfaces/ecpg/test/expected/sql-binary.c
+++ b/src/interfaces/ecpg/test/expected/sql-binary.c
@@ -111,12 +111,12 @@ main (void)
  /* declare C cursor for select name , accs , byte from empl where idnum = $1  */
 #line 58 "binary.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select name , accs , byte from empl where idnum = $1 ", 
+  { ECPGopen("C", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C 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"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT, 
+  { ECPGfetch("C", __LINE__, 0, 1, NULL, 0, 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), 
@@ -133,7 +133,7 @@ main (void)
 
   printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte);
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT);}
+  { ECPGclose("C", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT);}
 #line 69 "binary.pgc"
 
 
@@ -142,12 +142,12 @@ main (void)
  /* declare B binary cursor for select name , accs , byte from empl where idnum = $1  */
 #line 72 "binary.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare B binary cursor for select name , accs , byte from empl where idnum = $1 ", 
+  { ECPGopen("B", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare B binary 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"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch B", ECPGt_EOIT, 
+  { ECPGfetch("B", __LINE__, 0, 1, NULL, 0, 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), 
@@ -162,7 +162,7 @@ main (void)
       exit (sqlca.sqlcode);
     }
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close B", ECPGt_EOIT, ECPGt_EORT);}
+  { ECPGclose("B", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close B", ECPGt_EOIT, ECPGt_EORT);}
 #line 81 "binary.pgc"
 
 
@@ -176,12 +176,12 @@ main (void)
  /* declare A binary cursor for select byte from empl where idnum = $1  */
 #line 89 "binary.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare A binary cursor for select byte from empl where idnum = $1 ", 
+  { ECPGopen("A", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare A binary 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"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch A", ECPGt_EOIT, 
+  { ECPGfetch("A", __LINE__, 0, 1, NULL, 0, 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"
@@ -192,7 +192,7 @@ main (void)
       exit (sqlca.sqlcode);
     }
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close A", ECPGt_EOIT, ECPGt_EORT);}
+  { ECPGclose("A", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close A", ECPGt_EOIT, ECPGt_EORT);}
 #line 98 "binary.pgc"
 
 
diff --git a/src/interfaces/ecpg/test/expected/sql-declare.c b/src/interfaces/ecpg/test/expected/sql-declare.c
new file mode 100644
index 0000000..2a7ea0d
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/sql-declare.c
@@ -0,0 +1,2592 @@
+/* Processed by ecpg (regression mode) */
+/* These include files are added by the preprocessor */
+#include <ecpglib.h>
+#include <ecpgerrno.h>
+#include <sqlca.h>
+/* End of automatic include section */
+#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+
+#line 1 "declare.pgc"
+#include <locale.h>
+#include <string.h>
+#include <stdlib.h>
+
+/* exec sql whenever sqlerror  sqlprint ; */
+#line 5 "declare.pgc"
+
+
+
+#line 1 "sqlca.h"
+#ifndef POSTGRES_SQLCA_H
+#define POSTGRES_SQLCA_H
+
+#ifndef PGDLLIMPORT
+#if  defined(WIN32) || defined(__CYGWIN__)
+#define PGDLLIMPORT __declspec (dllimport)
+#else
+#define PGDLLIMPORT
+#endif   /* __CYGWIN__ */
+#endif   /* PGDLLIMPORT */
+
+#define SQLERRMC_LEN	150
+
+#ifdef __cplusplus
+extern		"C"
+{
+#endif
+
+struct sqlca_t
+{
+	char		sqlcaid[8];
+	long		sqlabc;
+	long		sqlcode;
+	struct
+	{
+		int			sqlerrml;
+		char		sqlerrmc[SQLERRMC_LEN];
+	}			sqlerrm;
+	char		sqlerrp[8];
+	long		sqlerrd[6];
+	/* Element 0: empty						*/
+	/* 1: OID of processed tuple if applicable			*/
+	/* 2: number of rows processed				*/
+	/* after an INSERT, UPDATE or				*/
+	/* DELETE statement					*/
+	/* 3: empty						*/
+	/* 4: empty						*/
+	/* 5: empty						*/
+	char		sqlwarn[8];
+	/* Element 0: set to 'W' if at least one other is 'W'	*/
+	/* 1: if 'W' at least one character string		*/
+	/* value was truncated when it was			*/
+	/* stored into a host variable.             */
+
+	/*
+	 * 2: if 'W' a (hopefully) non-fatal notice occurred
+	 */	/* 3: empty */
+	/* 4: empty						*/
+	/* 5: empty						*/
+	/* 6: empty						*/
+	/* 7: empty						*/
+
+	char		sqlstate[5];
+};
+
+struct sqlca_t *ECPGget_sqlca(void);
+
+#ifndef POSTGRES_ECPG_INTERNAL
+#define sqlca (*ECPGget_sqlca())
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+#line 7 "declare.pgc"
+
+
+#line 1 "regression.h"
+
+
+
+
+
+
+#line 8 "declare.pgc"
+
+
+#define OUT_ARRAY_SZIE 20
+#define TEST_CASE_NUM 29
+#define COLUMN_NUM 3
+#define FIELD_NAME_LEN 30
+
+void declare_test(char * tc_name);
+int createTable(void);
+void dropTable(void);
+void reCreateTable(void);
+void truncateTable(void);
+void commitTable(void);
+void reset(void);
+int initValues(void);
+void releaseValues(void);
+void printResultF123(char *tc_name, int loop);
+void printResultIndF123(char *tc_name, int loop);
+int startManualTest(char *in);
+int startAutoTest(void);
+void printFieldName(char *);
+
+/* exec sql begin declare section */
+
+    //input variables
+                
+            
+              
+
+    //output variables
+     
+     
+     
+
+     
+
+
+     
+
+
+#line 33 "declare.pgc"
+ int in_f1 = 1 ;
+ 
+#line 34 "declare.pgc"
+ double in_f2 = 10 ;
+ 
+#line 35 "declare.pgc"
+ char in_f3 [ 20 ] = { "one" } ;
+ 
+#line 38 "declare.pgc"
+ int f1 [ OUT_ARRAY_SZIE ] ;
+ 
+#line 39 "declare.pgc"
+ int f2 [ OUT_ARRAY_SZIE ] ;
+ 
+#line 40 "declare.pgc"
+ char f3 [ OUT_ARRAY_SZIE ] [ 20 ] ;
+ 
+#line 42 "declare.pgc"
+ char field_name [ COLUMN_NUM ] [ FIELD_NAME_LEN ] ;
+ 
+#line 45 "declare.pgc"
+ int ind_f1 [ OUT_ARRAY_SZIE ] , ind_f2 [ OUT_ARRAY_SZIE ] , ind_f3 [ OUT_ARRAY_SZIE ] ;
+/* exec sql end declare section */
+#line 47 "declare.pgc"
+
+
+int
+main (int argc, char *argv[])
+{
+    setlocale(LC_ALL, "C");
+
+    ECPGdebug(1, stderr);
+
+    /* connect to database */
+    { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "con1", 0); 
+#line 57 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 57 "declare.pgc"
+
+    { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "con2", 0); 
+#line 58 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 58 "declare.pgc"
+
+    { ECPGconnect(__LINE__, 0, "ecpg3_regression" , NULL, NULL , "con3", 0); 
+#line 59 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 59 "declare.pgc"
+
+
+    if(initValues())
+    {
+        printf("Error: initValues return error!\n");
+
+        releaseValues();
+        return -1;
+    }
+
+    if(argc == 2) //start manual test
+    {
+        printf("Start manual test! \n");
+        startManualTest(argv[1]);
+    }
+    else  //start auto test
+    {
+        startAutoTest();
+    }
+
+    { ECPGdisconnect(__LINE__, "con1");
+#line 79 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 79 "declare.pgc"
+
+
+    { ECPGdisconnect(__LINE__, "ALL");
+#line 81 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 81 "declare.pgc"
+
+
+    releaseValues();
+
+    return (0);
+}
+
+int startManualTest(char *in)
+{
+    if(!strcmp(in,"cr"))
+    {
+        createTable();
+    }
+    else if(!strcmp(in,"dr"))
+    {
+        dropTable();
+    }
+    else if(!strcmp(in,"re"))
+    {
+        reCreateTable();
+    }
+    else if(!strcmp(in,"help"))
+    {
+        printf("====Supporting the following parameters====\n");
+        printf("1. cr -- create tables\n");
+        printf("2. dr -- drop tables\n");
+        printf("3. re -- drop tables and create tables\n");
+        printf("4. testcaseX where X is a digit form 1 to %d\n",TEST_CASE_NUM);
+        printf("If you don't give any parameter, the program will start the test from the testcase1 to testcase%d automatically\n",TEST_CASE_NUM);
+    }
+    else
+    {
+        declare_test(in);
+    }
+
+    commitTable();
+
+    return 0;
+}
+
+int startAutoTest()
+{
+    int i;
+    char tc_name[20];
+
+    dropTable();
+
+    if(createTable())
+    {
+        printf("Error: createTable return error!\n");
+        return -1;
+    }
+
+    for(i=1;i<=TEST_CASE_NUM;i++)
+    {
+        sprintf(tc_name,"testcase%d",i);
+        declare_test(tc_name);
+    }
+
+    dropTable();
+
+    return 0;
+}
+
+
+/*
+ * default connection: con3
+ * Non-default connection: con1, con2
+ *
+ * testcase1. using DECLARE STATEMENT, let CURSOR statement precede PREPARE statement
+ *        ---test result: ok
+ * testcase2. without using DECLARE STATEMENT, let CURSOR statement precede PREPARE statement
+ *        ---test result: ok
+ *
+ * testcase3. using DECLARE STATEMENT at con1, using PREPARE and EXECUTE statement without using AT clause
+ *        ---test result: ok
+ * testcase4. using DECLARE STATEMENT at con1, using PREPARE and EXECUTE statement at con2
+ *        ---test result: ok
+ * testcase5. using DECLARE STATEMENT at con1, using PREPARE and CURSOR statement without using AT clause
+ *        ---test result: ok
+ * testcase6. using DECLARE STATEMENT at con1, using PREPARE and CURSOR statement at con2
+ *        ---test result: ok
+ * testcase7. using DECLARE STATEMENT at con1, using DESCRIBE statement without using AT clause
+ *        ---test result: ok
+ * testcase8. using DECLARE STATEMENT at con1, using DESCRIBE statement at con2
+ *        ---test result: ok
+ *
+ * testcase9. using DECLARE STATEMENT at con3, using PREPARE and EXECUTE statement without using AT clause
+ *        ---test result: ok
+ * testcase10. using DECLARE STATEMENT at con3, using PREPARE and EXECUTE statement at con2
+ *        ---test result: ok
+ * testcase11. using DECLARE STATEMENT at con3, using PREPARE and CURSOR statement without using AT clause
+ *        ---test result: ok
+ * testcase12. using DECLARE STATEMENT at con3, using PREPARE and CURSOR statement at con2
+ *        ---test result: ok
+ * testcase13. using DECLARE STATEMENT at con3, using DESCRIBE statement without using AT clause
+ *        ---test result: ok
+ * testcase14. using DECLARE STATEMENT at con3, using DESCRIBE statement at con2
+ *        ---test result: ok
+ *
+ * testcase15. using DECLARE STATEMENT without using AT clause, using PREPARE and EXECUTE statement without using AT clause
+ *        ---test result: ok
+ * testcase16. using DECLARE STATEMENT without using AT clause, using PREPARE and EXECUTE statement at con2
+ *        ---test result: ok
+ * testcase17. using DECLARE STATEMENT without using AT clause, using PREPARE and CURSOR statement without using AT clause
+ *        ---test result: ok
+ * testcase18. using DECLARE STATEMENT without using AT clause, using PREPARE and CURSOR statement at con2
+ *        ---test result: ok
+ * testcase19. using DECLARE STATEMENT without using AT clause, using DESCRIBE statement without using AT clause
+ *        ---test result: ok
+ * testcase20. using DECLARE STATEMENT without using AT clause, using DESCRIBE statement at con2
+ *        ---test result: ok
+
+ * testcase21. using DECLARE STATEMENT at con1, using PREPARE and EXECUTE statement at con2
+ *            using quoted string as declared name
+ *        ---test result: ok
+ * testcase22. using DECLARE STATEMENT at con1, using PREPARE and CURSOR statement at con2
+ *            using quoted string as declared name
+ *        ---test result: ok
+ * testcase23. using DECLARE STATEMENT at con1, using DESCRIBE statement at con2
+ *            using quoted string as declared name
+ *        ---test result: ok
+ *
+ * testcase24. using DECLARE STATEMENT at con1, using PREPARE and EXECUTE statement at con2
+ *            using host variable as declared name
+ *        ---test result:
+ *
+ * testcase25. using DECLARE STATEMENT at con1, using PREPARE and EXECUTE statement at con2 and without referring the DECLARE statement
+ *        ---test result: ok
+ * testcase26. using DECLARE STATEMENT at con1, using PREPARE and CURSOR statement at con2 and without referring the DECLARE statement
+ *        ---test result: ok
+ * testcase27. using DECLARE STATEMENT at con1, using PREPARE and DESCRIBE statement at con2 and without referring the DECLARE statement
+ *        ---test result: ok
+ *
+ * testcase28. Using host variable as cursor name in the DECLARE/OPEN CURSOR statement,
+ *             using the content in the host variable as the cursor name in the CLOSE CURSOR statement
+ *             This is nothing with DECLARE STATEMENT feature, this case just verify a bug that cursor name can be closed by using
+ *             content of host variable while the cursor name is declared/opened by using the host variable.
+ *        ---test result: ok
+ *
+ * testcase29. using DECLARE STATEMENT at con1, using PREPARE and CURSOR statement without using AT clause
+ *             one cursor is set to "open" and "close" twice.
+ *             Check the declared name can be referred by the cursor at the second time correctly
+ *        ---test result: ok
+ */
+void declare_test(char * tc_name)
+{
+    /* exec sql begin declare section */
+     
+
+          
+          
+
+          
+          
+          
+
+          
+
+          
+
+    
+#line 229 "declare.pgc"
+ int i ;
+ 
+#line 231 "declare.pgc"
+ char * selectString = "SELECT f1,f2,f3 FROM source where f1<4" ;
+ 
+#line 232 "declare.pgc"
+ char * selectTb1 = "SELECT * FROM tb1" ;
+ 
+#line 234 "declare.pgc"
+ char * stmt_4 = "str_stmt_4" ;
+ 
+#line 235 "declare.pgc"
+ char * stmt_6 = "str_stmt_6" ;
+ 
+#line 236 "declare.pgc"
+ char * stmt_8 = "str_stmt_8" ;
+ 
+#line 238 "declare.pgc"
+ char * cur_6 = "str_cur_6" ;
+ 
+#line 240 "declare.pgc"
+ char * desc_8 = "str_desc_8" ;
+/* exec sql end declare section */
+#line 242 "declare.pgc"
+
+
+    if(!strcmp(tc_name,"testcase1"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, NULL, "stmt_1");
+#line 248 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 248 "declare.pgc"
+
+        /* declare cur_1 cursor for $1 */
+#line 249 "declare.pgc"
+
+        { ECPGprepare(__LINE__, NULL, 0, "stmt_1", selectString);
+#line 250 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 250 "declare.pgc"
+
+        { ECPGopen("cur_1", "stmt_1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_1 cursor for $1", 
+	ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt_1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 251 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 251 "declare.pgc"
+
+
+        /* exec sql whenever not found  break ; */
+#line 253 "declare.pgc"
+
+        i = 0;
+        while(1)
+        {
+            { ECPGfetch("cur_1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_1", ECPGt_EOIT, 
+	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 257 "declare.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 257 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 257 "declare.pgc"
+
+            i++;
+        }
+
+        { ECPGclose("cur_1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_1", ECPGt_EOIT, ECPGt_EORT);
+#line 261 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 261 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, NULL, "stmt_1");
+#line 262 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 262 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase2"))
+    {
+        reset();
+
+        /* declare cur_2 cursor for $1 */
+#line 270 "declare.pgc"
+
+        { ECPGprepare(__LINE__, NULL, 0, "stmt_2", selectString);
+#line 271 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 271 "declare.pgc"
+
+        { ECPGopen("cur_2", "stmt_2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_2 cursor for $1", 
+	ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt_2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 272 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 272 "declare.pgc"
+
+
+        /* exec sql whenever not found  break ; */
+#line 274 "declare.pgc"
+
+        i = 0;
+        while(1)
+        {
+            { ECPGfetch("cur_2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_2", ECPGt_EOIT, 
+	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 278 "declare.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 278 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 278 "declare.pgc"
+
+            i++;
+        }
+
+        { ECPGclose("cur_2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_2", ECPGt_EOIT, ECPGt_EORT);
+#line 282 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 282 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, NULL, "stmt_2");
+#line 283 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 283 "declare.pgc"
+
+
+        /* exec sql whenever not found  continue ; */
+#line 285 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase3"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, "con1", "stmt_3");
+#line 293 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 293 "declare.pgc"
+
+        { ECPGprepare(__LINE__, NULL, 0, "stmt_3", selectString);
+#line 294 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 294 "declare.pgc"
+
+        { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt_3", ECPGt_EOIT, 
+	ECPGt_int,(f1),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,(f2),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3),(long)20,(long)OUT_ARRAY_SZIE,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 295 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 295 "declare.pgc"
+
+
+        { ECPGdeallocate(__LINE__, 0, NULL, "stmt_3");
+#line 297 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 297 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase4"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, "con1", "stmt_4");
+#line 305 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 305 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, "stmt_4", selectString);
+#line 306 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 306 "declare.pgc"
+
+        { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_execute, "stmt_4", ECPGt_EOIT, 
+	ECPGt_int,(f1),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,(f2),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3),(long)20,(long)OUT_ARRAY_SZIE,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 307 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 307 "declare.pgc"
+
+
+        { ECPGdeallocate(__LINE__, 0, NULL, "stmt_4");
+#line 309 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 309 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+
+        reset();
+
+        { ECPGdeclare(__LINE__, "con1", stmt_4);
+#line 315 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 315 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, stmt_4, selectString);
+#line 316 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 316 "declare.pgc"
+
+        { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_execute, stmt_4, ECPGt_EOIT, 
+	ECPGt_int,(f1),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,(f2),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3),(long)20,(long)OUT_ARRAY_SZIE,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 317 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 317 "declare.pgc"
+
+
+        { ECPGdeallocate(__LINE__, 0, NULL, stmt_4);
+#line 319 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 319 "declare.pgc"
+
+
+        printResultF123(NULL,3);
+    }
+    else if(!strcmp(tc_name,"testcase5"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, "con1", "stmt_5");
+#line 327 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 327 "declare.pgc"
+
+        { ECPGprepare(__LINE__, NULL, 0, "stmt_5", selectString);
+#line 328 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 328 "declare.pgc"
+
+        /* declare cur_5 cursor for $1 */
+#line 329 "declare.pgc"
+
+        { ECPGopen("cur_5", "stmt_5", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_5 cursor for $1", 
+	ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt_5", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 330 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 330 "declare.pgc"
+
+
+        /* exec sql whenever not found  break ; */
+#line 332 "declare.pgc"
+
+        i = 0;
+        while(1)
+        {
+            { ECPGfetch("cur_5", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_5", ECPGt_EOIT, 
+	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 336 "declare.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 336 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 336 "declare.pgc"
+
+            i++;
+        }
+
+        { ECPGclose("cur_5", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_5", ECPGt_EOIT, ECPGt_EORT);
+#line 340 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 340 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, NULL, "stmt_5");
+#line 341 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 341 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase6"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, "con1", "stmt_6");
+#line 349 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 349 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, "stmt_6", selectString);
+#line 350 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 350 "declare.pgc"
+
+        /* declare cur_6 cursor for $1 */
+#line 351 "declare.pgc"
+
+        { ECPGopen("cur_6", "stmt_6", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "declare cur_6 cursor for $1", 
+	ECPGt_char_variable,(ECPGprepared_statement("con2", "stmt_6", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 352 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 352 "declare.pgc"
+
+
+        /* exec sql whenever not found  break ; */
+#line 354 "declare.pgc"
+
+        i = 0;
+        while(1)
+        {
+            { ECPGfetch("cur_6", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "fetch cur_6", ECPGt_EOIT, 
+	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 358 "declare.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 358 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 358 "declare.pgc"
+
+            i++;
+        }
+
+        { ECPGclose("cur_6", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "close cur_6", ECPGt_EOIT, ECPGt_EORT);
+#line 362 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 362 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, "con2", "stmt_6");
+#line 363 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 363 "declare.pgc"
+
+        /* exec sql whenever not found  continue ; */
+#line 364 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+
+        reset();
+
+        { ECPGdeclare(__LINE__, "con1", stmt_6);
+#line 370 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 370 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, stmt_6, selectString);
+#line 371 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 371 "declare.pgc"
+
+        ECPGset_var( 0, &( cur_6 ), __LINE__);\
+ /* declare $0 cursor for $1 */
+#line 372 "declare.pgc"
+
+        { ECPGopen(":cur_6", stmt_6, __LINE__, 0, 1, "con2", 0, ECPGst_normal, "declare $0 cursor for $1", 
+	ECPGt_char,&(cur_6),(long)0,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char_variable,(ECPGprepared_statement("con2", stmt_6, __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 373 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 373 "declare.pgc"
+
+
+        /* exec sql whenever not found  break ; */
+#line 375 "declare.pgc"
+
+        i = 0;
+        while(1)
+        {
+            { ECPGfetch(":cur_6", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "fetch $0", 
+	ECPGt_char,&(cur_6),(long)0,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 379 "declare.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 379 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 379 "declare.pgc"
+
+            i++;
+        }
+
+        { ECPGclose(":cur_6", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "close $0", 
+	ECPGt_char,&(cur_6),(long)0,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 383 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 383 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, "con2", stmt_6);
+#line 384 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 384 "declare.pgc"
+
+        /* exec sql whenever not found  continue ; */
+#line 385 "declare.pgc"
+
+
+        printResultF123(NULL,3);
+    }
+    else if(!strcmp(tc_name,"testcase7"))
+    {
+        reset();
+
+        ECPGallocate_desc(__LINE__, "desc_7");
+#line 393 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 393 "declare.pgc"
+
+
+        { ECPGdeclare(__LINE__, "con1", "stmt_7");
+#line 395 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 395 "declare.pgc"
+
+        { ECPGprepare(__LINE__, NULL, 0, "stmt_7", selectTb1);
+#line 396 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 396 "declare.pgc"
+
+        { ECPGdescribe(__LINE__, 0, 0, NULL, "stmt_7",
+	ECPGt_descriptor, "desc_7", 1L, 1L, 1L, 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+#line 397 "declare.pgc"
+
+
+        for(i=1; i<4; i++)
+        {
+            { ECPGget_desc(__LINE__, "desc_7", i,ECPGd_name,
+	ECPGt_char,(field_name[i-1]),(long)FIELD_NAME_LEN,(long)1,(FIELD_NAME_LEN)*sizeof(char), ECPGd_EODT);
+
+#line 401 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 401 "declare.pgc"
+
+        }
+
+        ECPGdeallocate_desc(__LINE__, "desc_7");
+#line 404 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 404 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, NULL, "stmt_7");
+#line 405 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 405 "declare.pgc"
+
+
+        printFieldName(tc_name);
+    }
+    else if(!strcmp(tc_name,"testcase8"))
+    {
+        reset();
+
+        ECPGallocate_desc(__LINE__, "desc_8");
+#line 413 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 413 "declare.pgc"
+
+
+        { ECPGdeclare(__LINE__, "con1", "stmt_8");
+#line 415 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 415 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, "stmt_8", selectTb1);
+#line 416 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 416 "declare.pgc"
+
+        { ECPGdescribe(__LINE__, 0, 0, "con2", "stmt_8",
+	ECPGt_descriptor, "desc_8", 1L, 1L, 1L, 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+#line 417 "declare.pgc"
+
+
+        for(i=1; i<4; i++)
+        {
+            { ECPGget_desc(__LINE__, "desc_8", i,ECPGd_name,
+	ECPGt_char,(field_name[i-1]),(long)FIELD_NAME_LEN,(long)1,(FIELD_NAME_LEN)*sizeof(char), ECPGd_EODT);
+
+#line 421 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 421 "declare.pgc"
+
+        }
+
+        ECPGdeallocate_desc(__LINE__, "desc_8");
+#line 424 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 424 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, "con2", "stmt_8");
+#line 425 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 425 "declare.pgc"
+
+
+        printFieldName(tc_name);
+
+
+        reset();
+
+        ECPGallocate_desc(__LINE__, (desc_8));
+#line 432 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 432 "declare.pgc"
+
+
+        { ECPGdeclare(__LINE__, "con1", stmt_8);
+#line 434 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 434 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, stmt_8, selectTb1);
+#line 435 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 435 "declare.pgc"
+
+        { ECPGdescribe(__LINE__, 0, 0, "con2", stmt_8,
+	ECPGt_descriptor, (desc_8), 1L, 1L, 1L, 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+#line 436 "declare.pgc"
+
+
+        for(i=1; i<4; i++)
+        {
+            { ECPGget_desc(__LINE__, (desc_8), i,ECPGd_name,
+	ECPGt_char,(field_name[i-1]),(long)FIELD_NAME_LEN,(long)1,(FIELD_NAME_LEN)*sizeof(char), ECPGd_EODT);
+
+#line 440 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 440 "declare.pgc"
+
+        }
+
+        ECPGdeallocate_desc(__LINE__, (desc_8));
+#line 443 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 443 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, "con2", stmt_8);
+#line 444 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 444 "declare.pgc"
+
+
+        printFieldName(NULL);
+    }
+    else if(!strcmp(tc_name,"testcase9"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, "con3", "stmt_9");
+#line 452 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 452 "declare.pgc"
+
+        { ECPGprepare(__LINE__, NULL, 0, "stmt_9", selectString);
+#line 453 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 453 "declare.pgc"
+
+        { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt_9", ECPGt_EOIT, 
+	ECPGt_int,(f1),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,(f2),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3),(long)20,(long)OUT_ARRAY_SZIE,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 454 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 454 "declare.pgc"
+
+
+        { ECPGdeallocate(__LINE__, 0, NULL, "stmt_9");
+#line 456 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 456 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase10"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, "con3", "stmt_10");
+#line 464 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 464 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, "stmt_10", selectString);
+#line 465 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 465 "declare.pgc"
+
+        { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_execute, "stmt_10", ECPGt_EOIT, 
+	ECPGt_int,(f1),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,(f2),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3),(long)20,(long)OUT_ARRAY_SZIE,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 466 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 466 "declare.pgc"
+
+
+        { ECPGdeallocate(__LINE__, 0, "con2", "stmt_10");
+#line 468 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 468 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase11"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, "con3", "stmt_11");
+#line 476 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 476 "declare.pgc"
+
+        { ECPGprepare(__LINE__, NULL, 0, "stmt_11", selectString);
+#line 477 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 477 "declare.pgc"
+
+        /* declare cur_11 cursor for $1 */
+#line 478 "declare.pgc"
+
+        { ECPGopen("cur_11", "stmt_11", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_11 cursor for $1", 
+	ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt_11", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 479 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 479 "declare.pgc"
+
+
+        /* exec sql whenever not found  break ; */
+#line 481 "declare.pgc"
+
+        i = 0;
+        while(1)
+        {
+            { ECPGfetch("cur_11", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_11", ECPGt_EOIT, 
+	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 485 "declare.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 485 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 485 "declare.pgc"
+
+            i++;
+        }
+
+        { ECPGclose("cur_11", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_11", ECPGt_EOIT, ECPGt_EORT);
+#line 489 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 489 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, NULL, "stmt_11");
+#line 490 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 490 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase12"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, "con3", "stmt_12");
+#line 498 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 498 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, "stmt_12", selectString);
+#line 499 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 499 "declare.pgc"
+
+        /* declare cur_12 cursor for $1 */
+#line 500 "declare.pgc"
+
+        { ECPGopen("cur_12", "stmt_12", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "declare cur_12 cursor for $1", 
+	ECPGt_char_variable,(ECPGprepared_statement("con2", "stmt_12", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 501 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 501 "declare.pgc"
+
+
+        /* exec sql whenever not found  break ; */
+#line 503 "declare.pgc"
+
+        i = 0;
+        while(1)
+        {
+            { ECPGfetch("cur_12", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "fetch cur_12", ECPGt_EOIT, 
+	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 507 "declare.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 507 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 507 "declare.pgc"
+
+            i++;
+        }
+
+        { ECPGclose("cur_12", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "close cur_12", ECPGt_EOIT, ECPGt_EORT);
+#line 511 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 511 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, "con2", "stmt_12");
+#line 512 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 512 "declare.pgc"
+
+        /* exec sql whenever not found  continue ; */
+#line 513 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase13"))
+    {
+        reset();
+
+        ECPGallocate_desc(__LINE__, "desc_13");
+#line 521 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 521 "declare.pgc"
+
+
+        { ECPGdeclare(__LINE__, "con3", "stmt_13");
+#line 523 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 523 "declare.pgc"
+
+        { ECPGprepare(__LINE__, NULL, 0, "stmt_13", selectTb1);
+#line 524 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 524 "declare.pgc"
+
+        { ECPGdescribe(__LINE__, 0, 0, NULL, "stmt_13",
+	ECPGt_descriptor, "desc_13", 1L, 1L, 1L, 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+#line 525 "declare.pgc"
+
+
+        for(i=1; i<4; i++)
+        {
+            { ECPGget_desc(__LINE__, "desc_13", i,ECPGd_name,
+	ECPGt_char,(field_name[i-1]),(long)FIELD_NAME_LEN,(long)1,(FIELD_NAME_LEN)*sizeof(char), ECPGd_EODT);
+
+#line 529 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 529 "declare.pgc"
+
+        }
+
+        ECPGdeallocate_desc(__LINE__, "desc_13");
+#line 532 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 532 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, NULL, "stmt_13");
+#line 533 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 533 "declare.pgc"
+
+
+        printFieldName(tc_name);
+    }
+    else if(!strcmp(tc_name,"testcase14"))
+    {
+        reset();
+
+        ECPGallocate_desc(__LINE__, "desc_14");
+#line 541 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 541 "declare.pgc"
+
+
+        { ECPGdeclare(__LINE__, "con3", "stmt_14");
+#line 543 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 543 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, "stmt_14", selectTb1);
+#line 544 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 544 "declare.pgc"
+
+        { ECPGdescribe(__LINE__, 0, 0, "con2", "stmt_14",
+	ECPGt_descriptor, "desc_14", 1L, 1L, 1L, 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+#line 545 "declare.pgc"
+
+
+        for(i=1; i<4; i++)
+        {
+            { ECPGget_desc(__LINE__, "desc_14", i,ECPGd_name,
+	ECPGt_char,(field_name[i-1]),(long)FIELD_NAME_LEN,(long)1,(FIELD_NAME_LEN)*sizeof(char), ECPGd_EODT);
+
+#line 549 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 549 "declare.pgc"
+
+        }
+
+        ECPGdeallocate_desc(__LINE__, "desc_14");
+#line 552 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 552 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, "con2", "stmt_14");
+#line 553 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 553 "declare.pgc"
+
+
+        printFieldName(tc_name);
+    }
+    else if(!strcmp(tc_name,"testcase15"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, NULL, "stmt_15");
+#line 561 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 561 "declare.pgc"
+
+        { ECPGprepare(__LINE__, NULL, 0, "stmt_15", selectString);
+#line 562 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 562 "declare.pgc"
+
+        { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "stmt_15", ECPGt_EOIT, 
+	ECPGt_int,(f1),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,(f2),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3),(long)20,(long)OUT_ARRAY_SZIE,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 563 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 563 "declare.pgc"
+
+
+        { ECPGdeallocate(__LINE__, 0, NULL, "stmt_15");
+#line 565 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 565 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase16"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, NULL, "stmt_16");
+#line 573 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 573 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, "stmt_16", selectString);
+#line 574 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 574 "declare.pgc"
+
+        { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_execute, "stmt_16", ECPGt_EOIT, 
+	ECPGt_int,(f1),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,(f2),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3),(long)20,(long)OUT_ARRAY_SZIE,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 575 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 575 "declare.pgc"
+
+
+        { ECPGdeallocate(__LINE__, 0, "con2", "stmt_16");
+#line 577 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 577 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase17"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, NULL, "stmt_17");
+#line 585 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 585 "declare.pgc"
+
+        { ECPGprepare(__LINE__, NULL, 0, "stmt_17", selectString);
+#line 586 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 586 "declare.pgc"
+
+        /* declare cur_17 cursor for $1 */
+#line 587 "declare.pgc"
+
+        { ECPGopen("cur_17", "stmt_17", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_17 cursor for $1", 
+	ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt_17", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 588 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 588 "declare.pgc"
+
+
+        /* exec sql whenever not found  break ; */
+#line 590 "declare.pgc"
+
+        i = 0;
+        while(1)
+        {
+            { ECPGfetch("cur_17", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_17", ECPGt_EOIT, 
+	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 594 "declare.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 594 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 594 "declare.pgc"
+
+            i++;
+        }
+
+        { ECPGclose("cur_17", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_17", ECPGt_EOIT, ECPGt_EORT);
+#line 598 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 598 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, NULL, "stmt_17");
+#line 599 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 599 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase18"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, NULL, "stmt_18");
+#line 607 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 607 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, "stmt_18", selectString);
+#line 608 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 608 "declare.pgc"
+
+        /* declare cur_18 cursor for $1 */
+#line 609 "declare.pgc"
+
+        { ECPGopen("cur_18", "stmt_18", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "declare cur_18 cursor for $1", 
+	ECPGt_char_variable,(ECPGprepared_statement("con2", "stmt_18", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 610 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 610 "declare.pgc"
+
+
+        /* exec sql whenever not found  break ; */
+#line 612 "declare.pgc"
+
+        i = 0;
+        while(1)
+        {
+            { ECPGfetch("cur_18", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "fetch cur_18", ECPGt_EOIT, 
+	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 616 "declare.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 616 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 616 "declare.pgc"
+
+            i++;
+        }
+
+        { ECPGclose("cur_18", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "close cur_18", ECPGt_EOIT, ECPGt_EORT);
+#line 620 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 620 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, "con2", "stmt_18");
+#line 621 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 621 "declare.pgc"
+
+        /* exec sql whenever not found  continue ; */
+#line 622 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase19"))
+    {
+        reset();
+
+        ECPGallocate_desc(__LINE__, "desc_19");
+#line 630 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 630 "declare.pgc"
+
+
+        { ECPGdeclare(__LINE__, NULL, "stmt_19");
+#line 632 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 632 "declare.pgc"
+
+        { ECPGprepare(__LINE__, NULL, 0, "stmt_19", selectTb1);
+#line 633 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 633 "declare.pgc"
+
+        { ECPGdescribe(__LINE__, 0, 0, NULL, "stmt_19",
+	ECPGt_descriptor, "desc_19", 1L, 1L, 1L, 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+#line 634 "declare.pgc"
+
+
+        for(i=1; i<4; i++)
+        {
+            { ECPGget_desc(__LINE__, "desc_19", i,ECPGd_name,
+	ECPGt_char,(field_name[i-1]),(long)FIELD_NAME_LEN,(long)1,(FIELD_NAME_LEN)*sizeof(char), ECPGd_EODT);
+
+#line 638 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 638 "declare.pgc"
+
+        }
+
+        ECPGdeallocate_desc(__LINE__, "desc_19");
+#line 641 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 641 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, NULL, "stmt_19");
+#line 642 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 642 "declare.pgc"
+
+
+        printFieldName(tc_name);
+    }
+    else if(!strcmp(tc_name,"testcase20"))
+    {
+        reset();
+
+        ECPGallocate_desc(__LINE__, "desc_20");
+#line 650 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 650 "declare.pgc"
+
+
+        { ECPGdeclare(__LINE__, NULL, "stmt_20");
+#line 652 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 652 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, "stmt_20", selectTb1);
+#line 653 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 653 "declare.pgc"
+
+        { ECPGdescribe(__LINE__, 0, 0, "con2", "stmt_20",
+	ECPGt_descriptor, "desc_20", 1L, 1L, 1L, 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+#line 654 "declare.pgc"
+
+
+        for(i=1; i<4; i++)
+        {
+            { ECPGget_desc(__LINE__, "desc_20", i,ECPGd_name,
+	ECPGt_char,(field_name[i-1]),(long)FIELD_NAME_LEN,(long)1,(FIELD_NAME_LEN)*sizeof(char), ECPGd_EODT);
+
+#line 658 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 658 "declare.pgc"
+
+        }
+
+        ECPGdeallocate_desc(__LINE__, "desc_20");
+#line 661 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 661 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, "con2", "stmt_20");
+#line 662 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 662 "declare.pgc"
+
+
+        printFieldName(tc_name);
+    }
+    else if(!strcmp(tc_name,"testcase21"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, "con1", "stmt_21");
+#line 670 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 670 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, "stmt_21", selectString);
+#line 671 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 671 "declare.pgc"
+
+        { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_execute, "stmt_21", ECPGt_EOIT, 
+	ECPGt_int,(f1),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,(f2),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3),(long)20,(long)OUT_ARRAY_SZIE,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 672 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 672 "declare.pgc"
+
+
+        { ECPGdeallocate(__LINE__, 0, NULL, "stmt_21");
+#line 674 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 674 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase22"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, "con1", "stmt_22");
+#line 682 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 682 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, "stmt_22", selectString);
+#line 683 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 683 "declare.pgc"
+
+        /* declare \"cur_22\" cursor for $1 */
+#line 684 "declare.pgc"
+
+        { ECPGopen("\"cur_22\"", "stmt_22", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "declare \"cur_22\" cursor for $1", 
+	ECPGt_char_variable,(ECPGprepared_statement("con2", "stmt_22", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 685 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 685 "declare.pgc"
+
+
+        /* exec sql whenever not found  break ; */
+#line 687 "declare.pgc"
+
+        i = 0;
+        while(1)
+        {
+            { ECPGfetch("\"cur_22\"", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "fetch \"cur_22\"", ECPGt_EOIT, 
+	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 691 "declare.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 691 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 691 "declare.pgc"
+
+            i++;
+        }
+
+        { ECPGclose("\"cur_22\"", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "close \"cur_22\"", ECPGt_EOIT, ECPGt_EORT);
+#line 695 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 695 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, "con2", "stmt_22");
+#line 696 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 696 "declare.pgc"
+
+        /* exec sql whenever not found  continue ; */
+#line 697 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase23"))
+    {
+        reset();
+
+        ECPGallocate_desc(__LINE__, "desc_23");
+#line 705 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 705 "declare.pgc"
+
+
+        { ECPGdeclare(__LINE__, "con1", "stmt_23");
+#line 707 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 707 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, "stmt_23", selectTb1);
+#line 708 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 708 "declare.pgc"
+
+        { ECPGdescribe(__LINE__, 0, 0, "con2", "stmt_23",
+	ECPGt_descriptor, "desc_23", 1L, 1L, 1L, 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+#line 709 "declare.pgc"
+
+
+        for(i=1; i<4; i++)
+        {
+            { ECPGget_desc(__LINE__, "desc_23", i,ECPGd_name,
+	ECPGt_char,(field_name[i-1]),(long)FIELD_NAME_LEN,(long)1,(FIELD_NAME_LEN)*sizeof(char), ECPGd_EODT);
+
+#line 713 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 713 "declare.pgc"
+
+        }
+
+        ECPGdeallocate_desc(__LINE__, "desc_23");
+#line 716 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 716 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, "con2", "stmt_23");
+#line 717 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 717 "declare.pgc"
+
+
+        printFieldName(tc_name);
+    }
+    else if(!strcmp(tc_name,"testcase24"))
+    {
+        /* exec sql begin declare section */
+           
+        
+#line 724 "declare.pgc"
+ char * char_stmt_24 = "strSTMT24" ;
+/* exec sql end declare section */
+#line 725 "declare.pgc"
+
+
+        reset();
+
+        { ECPGdeclare(__LINE__, "con1", char_stmt_24);
+#line 729 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 729 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, char_stmt_24, selectString);
+#line 730 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 730 "declare.pgc"
+
+        { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_execute, char_stmt_24, ECPGt_EOIT, 
+	ECPGt_int,(f1),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,(f2),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3),(long)20,(long)OUT_ARRAY_SZIE,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 731 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 731 "declare.pgc"
+
+
+        { ECPGdeallocate(__LINE__, 0, NULL, char_stmt_24);
+#line 733 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 733 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase25"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, "con1", "stmt_25");
+#line 741 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 741 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, "pre_stmt_25", selectString);
+#line 742 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 742 "declare.pgc"
+
+        { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_execute, "pre_stmt_25", ECPGt_EOIT, 
+	ECPGt_int,(f1),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,(f2),(long)1,(long)OUT_ARRAY_SZIE,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3),(long)20,(long)OUT_ARRAY_SZIE,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 743 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 743 "declare.pgc"
+
+
+        { ECPGdeallocate(__LINE__, 0, "con2", "pre_stmt_25");
+#line 745 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 745 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase26"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, "con1", "stmt_26");
+#line 753 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 753 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, "pre_stmt_26", selectString);
+#line 754 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 754 "declare.pgc"
+
+        /* declare cur_26 cursor for $1 */
+#line 755 "declare.pgc"
+
+        { ECPGopen("cur_26", "pre_stmt_26", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "declare cur_26 cursor for $1", 
+	ECPGt_char_variable,(ECPGprepared_statement("con2", "pre_stmt_26", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 756 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 756 "declare.pgc"
+
+
+        /* exec sql whenever not found  break ; */
+#line 758 "declare.pgc"
+
+        i = 0;
+        while(1)
+        {
+            { ECPGfetch("cur_26", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "fetch cur_26", ECPGt_EOIT, 
+	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 762 "declare.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 762 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 762 "declare.pgc"
+
+            i++;
+        }
+
+        { ECPGclose("cur_26", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "close cur_26", ECPGt_EOIT, ECPGt_EORT);
+#line 766 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 766 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, "con2", "pre_stmt_26");
+#line 767 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 767 "declare.pgc"
+
+        /* exec sql whenever not found  continue ; */
+#line 768 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase27"))
+    {
+        reset();
+
+        ECPGallocate_desc(__LINE__, "desc_27");
+#line 776 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 776 "declare.pgc"
+
+
+        { ECPGdeclare(__LINE__, "con1", "stmt_27");
+#line 778 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 778 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, "pre_stmt_27", selectTb1);
+#line 779 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 779 "declare.pgc"
+
+        { ECPGdescribe(__LINE__, 0, 0, "con2", "pre_stmt_27",
+	ECPGt_descriptor, "desc_27", 1L, 1L, 1L, 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+#line 780 "declare.pgc"
+
+
+        for(i=1; i<4; i++)
+        {
+            { ECPGget_desc(__LINE__, "desc_27", i,ECPGd_name,
+	ECPGt_char,(field_name[i-1]),(long)FIELD_NAME_LEN,(long)1,(FIELD_NAME_LEN)*sizeof(char), ECPGd_EODT);
+
+#line 784 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 784 "declare.pgc"
+
+        }
+
+        ECPGdeallocate_desc(__LINE__, "desc_27");
+#line 787 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();
+#line 787 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, "con2", "pre_stmt_27");
+#line 788 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 788 "declare.pgc"
+
+
+        printFieldName(tc_name);
+    }
+    else if(!strcmp(tc_name,"testcase28"))
+    {
+        /* exec sql begin declare section */
+              
+        
+#line 795 "declare.pgc"
+ char * cur_28 = "str_cur_28" ;
+/* exec sql end declare section */
+#line 796 "declare.pgc"
+
+
+        reset();
+
+        { ECPGdeclare(__LINE__, "con1", "stmt_28");
+#line 800 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 800 "declare.pgc"
+
+        { ECPGprepare(__LINE__, "con2", 0, "stmt_28", selectString);
+#line 801 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 801 "declare.pgc"
+
+        ECPGset_var( 1, &( cur_28 ), __LINE__);\
+ /* declare $0 cursor for $1 */
+#line 802 "declare.pgc"
+
+        { ECPGopen(":cur_28", "stmt_28", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "declare $0 cursor for $1", 
+	ECPGt_char,&(cur_28),(long)0,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char_variable,(ECPGprepared_statement("con2", "stmt_28", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 803 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 803 "declare.pgc"
+
+
+        /* exec sql whenever not found  break ; */
+#line 805 "declare.pgc"
+
+        i = 0;
+        while(1)
+        {
+            { ECPGfetch(":cur_28", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "fetch $0", 
+	ECPGt_char,&(cur_28),(long)0,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 809 "declare.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 809 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 809 "declare.pgc"
+
+            i++;
+        }
+
+        { ECPGclose("str_cur_28", __LINE__, 0, 1, "con2", 0, ECPGst_normal, "close str_cur_28", ECPGt_EOIT, ECPGt_EORT);
+#line 813 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 813 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, "con2", "stmt_28");
+#line 814 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 814 "declare.pgc"
+
+        /* exec sql whenever not found  continue ; */
+#line 815 "declare.pgc"
+
+
+        printResultF123(tc_name,3);
+
+    }
+    else if(!strcmp(tc_name,"testcase29"))
+    {
+        reset();
+
+        { ECPGdeclare(__LINE__, "con1", "stmt_29");
+#line 824 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 824 "declare.pgc"
+
+        { ECPGprepare(__LINE__, NULL, 0, "stmt_29", selectString);
+#line 825 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 825 "declare.pgc"
+
+        /* declare cur_29 cursor for $1 */
+#line 826 "declare.pgc"
+
+
+        { ECPGopen("cur_29", "stmt_29", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_29 cursor for $1", 
+	ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt_29", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 828 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 828 "declare.pgc"
+
+
+        /* exec sql whenever not found  break ; */
+#line 830 "declare.pgc"
+
+        i = 0;
+        while(1)
+        {
+            { ECPGfetch("cur_29", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_29", ECPGt_EOIT, 
+	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 834 "declare.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 834 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 834 "declare.pgc"
+
+            i++;
+        }
+
+        { ECPGclose("cur_29", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_29", ECPGt_EOIT, ECPGt_EORT);
+#line 838 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 838 "declare.pgc"
+
+        printResultF123(tc_name,3);
+
+        reset();
+        /* Open and fetch cursor again */
+        { ECPGopen("cur_29", "stmt_29", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_29 cursor for $1", 
+	ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt_29", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+#line 843 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 843 "declare.pgc"
+
+        i = 0;
+        while(1)
+        {
+            { ECPGfetch("cur_29", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_29", ECPGt_EOIT, 
+	ECPGt_int,&(f1[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_int,&(f2[i]),(long)1,(long)1,sizeof(int), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+	ECPGt_char,(f3[i]),(long)20,(long)1,(20)*sizeof(char), 
+	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+#line 847 "declare.pgc"
+
+if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+#line 847 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 847 "declare.pgc"
+
+            i++;
+        }
+
+        { ECPGclose("cur_29", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_29", ECPGt_EOIT, ECPGt_EORT);
+#line 851 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 851 "declare.pgc"
+
+        { ECPGdeallocate(__LINE__, 0, NULL, "stmt_29");
+#line 852 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 852 "declare.pgc"
+
+        /* exec sql whenever not found  continue ; */
+#line 853 "declare.pgc"
+
+
+        printResultF123(NULL,3);
+    }
+    else
+    {
+        /* exec sql whenever not found  continue ; */
+#line 859 "declare.pgc"
+
+        printf("Sorry, there isn't this testcase: %s!\n",tc_name);
+    }
+}
+
+
+/*
+ * success -- 0
+ * failed -- -1
+ */
+int createTable()
+{
+    { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "create table source ( f1 integer , f2 integer , f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT);
+#line 871 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 871 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "create table source ( f1 integer , f2 integer , f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT);
+#line 872 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 872 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con3", 0, ECPGst_normal, "create table source ( f1 integer , f2 integer , f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT);
+#line 873 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 873 "declare.pgc"
+
+
+    { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "create table tb1 ( con1_f1 integer , con1_f2 integer , con1_f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT);
+#line 875 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 875 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "create table tb1 ( con2_f1 integer , con2_f2 integer , con2_f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT);
+#line 876 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 876 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con3", 0, ECPGst_normal, "create table tb1 ( con3_f1 integer , con3_f2 integer , con3_f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT);
+#line 877 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 877 "declare.pgc"
+
+
+    { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "create table target ( f1 integer , f2 integer , f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT);
+#line 879 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 879 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "create table target ( f1 integer , f2 integer , f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT);
+#line 880 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 880 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con3", 0, ECPGst_normal, "create table target ( f1 integer , f2 integer , f3 varchar ( 20 ) )", ECPGt_EOIT, ECPGt_EORT);
+#line 881 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 881 "declare.pgc"
+
+
+
+
+    { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "insert into source values ( 1 , 10 , 'db on con1' )", ECPGt_EOIT, ECPGt_EORT);
+#line 885 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 885 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "insert into source values ( 2 , 20 , 'db on con1' )", ECPGt_EOIT, ECPGt_EORT);
+#line 886 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 886 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "insert into source values ( 3 , 30 , 'db on con1' )", ECPGt_EOIT, ECPGt_EORT);
+#line 887 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 887 "declare.pgc"
+
+
+    { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "insert into source values ( 1 , 10 , 'db on con2' )", ECPGt_EOIT, ECPGt_EORT);
+#line 889 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 889 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "insert into source values ( 2 , 20 , 'db on con2' )", ECPGt_EOIT, ECPGt_EORT);
+#line 890 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 890 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "insert into source values ( 3 , 30 , 'db on con2' )", ECPGt_EOIT, ECPGt_EORT);
+#line 891 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 891 "declare.pgc"
+
+
+    { ECPGdo(__LINE__, 0, 1, "con3", 0, ECPGst_normal, "insert into source values ( 1 , 10 , 'db on con3' )", ECPGt_EOIT, ECPGt_EORT);
+#line 893 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 893 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con3", 0, ECPGst_normal, "insert into source values ( 2 , 20 , 'db on con3' )", ECPGt_EOIT, ECPGt_EORT);
+#line 894 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 894 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con3", 0, ECPGst_normal, "insert into source values ( 3 , 30 , 'db on con3' )", ECPGt_EOIT, ECPGt_EORT);
+#line 895 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 895 "declare.pgc"
+
+
+    commitTable();
+
+    return 0;
+}
+
+/*
+ * success -- 0
+ * failed -- -1
+ */
+void dropTable()
+{
+    { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "drop table if exists source", ECPGt_EOIT, ECPGt_EORT);
+#line 908 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 908 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "drop table if exists source", ECPGt_EOIT, ECPGt_EORT);
+#line 909 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 909 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con3", 0, ECPGst_normal, "drop table if exists source", ECPGt_EOIT, ECPGt_EORT);
+#line 910 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 910 "declare.pgc"
+
+
+    { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "drop table if exists target", ECPGt_EOIT, ECPGt_EORT);
+#line 912 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 912 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "drop table if exists target", ECPGt_EOIT, ECPGt_EORT);
+#line 913 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 913 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con3", 0, ECPGst_normal, "drop table if exists target", ECPGt_EOIT, ECPGt_EORT);
+#line 914 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 914 "declare.pgc"
+
+
+    { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "drop table if exists tb1", ECPGt_EOIT, ECPGt_EORT);
+#line 916 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 916 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "drop table if exists tb1", ECPGt_EOIT, ECPGt_EORT);
+#line 917 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 917 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con3", 0, ECPGst_normal, "drop table if exists tb1", ECPGt_EOIT, ECPGt_EORT);
+#line 918 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 918 "declare.pgc"
+
+
+    commitTable();
+}
+
+void reCreateTable()
+{
+    dropTable();
+    createTable();
+}
+
+void truncateTable()
+{
+    { ECPGdo(__LINE__, 0, 1, "con1", 0, ECPGst_normal, "truncate table target", ECPGt_EOIT, ECPGt_EORT);
+#line 931 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 931 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_normal, "truncate table target", ECPGt_EOIT, ECPGt_EORT);
+#line 932 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 932 "declare.pgc"
+
+    { ECPGdo(__LINE__, 0, 1, "con3", 0, ECPGst_normal, "truncate table target", ECPGt_EOIT, ECPGt_EORT);
+#line 933 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 933 "declare.pgc"
+
+
+    commitTable();
+}
+
+void commitTable()
+{
+    { ECPGtrans(__LINE__, "con1", "commit");
+#line 940 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 940 "declare.pgc"
+
+    { ECPGtrans(__LINE__, "con2", "commit");
+#line 941 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 941 "declare.pgc"
+
+    { ECPGtrans(__LINE__, "con3", "commit");
+#line 942 "declare.pgc"
+
+if (sqlca.sqlcode < 0) sqlprint();}
+#line 942 "declare.pgc"
+
+}
+
+/*
+ * reset all the output variables
+ */
+void reset()
+{
+    int i;
+
+    truncateTable();
+
+    memset(f1,0,sizeof(f1));
+    memset(f2,0,sizeof(f2));
+    memset(f3,0,sizeof(f3));
+
+    for(i=0; i<COLUMN_NUM; i++)
+    {
+        memset(field_name[i],0, FIELD_NAME_LEN);
+    }
+}
+
+int initValues()
+{
+    return 0;
+}
+
+void releaseValues()
+{
+}
+
+void printResultF123(char *tc_name, int loop)
+{
+    int i;
+
+    if(loop>OUT_ARRAY_SZIE)
+    {
+        loop = OUT_ARRAY_SZIE;
+    }
+
+    if(tc_name)
+    {
+        printf("****%s test results:****\n",tc_name);
+    }
+
+    for (i = 0; i < loop; i++)
+        printf("f1=%d, f2=%d, f3=%s\n", f1[i], f2[i], f3[i]);
+
+    printf("\n");
+}
+
+void printResultIndF123(char *tc_name, int loop)
+{
+    int i;
+
+    if(loop>OUT_ARRAY_SZIE)
+    {
+        loop = OUT_ARRAY_SZIE;
+    }
+
+    if(tc_name)
+    {
+        printf("****%s indicator results:****\n",tc_name);
+    }
+
+    for (i = 0; i < loop; i++)
+        printf("ind_f1=%d, ind_f2=%d, ind_f3=%d\n", ind_f1[i], ind_f2[i], ind_f3[i]);
+
+    printf("\n");
+}
+
+void printFieldName(char *tc_name)
+{
+    int i;
+
+    if(tc_name)
+    {
+        printf("****%s test results:****\n",tc_name);
+    }
+
+    for (i = 0; i < COLUMN_NUM; i++)
+    {
+        printf("field[%d]'s name = %s\n", i, field_name[i]);
+    }
+
+    printf("\n");
+}
diff --git a/src/interfaces/ecpg/test/expected/sql-declare.stderr b/src/interfaces/ecpg/test/expected/sql-declare.stderr
new file mode 100644
index 0000000..beeb8ea
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/sql-declare.stderr
@@ -0,0 +1,2393 @@
+[NO_PID]: ECPGdebug: set to 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database ecpg1_regression on <DEFAULT> port <DEFAULT>  
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database ecpg2_regression on <DEFAULT> port <DEFAULT>  
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGconnect: opening database ecpg3_regression on <DEFAULT> port <DEFAULT>  
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 908: query: drop table if exists source; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 908: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 908: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 909: query: drop table if exists source; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 909: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 909: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 910: query: drop table if exists source; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 910: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 910: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 912: query: drop table if exists target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 912: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 912: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 913: query: drop table if exists target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 913: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 913: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 914: query: drop table if exists target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 914: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 914: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 916: query: drop table if exists tb1; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 916: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 916: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 917: query: drop table if exists tb1; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 917: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 917: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 918: query: drop table if exists tb1; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 918: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 918: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 871: query: create table source ( f1 integer , f2 integer , f3 varchar ( 20 ) ); with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 871: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 871: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 872: query: create table source ( f1 integer , f2 integer , f3 varchar ( 20 ) ); with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 872: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 872: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 873: query: create table source ( f1 integer , f2 integer , f3 varchar ( 20 ) ); with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 873: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 873: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 875: query: create table tb1 ( con1_f1 integer , con1_f2 integer , con1_f3 varchar ( 20 ) ); with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 875: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 875: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 876: query: create table tb1 ( con2_f1 integer , con2_f2 integer , con2_f3 varchar ( 20 ) ); with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 876: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 876: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 877: query: create table tb1 ( con3_f1 integer , con3_f2 integer , con3_f3 varchar ( 20 ) ); with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 877: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 877: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 879: query: create table target ( f1 integer , f2 integer , f3 varchar ( 20 ) ); with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 879: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 879: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 880: query: create table target ( f1 integer , f2 integer , f3 varchar ( 20 ) ); with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 880: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 880: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 881: query: create table target ( f1 integer , f2 integer , f3 varchar ( 20 ) ); with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 881: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 881: OK: CREATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 885: query: insert into source values ( 1 , 10 , 'db on con1' ); with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 885: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 885: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 886: query: insert into source values ( 2 , 20 , 'db on con1' ); with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 886: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 886: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 887: query: insert into source values ( 3 , 30 , 'db on con1' ); with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 887: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 887: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 889: query: insert into source values ( 1 , 10 , 'db on con2' ); with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 889: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 889: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 890: query: insert into source values ( 2 , 20 , 'db on con2' ); with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 890: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 890: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 891: query: insert into source values ( 3 , 30 , 'db on con2' ); with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 891: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 891: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 893: query: insert into source values ( 1 , 10 , 'db on con3' ); with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 893: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 893: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 894: query: insert into source values ( 2 , 20 , 'db on con3' ); with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 894: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 894: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 895: query: insert into source values ( 3 , 30 , 'db on con3' ); with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 895: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 895: OK: INSERT 0 1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 250: name stmt_1; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 251: query: declare cur_1 cursor for SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 251: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 251: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 257: query: fetch cur_1; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 257: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 257: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 257: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 257: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 257: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 257: query: fetch cur_1; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 257: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 257: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 257: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 257: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 257: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 257: query: fetch cur_1; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 257: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 257: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 257: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 257: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 257: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 257: query: fetch cur_1; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 257: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 257: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 257: no data found on line 257
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 261: query: close cur_1; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 261: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 261: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 262: name stmt_1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 271: name stmt_2; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 272: query: declare cur_2 cursor for SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 272: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 272: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 278: query: fetch cur_2; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 278: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 278: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 278: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 278: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 278: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 278: query: fetch cur_2; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 278: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 278: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 278: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 278: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 278: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 278: query: fetch cur_2; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 278: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 278: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 278: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 278: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 278: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 278: query: fetch cur_2; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 278: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 278: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 278: no data found on line 278
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 282: query: close cur_2; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 282: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 282: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 283: name stmt_2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 293: declared name stmt_3 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 294: name stmt_3; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 295: query: SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 295: using PQexecPrepared for "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 295: correctly got 3 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 295: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 295: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 295: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 295: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 295: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 295: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 295: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 295: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 295: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 297: name stmt_3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 305: declared name stmt_4 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 306: name stmt_4; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 307: query: SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 307: using PQexecPrepared for "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 307: correctly got 3 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 307: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 307: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 307: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 307: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 307: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 307: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 307: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 307: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 307: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 309: name stmt_4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 315: declared name str_stmt_4 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 316: name str_stmt_4; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 317: query: SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 317: using PQexecPrepared for "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 317: correctly got 3 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 317: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 317: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 317: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 317: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 317: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 317: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 317: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 317: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 317: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 319: name str_stmt_4
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 327: declared name stmt_5 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 328: name stmt_5; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 330: query: declare cur_5 cursor for SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 330: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 330: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 336: query: fetch cur_5; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 336: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 336: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 336: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 336: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 336: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 336: query: fetch cur_5; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 336: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 336: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 336: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 336: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 336: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 336: query: fetch cur_5; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 336: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 336: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 336: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 336: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 336: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 336: query: fetch cur_5; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 336: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 336: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 336: no data found on line 336
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 340: query: close cur_5; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 340: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 340: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 341: name stmt_5
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 349: declared name stmt_6 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 350: name stmt_6; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 352: query: declare cur_6 cursor for SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 352: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 352: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 358: query: fetch cur_6; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 358: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 358: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 358: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 358: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 358: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 358: query: fetch cur_6; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 358: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 358: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 358: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 358: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 358: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 358: query: fetch cur_6; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 358: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 358: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 358: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 358: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 358: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 358: query: fetch cur_6; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 358: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 358: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 358: no data found on line 358
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 362: query: close cur_6; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 362: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 362: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 363: name stmt_6
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 370: declared name str_stmt_6 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 371: name str_stmt_6; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 373: query: declare str_cur_6 cursor for SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 373: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 373: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 379: query: fetch str_cur_6; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 379: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 379: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 379: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 379: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 379: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 379: query: fetch str_cur_6; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 379: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 379: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 379: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 379: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 379: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 379: query: fetch str_cur_6; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 379: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 379: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 379: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 379: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 379: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 379: query: fetch str_cur_6; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 379: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 379: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 379: no data found on line 379
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 383: query: close str_cur_6; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 383: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 383: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 384: name str_stmt_6
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 395: declared name stmt_7 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 396: name stmt_7; query: "SELECT * FROM tb1"
+[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]: ECPGget_desc: NAME = con1_f1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con1_f2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con1_f3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 405: name stmt_7
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 415: declared name stmt_8 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 416: name stmt_8; query: "SELECT * FROM tb1"
+[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]: ECPGget_desc: NAME = con1_f1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con1_f2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con1_f3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 425: name stmt_8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 434: declared name str_stmt_8 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 435: name str_stmt_8; query: "SELECT * FROM tb1"
+[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]: ECPGget_desc: NAME = con1_f1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con1_f2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con1_f3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 444: name str_stmt_8
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 452: declared name stmt_9 on connection: "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 453: name stmt_9; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 454: query: SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 454: using PQexecPrepared for "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 454: correctly got 3 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 454: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 454: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 454: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 454: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 454: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 454: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 454: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 454: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 454: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 456: name stmt_9
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 464: declared name stmt_10 on connection: "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 465: name stmt_10; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 466: query: SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 466: using PQexecPrepared for "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 466: correctly got 3 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 466: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 466: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 466: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 466: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 466: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 466: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 466: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 466: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 466: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 468: name stmt_10
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 476: declared name stmt_11 on connection: "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 477: name stmt_11; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 479: query: declare cur_11 cursor for SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 479: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 479: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 485: query: fetch cur_11; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 485: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 485: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 485: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 485: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 485: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 485: query: fetch cur_11; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 485: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 485: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 485: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 485: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 485: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 485: query: fetch cur_11; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 485: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 485: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 485: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 485: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 485: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 485: query: fetch cur_11; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 485: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 485: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 485: no data found on line 485
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 489: query: close cur_11; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 489: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 489: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 490: name stmt_11
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 498: declared name stmt_12 on connection: "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 499: name stmt_12; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 501: query: declare cur_12 cursor for SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 501: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 501: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 507: query: fetch cur_12; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 507: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 507: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 507: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 507: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 507: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 507: query: fetch cur_12; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 507: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 507: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 507: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 507: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 507: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 507: query: fetch cur_12; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 507: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 507: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 507: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 507: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 507: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 507: query: fetch cur_12; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 507: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 507: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 507: no data found on line 507
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 511: query: close cur_12; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 511: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 511: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 512: name stmt_12
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 523: declared name stmt_13 on connection: "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 524: name stmt_13; query: "SELECT * FROM tb1"
+[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]: ECPGget_desc: NAME = con3_f1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con3_f2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con3_f3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 533: name stmt_13
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 543: declared name stmt_14 on connection: "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 544: name stmt_14; query: "SELECT * FROM tb1"
+[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]: ECPGget_desc: NAME = con3_f1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con3_f2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con3_f3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 553: name stmt_14
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 562: name stmt_15; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 563: query: SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 563: using PQexecPrepared for "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 563: correctly got 3 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 563: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 563: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 563: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 563: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 563: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 563: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 563: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 563: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 563: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 565: name stmt_15
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 574: name stmt_16; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 575: query: SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 575: using PQexecPrepared for "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 575: correctly got 3 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 575: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 575: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 575: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 575: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 575: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 575: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 575: RESULT: db on con2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 575: RESULT: db on con2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 575: RESULT: db on con2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 577: name stmt_16
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 586: name stmt_17; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 588: query: declare cur_17 cursor for SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 588: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 588: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 594: query: fetch cur_17; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 594: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 594: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 594: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 594: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 594: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 594: query: fetch cur_17; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 594: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 594: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 594: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 594: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 594: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 594: query: fetch cur_17; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 594: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 594: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 594: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 594: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 594: RESULT: db on con3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 594: query: fetch cur_17; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 594: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 594: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 594: no data found on line 594
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 598: query: close cur_17; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 598: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 598: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 599: name stmt_17
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 608: name stmt_18; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 610: query: declare cur_18 cursor for SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 610: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 610: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 616: query: fetch cur_18; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 616: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 616: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 616: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 616: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 616: RESULT: db on con2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 616: query: fetch cur_18; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 616: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 616: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 616: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 616: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 616: RESULT: db on con2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 616: query: fetch cur_18; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 616: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 616: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 616: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 616: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 616: RESULT: db on con2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 616: query: fetch cur_18; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 616: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 616: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 616: no data found on line 616
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 620: query: close cur_18; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 620: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 620: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 621: name stmt_18
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 633: name stmt_19; query: "SELECT * FROM tb1"
+[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]: ECPGget_desc: NAME = con3_f1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con3_f2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con3_f3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 642: name stmt_19
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 653: name stmt_20; query: "SELECT * FROM tb1"
+[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]: ECPGget_desc: NAME = con2_f1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con2_f2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con2_f3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 662: name stmt_20
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 670: declared name stmt_21 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 671: name stmt_21; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 672: query: SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 672: using PQexecPrepared for "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 672: correctly got 3 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 672: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 672: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 672: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 672: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 672: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 672: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 672: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 672: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 672: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 674: name stmt_21
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 682: declared name stmt_22 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 683: name stmt_22; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 685: query: declare "cur_22" cursor for SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 685: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 685: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 691: query: fetch "cur_22"; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 691: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 691: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 691: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 691: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 691: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 691: query: fetch "cur_22"; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 691: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 691: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 691: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 691: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 691: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 691: query: fetch "cur_22"; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 691: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 691: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 691: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 691: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 691: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 691: query: fetch "cur_22"; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 691: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 691: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 691: no data found on line 691
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 695: query: close "cur_22"; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 695: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 695: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 696: name stmt_22
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 707: declared name stmt_23 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 708: name stmt_23; query: "SELECT * FROM tb1"
+[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]: ECPGget_desc: NAME = con1_f1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con1_f2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con1_f3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 717: name stmt_23
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 729: declared name strSTMT24 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 730: name strSTMT24; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 731: query: SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 731: using PQexecPrepared for "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 731: correctly got 3 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 731: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 731: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 731: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 731: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 731: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 731: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 731: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 731: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 731: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 733: name strSTMT24
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 741: declared name stmt_25 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 742: name pre_stmt_25; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 743: query: SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 743: using PQexecPrepared for "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 743: correctly got 3 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 743: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 743: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 743: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 743: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 743: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 743: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 743: RESULT: db on con2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 743: RESULT: db on con2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 743: RESULT: db on con2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 745: name pre_stmt_25
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 753: declared name stmt_26 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 754: name pre_stmt_26; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 756: query: declare cur_26 cursor for SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 756: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 756: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 762: query: fetch cur_26; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 762: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 762: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 762: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 762: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 762: RESULT: db on con2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 762: query: fetch cur_26; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 762: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 762: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 762: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 762: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 762: RESULT: db on con2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 762: query: fetch cur_26; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 762: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 762: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 762: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 762: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 762: RESULT: db on con2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 762: query: fetch cur_26; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 762: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 762: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 762: no data found on line 762
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 766: query: close cur_26; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 766: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 766: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 767: name pre_stmt_26
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 778: declared name stmt_27 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 779: name pre_stmt_27; query: "SELECT * FROM tb1"
+[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]: ECPGget_desc: NAME = con2_f1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con2_f2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: reading items for tuple 3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGget_desc: NAME = con2_f3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 788: name pre_stmt_27
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 800: declared name stmt_28 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 801: name stmt_28; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 803: query: declare str_cur_28 cursor for SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 803: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 803: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 809: query: fetch str_cur_28; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 809: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 809: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 809: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 809: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 809: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 809: query: fetch str_cur_28; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 809: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 809: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 809: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 809: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 809: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 809: query: fetch str_cur_28; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 809: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 809: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 809: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 809: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 809: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 809: query: fetch str_cur_28; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 809: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 809: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 809: no data found on line 809
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: raising sqlcode -245 on line 813: The cursor is invalid on line 813
+[NO_PID]: sqlca: code: -245, state: YE000
+SQL error: The cursor is invalid on line 813
+[NO_PID]: deallocate_one on line 814: name stmt_28
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGdeclare on line 824: declared name stmt_29 on connection: "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: prepare_common on line 825: name stmt_29; query: "SELECT f1,f2,f3 FROM source where f1<4"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 828: query: declare cur_29 cursor for SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 828: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 828: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 834: query: fetch cur_29; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 834: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 834: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 834: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 834: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 834: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 834: query: fetch cur_29; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 834: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 834: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 834: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 834: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 834: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 834: query: fetch cur_29; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 834: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 834: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 834: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 834: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 834: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 834: query: fetch cur_29; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 834: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 834: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 834: no data found on line 834
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 838: query: close cur_29; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 838: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 838: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: query: truncate table target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 931: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 931: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: query: truncate table target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 932: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 932: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: query: truncate table target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 933: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 933: OK: TRUNCATE TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 843: query: declare cur_29 cursor for SELECT f1,f2,f3 FROM source where f1<4; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 843: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 843: OK: DECLARE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 847: query: fetch cur_29; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 847: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 847: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 847: RESULT: 1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 847: RESULT: 10 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 847: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 847: query: fetch cur_29; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 847: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 847: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 847: RESULT: 2 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 847: RESULT: 20 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 847: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 847: query: fetch cur_29; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 847: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 847: correctly got 1 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 847: RESULT: 3 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 847: RESULT: 30 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_get_data on line 847: RESULT: db on con1 offset: -1; array: no
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 847: query: fetch cur_29; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 847: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 847: correctly got 0 tuples with 3 fields
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: raising sqlcode 100 on line 847: no data found on line 847
+[NO_PID]: sqlca: code: 100, state: 02000
+[NO_PID]: ecpg_execute on line 851: query: close cur_29; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 851: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 851: OK: CLOSE CURSOR
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: deallocate_one on line 852: name stmt_29
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 908: query: drop table if exists source; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 908: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 908: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 909: query: drop table if exists source; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 909: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 909: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 910: query: drop table if exists source; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 910: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 910: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 912: query: drop table if exists target; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 912: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 912: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 913: query: drop table if exists target; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 913: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 913: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 914: query: drop table if exists target; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 914: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 914: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 916: query: drop table if exists tb1; with 0 parameter(s) on connection con1
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 916: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 916: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 917: query: drop table if exists tb1; with 0 parameter(s) on connection con2
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 917: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 917: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 918: query: drop table if exists tb1; with 0 parameter(s) on connection con3
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_execute on line 918: using PQexec
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_process_output on line 918: OK: DROP TABLE
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 940: action "commit"; connection "con1"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 941: action "commit"; connection "con2"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ECPGtrans on line 942: action "commit"; connection "con3"
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_29 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_28 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_27 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_26 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_25 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name strSTMT24 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_23 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_22 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_21 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name str_stmt_8 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_8 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_7 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name str_stmt_6 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_6 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_5 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name str_stmt_4 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_4 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_3 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: connection con1 closed
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_14 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_13 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_12 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_11 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_10 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_release_declared_statement: declared name stmt_9 is released
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: connection con3 closed
+[NO_PID]: sqlca: code: 0, state: 00000
+[NO_PID]: ecpg_finish: connection con2 closed
+[NO_PID]: sqlca: code: 0, state: 00000
diff --git a/src/interfaces/ecpg/test/expected/sql-declare.stdout b/src/interfaces/ecpg/test/expected/sql-declare.stdout
new file mode 100644
index 0000000..2ffe1d7
--- /dev/null
+++ b/src/interfaces/ecpg/test/expected/sql-declare.stdout
@@ -0,0 +1,161 @@
+****testcase1 test results:****
+f1=1, f2=10, f3=db on con3
+f1=2, f2=20, f3=db on con3
+f1=3, f2=30, f3=db on con3
+
+****testcase2 test results:****
+f1=1, f2=10, f3=db on con3
+f1=2, f2=20, f3=db on con3
+f1=3, f2=30, f3=db on con3
+
+****testcase3 test results:****
+f1=1, f2=10, f3=db on con1
+f1=2, f2=20, f3=db on con1
+f1=3, f2=30, f3=db on con1
+
+****testcase4 test results:****
+f1=1, f2=10, f3=db on con1
+f1=2, f2=20, f3=db on con1
+f1=3, f2=30, f3=db on con1
+
+f1=1, f2=10, f3=db on con1
+f1=2, f2=20, f3=db on con1
+f1=3, f2=30, f3=db on con1
+
+****testcase5 test results:****
+f1=1, f2=10, f3=db on con1
+f1=2, f2=20, f3=db on con1
+f1=3, f2=30, f3=db on con1
+
+****testcase6 test results:****
+f1=1, f2=10, f3=db on con1
+f1=2, f2=20, f3=db on con1
+f1=3, f2=30, f3=db on con1
+
+f1=1, f2=10, f3=db on con1
+f1=2, f2=20, f3=db on con1
+f1=3, f2=30, f3=db on con1
+
+****testcase7 test results:****
+field[0]'s name = con1_f1
+field[1]'s name = con1_f2
+field[2]'s name = con1_f3
+
+****testcase8 test results:****
+field[0]'s name = con1_f1
+field[1]'s name = con1_f2
+field[2]'s name = con1_f3
+
+field[0]'s name = con1_f1
+field[1]'s name = con1_f2
+field[2]'s name = con1_f3
+
+****testcase9 test results:****
+f1=1, f2=10, f3=db on con3
+f1=2, f2=20, f3=db on con3
+f1=3, f2=30, f3=db on con3
+
+****testcase10 test results:****
+f1=1, f2=10, f3=db on con3
+f1=2, f2=20, f3=db on con3
+f1=3, f2=30, f3=db on con3
+
+****testcase11 test results:****
+f1=1, f2=10, f3=db on con3
+f1=2, f2=20, f3=db on con3
+f1=3, f2=30, f3=db on con3
+
+****testcase12 test results:****
+f1=1, f2=10, f3=db on con3
+f1=2, f2=20, f3=db on con3
+f1=3, f2=30, f3=db on con3
+
+****testcase13 test results:****
+field[0]'s name = con3_f1
+field[1]'s name = con3_f2
+field[2]'s name = con3_f3
+
+****testcase14 test results:****
+field[0]'s name = con3_f1
+field[1]'s name = con3_f2
+field[2]'s name = con3_f3
+
+****testcase15 test results:****
+f1=1, f2=10, f3=db on con3
+f1=2, f2=20, f3=db on con3
+f1=3, f2=30, f3=db on con3
+
+****testcase16 test results:****
+f1=1, f2=10, f3=db on con2
+f1=2, f2=20, f3=db on con2
+f1=3, f2=30, f3=db on con2
+
+****testcase17 test results:****
+f1=1, f2=10, f3=db on con3
+f1=2, f2=20, f3=db on con3
+f1=3, f2=30, f3=db on con3
+
+****testcase18 test results:****
+f1=1, f2=10, f3=db on con2
+f1=2, f2=20, f3=db on con2
+f1=3, f2=30, f3=db on con2
+
+****testcase19 test results:****
+field[0]'s name = con3_f1
+field[1]'s name = con3_f2
+field[2]'s name = con3_f3
+
+****testcase20 test results:****
+field[0]'s name = con2_f1
+field[1]'s name = con2_f2
+field[2]'s name = con2_f3
+
+****testcase21 test results:****
+f1=1, f2=10, f3=db on con1
+f1=2, f2=20, f3=db on con1
+f1=3, f2=30, f3=db on con1
+
+****testcase22 test results:****
+f1=1, f2=10, f3=db on con1
+f1=2, f2=20, f3=db on con1
+f1=3, f2=30, f3=db on con1
+
+****testcase23 test results:****
+field[0]'s name = con1_f1
+field[1]'s name = con1_f2
+field[2]'s name = con1_f3
+
+****testcase24 test results:****
+f1=1, f2=10, f3=db on con1
+f1=2, f2=20, f3=db on con1
+f1=3, f2=30, f3=db on con1
+
+****testcase25 test results:****
+f1=1, f2=10, f3=db on con2
+f1=2, f2=20, f3=db on con2
+f1=3, f2=30, f3=db on con2
+
+****testcase26 test results:****
+f1=1, f2=10, f3=db on con2
+f1=2, f2=20, f3=db on con2
+f1=3, f2=30, f3=db on con2
+
+****testcase27 test results:****
+field[0]'s name = con2_f1
+field[1]'s name = con2_f2
+field[2]'s name = con2_f3
+
+****testcase28 test results:****
+f1=1, f2=10, f3=db on con1
+f1=2, f2=20, f3=db on con1
+f1=3, f2=30, f3=db on con1
+
+****testcase29 test results:****
+f1=1, f2=10, f3=db on con1
+f1=2, f2=20, f3=db on con1
+f1=3, f2=30, f3=db on con1
+
+f1=1, f2=10, f3=db on con1
+f1=2, f2=20, f3=db on con1
+f1=3, f2=30, f3=db on con1
+
diff --git a/src/interfaces/ecpg/test/expected/sql-desc.c b/src/interfaces/ecpg/test/expected/sql-desc.c
index bdd12a5..bcfe1bd 100644
--- a/src/interfaces/ecpg/test/expected/sql-desc.c
+++ b/src/interfaces/ecpg/test/expected/sql-desc.c
@@ -249,7 +249,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	/* declare c1 cursor for $1 */
 #line 58 "desc.pgc"
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c1 cursor for $1", 
+	{ ECPGopen("c1", "foo2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c1 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, 
@@ -260,7 +260,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 59 "desc.pgc"
 
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch next from c1", ECPGt_EOIT, 
+	{ ECPGfetch("c1", __LINE__, 0, 1, NULL, 0, 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), 
@@ -273,7 +273,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n",
 		val1output, ind1, val2output, ind2);
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c1", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGclose("c1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c1", ECPGt_EOIT, ECPGt_EORT);
 #line 65 "desc.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -299,7 +299,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 	/* declare c2 cursor for $1 */
 #line 70 "desc.pgc"
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c2 cursor for $1", 
+	{ ECPGopen("c2", "foo3", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare c2 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, 
@@ -310,7 +310,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 71 "desc.pgc"
 
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch next from c2", ECPGt_EOIT, 
+	{ ECPGfetch("c2", __LINE__, 0, 1, NULL, 0, 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), 
@@ -322,7 +322,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c2", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGclose("c2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close c2", ECPGt_EOIT, ECPGt_EORT);
 #line 76 "desc.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
diff --git a/src/interfaces/ecpg/test/expected/sql-dyntest.c b/src/interfaces/ecpg/test/expected/sql-dyntest.c
index 2cbc196..dff22aa 100644
--- a/src/interfaces/ecpg/test/expected/sql-dyntest.c
+++ b/src/interfaces/ecpg/test/expected/sql-dyntest.c
@@ -261,7 +261,7 @@ if (sqlca.sqlcode < 0) error ( );}
 #line 58 "dyntest.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare MYCURS cursor for $1", 
+  { ECPGopen("MYCURS", "myquery", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare MYCURS 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"
@@ -272,7 +272,7 @@ if (sqlca.sqlcode < 0) error ( );}
 
   while (1)
     {
-      { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch in MYCURS", ECPGt_EOIT, 
+      { ECPGfetch("MYCURS", __LINE__, 0, 1, NULL, 0, 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"
@@ -468,7 +468,7 @@ if (sqlca.sqlcode < 0) error ( );}
 	}
     }
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close MYCURS", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGclose("MYCURS", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close MYCURS", ECPGt_EOIT, ECPGt_EORT);
 #line 194 "dyntest.pgc"
 
 if (sqlca.sqlcode < 0) error ( );}
diff --git a/src/interfaces/ecpg/test/expected/sql-execute.c b/src/interfaces/ecpg/test/expected/sql-execute.c
index aee3c1b..c511349 100644
--- a/src/interfaces/ecpg/test/expected/sql-execute.c
+++ b/src/interfaces/ecpg/test/expected/sql-execute.c
@@ -140,7 +140,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 50 "execute.pgc"
 
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare CUR cursor for $1", 
+	{ ECPGopen("CUR", "f", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare CUR 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"
@@ -148,7 +148,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 52 "execute.pgc"
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT, 
+	{ ECPGfetch("CUR", __LINE__, 0, 1, NULL, 0, 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), 
@@ -180,7 +180,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 		printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
 	}
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGclose("CUR", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT);
 #line 66 "execute.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -205,7 +205,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 72 "execute.pgc"
 
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare CUR2 cursor for $1", 
+	{ ECPGopen("CUR2", "f", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare CUR2 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"), 
@@ -215,7 +215,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 74 "execute.pgc"
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch in CUR2", ECPGt_EOIT, 
+	{ ECPGfetch("CUR2", __LINE__, 0, 1, NULL, 0, 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), 
@@ -247,7 +247,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 		printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
 	}
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close CUR2", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGclose("CUR2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close CUR2", ECPGt_EOIT, ECPGt_EORT);
 #line 88 "execute.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
diff --git a/src/interfaces/ecpg/test/expected/sql-fetch.c b/src/interfaces/ecpg/test/expected/sql-fetch.c
index b547b25..e6beaf5 100644
--- a/src/interfaces/ecpg/test/expected/sql-fetch.c
+++ b/src/interfaces/ecpg/test/expected/sql-fetch.c
@@ -99,7 +99,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 26 "fetch.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from My_Table", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGopen("C", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from My_Table", ECPGt_EOIT, ECPGt_EORT);
 #line 28 "fetch.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -113,7 +113,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 30 "fetch.pgc"
 
   while (1) {
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, 
+	{ ECPGfetch("C", __LINE__, 0, 1, NULL, 0, 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), 
@@ -135,7 +135,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
   /* exec sql whenever not found  continue ; */
 #line 36 "fetch.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGfetch("C", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT);
 #line 37 "fetch.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -145,7 +145,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 37 "fetch.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 in C", 
+  { ECPGfetch("C", __LINE__, 0, 1, NULL, 0, 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), 
@@ -162,7 +162,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
   printf("%d: %s\n", i, str);
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGclose("C", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT);
 #line 42 "fetch.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -176,7 +176,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 44 "fetch.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare D cursor for select * from My_Table where Item1 = $1", 
+  { ECPGopen("D", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare D 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"
@@ -192,7 +192,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 48 "fetch.pgc"
 
   while (1) {
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in D", ECPGt_EOIT, 
+	{ ECPGfetch("D", __LINE__, 0, 1, NULL, 0, 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), 
@@ -210,7 +210,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
 	printf("%d: %s\n", i, str);
   }
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close D", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGclose("D", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close D", ECPGt_EOIT, ECPGt_EORT);
 #line 53 "fetch.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
diff --git a/src/interfaces/ecpg/test/expected/sql-oldexec.c b/src/interfaces/ecpg/test/expected/sql-oldexec.c
index 5b74dda..2e398c2 100644
--- a/src/interfaces/ecpg/test/expected/sql-oldexec.c
+++ b/src/interfaces/ecpg/test/expected/sql-oldexec.c
@@ -141,7 +141,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 51 "oldexec.pgc"
 
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "declare CUR cursor for $1", 
+	{ ECPGopen("CUR", "f", __LINE__, 0, 1, NULL, 1, ECPGst_normal, "declare CUR 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 53 "oldexec.pgc"
@@ -149,7 +149,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 53 "oldexec.pgc"
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch 8 in CUR", ECPGt_EOIT, 
+	{ ECPGfetch("CUR", __LINE__, 0, 1, NULL, 1, 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), 
@@ -171,7 +171,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 		printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
 	}
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGclose("CUR", __LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR", ECPGt_EOIT, ECPGt_EORT);
 #line 65 "oldexec.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
@@ -190,7 +190,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 70 "oldexec.pgc"
 
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "declare CUR3 cursor for $1", 
+	{ ECPGopen("CUR3", "f", __LINE__, 0, 1, NULL, 1, ECPGst_normal, "declare CUR3 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"), 
@@ -200,7 +200,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 if (sqlca.sqlcode < 0) sqlprint();}
 #line 72 "oldexec.pgc"
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "fetch in CUR3", ECPGt_EOIT, 
+	{ ECPGfetch("CUR3", __LINE__, 0, 1, NULL, 1, 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), 
@@ -222,7 +222,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 		printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
 	}
 
-	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR3", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGclose("CUR3", __LINE__, 0, 1, NULL, 1, ECPGst_normal, "close CUR3", ECPGt_EOIT, ECPGt_EORT);
 #line 84 "oldexec.pgc"
 
 if (sqlca.sqlcode < 0) sqlprint();}
diff --git a/src/interfaces/ecpg/test/expected/sql-quote.c b/src/interfaces/ecpg/test/expected/sql-quote.c
index 0a3b77c..ec03612 100644
--- a/src/interfaces/ecpg/test/expected/sql-quote.c
+++ b/src/interfaces/ecpg/test/expected/sql-quote.c
@@ -162,7 +162,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 #line 43 "quote.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from \"My_Table\"", ECPGt_EOIT, ECPGt_EORT);
+  { ECPGopen("C", NULL, __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from \"My_Table\"", ECPGt_EOIT, ECPGt_EORT);
 #line 45 "quote.pgc"
 
 if (sqlca.sqlwarn[0] == 'W') sqlprint();
@@ -178,7 +178,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
   while (true)
   {
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT, 
+	{ ECPGfetch("C", __LINE__, 0, 1, NULL, 0, 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), 
diff --git a/src/interfaces/ecpg/test/expected/sql-sqlda.c b/src/interfaces/ecpg/test/expected/sql-sqlda.c
index b470b04..6bfcbe2 100644
--- a/src/interfaces/ecpg/test/expected/sql-sqlda.c
+++ b/src/interfaces/ecpg/test/expected/sql-sqlda.c
@@ -251,7 +251,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", 
+	{ ECPGopen("mycur1", "st_id1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur1 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"
@@ -268,7 +268,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	while (1)
 	{
 		strcpy(msg, "fetch");
-		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
+		{ ECPGfetch("mycur1", __LINE__, 0, 1, NULL, 0, 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"
@@ -289,7 +289,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "close");
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGclose("mycur1", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
 #line 120 "sqlda.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
@@ -324,7 +324,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "open");
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", 
+	{ ECPGopen("mycur2", "st_id2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur2 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"
@@ -334,7 +334,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 
 
 	strcpy(msg, "fetch");
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch all from mycur2", ECPGt_EOIT, 
+	{ ECPGfetch("mycur2", __LINE__, 0, 1, NULL, 0, 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"
@@ -357,7 +357,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 	}
 
 	strcpy(msg, "close");
-	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
+	{ ECPGclose("mycur2", __LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
 #line 157 "sqlda.pgc"
 
 if (sqlca.sqlcode < 0) exit (1);}
diff --git a/src/interfaces/ecpg/test/regression.h b/src/interfaces/ecpg/test/regression.h
index 4aa13b6..aa6421d 100644
--- a/src/interfaces/ecpg/test/regression.h
+++ b/src/interfaces/ecpg/test/regression.h
@@ -1,5 +1,5 @@
 exec sql define REGRESSDB1 ecpg1_regression;
 exec sql define REGRESSDB2 ecpg2_regression;
-
+exec sql define REGRESSDB3 ecpg3_regression;
 exec sql define REGRESSUSER1 regress_ecpg_user1;
 exec sql define REGRESSUSER2 regress_ecpg_user2;
diff --git a/src/interfaces/ecpg/test/sql/Makefile b/src/interfaces/ecpg/test/sql/Makefile
index 6bc67e9..d313464 100644
--- a/src/interfaces/ecpg/test/sql/Makefile
+++ b/src/interfaces/ecpg/test/sql/Makefile
@@ -22,7 +22,8 @@ TESTS = array array.c \
         parser parser.c \
         quote quote.c \
         show show.c \
-        insupd insupd.c
+        insupd insupd.c \
+        declare declare.c
 
 all: $(TESTS)
 
diff --git a/src/interfaces/ecpg/test/sql/declare.pgc b/src/interfaces/ecpg/test/sql/declare.pgc
new file mode 100644
index 0000000..d3bfb55
--- /dev/null
+++ b/src/interfaces/ecpg/test/sql/declare.pgc
@@ -0,0 +1,1028 @@
+#include <locale.h>
+#include <string.h>
+#include <stdlib.h>
+
+exec sql whenever sqlerror sqlprint;
+
+exec sql include sqlca;
+exec sql include ../regression;
+
+#define OUT_ARRAY_SZIE 20
+#define TEST_CASE_NUM 29
+#define COLUMN_NUM 3
+#define FIELD_NAME_LEN 30
+
+void declare_test(char * tc_name);
+int createTable(void);
+void dropTable(void);
+void reCreateTable(void);
+void truncateTable(void);
+void commitTable(void);
+void reset(void);
+int initValues(void);
+void releaseValues(void);
+void printResultF123(char *tc_name, int loop);
+void printResultIndF123(char *tc_name, int loop);
+int startManualTest(char *in);
+int startAutoTest(void);
+void printFieldName(char *);
+
+EXEC SQL BEGIN DECLARE SECTION;
+
+    //input variables
+    int         in_f1 = 1 ;
+    double      in_f2 = 10;
+    char        in_f3[20] = {"one"};
+
+    //output variables
+    int f1[OUT_ARRAY_SZIE];
+    int f2[OUT_ARRAY_SZIE];
+    char f3[OUT_ARRAY_SZIE][20];
+
+    char field_name[COLUMN_NUM][FIELD_NAME_LEN];
+
+
+    int ind_f1[OUT_ARRAY_SZIE],ind_f2[OUT_ARRAY_SZIE],ind_f3[OUT_ARRAY_SZIE];
+
+EXEC SQL END DECLARE SECTION;
+
+int
+main (int argc, char *argv[])
+{
+    setlocale(LC_ALL, "C");
+
+    ECPGdebug(1, stderr);
+
+    /* connect to database */
+    EXEC SQL CONNECT TO REGRESSDB1 AS con1;
+    EXEC SQL CONNECT TO REGRESSDB2 AS con2;
+    EXEC SQL CONNECT TO REGRESSDB3 as con3;
+
+    if(initValues())
+    {
+        printf("Error: initValues return error!\n");
+
+        releaseValues();
+        return -1;
+    }
+
+    if(argc == 2) //start manual test
+    {
+        printf("Start manual test! \n");
+        startManualTest(argv[1]);
+    }
+    else  //start auto test
+    {
+        startAutoTest();
+    }
+
+    EXEC SQL DISCONNECT con1;
+
+    EXEC SQL DISCONNECT ALL;
+
+    releaseValues();
+
+    return (0);
+}
+
+int startManualTest(char *in)
+{
+    if(!strcmp(in,"cr"))
+    {
+        createTable();
+    }
+    else if(!strcmp(in,"dr"))
+    {
+        dropTable();
+    }
+    else if(!strcmp(in,"re"))
+    {
+        reCreateTable();
+    }
+    else if(!strcmp(in,"help"))
+    {
+        printf("====Supporting the following parameters====\n");
+        printf("1. cr -- create tables\n");
+        printf("2. dr -- drop tables\n");
+        printf("3. re -- drop tables and create tables\n");
+        printf("4. testcaseX where X is a digit form 1 to %d\n",TEST_CASE_NUM);
+        printf("If you don't give any parameter, the program will start the test from the testcase1 to testcase%d automatically\n",TEST_CASE_NUM);
+    }
+    else
+    {
+        declare_test(in);
+    }
+
+    commitTable();
+
+    return 0;
+}
+
+int startAutoTest()
+{
+    int i;
+    char tc_name[20];
+
+    dropTable();
+
+    if(createTable())
+    {
+        printf("Error: createTable return error!\n");
+        return -1;
+    }
+
+    for(i=1;i<=TEST_CASE_NUM;i++)
+    {
+        sprintf(tc_name,"testcase%d",i);
+        declare_test(tc_name);
+    }
+
+    dropTable();
+
+    return 0;
+}
+
+
+/*
+ * default connection: con3
+ * Non-default connection: con1, con2
+ *
+ * testcase1. using DECLARE STATEMENT, let CURSOR statement precede PREPARE statement
+ *        ---test result: ok
+ * testcase2. without using DECLARE STATEMENT, let CURSOR statement precede PREPARE statement
+ *        ---test result: ok
+ *
+ * testcase3. using DECLARE STATEMENT at con1, using PREPARE and EXECUTE statement without using AT clause
+ *        ---test result: ok
+ * testcase4. using DECLARE STATEMENT at con1, using PREPARE and EXECUTE statement at con2
+ *        ---test result: ok
+ * testcase5. using DECLARE STATEMENT at con1, using PREPARE and CURSOR statement without using AT clause
+ *        ---test result: ok
+ * testcase6. using DECLARE STATEMENT at con1, using PREPARE and CURSOR statement at con2
+ *        ---test result: ok
+ * testcase7. using DECLARE STATEMENT at con1, using DESCRIBE statement without using AT clause
+ *        ---test result: ok
+ * testcase8. using DECLARE STATEMENT at con1, using DESCRIBE statement at con2
+ *        ---test result: ok
+ *
+ * testcase9. using DECLARE STATEMENT at con3, using PREPARE and EXECUTE statement without using AT clause
+ *        ---test result: ok
+ * testcase10. using DECLARE STATEMENT at con3, using PREPARE and EXECUTE statement at con2
+ *        ---test result: ok
+ * testcase11. using DECLARE STATEMENT at con3, using PREPARE and CURSOR statement without using AT clause
+ *        ---test result: ok
+ * testcase12. using DECLARE STATEMENT at con3, using PREPARE and CURSOR statement at con2
+ *        ---test result: ok
+ * testcase13. using DECLARE STATEMENT at con3, using DESCRIBE statement without using AT clause
+ *        ---test result: ok
+ * testcase14. using DECLARE STATEMENT at con3, using DESCRIBE statement at con2
+ *        ---test result: ok
+ *
+ * testcase15. using DECLARE STATEMENT without using AT clause, using PREPARE and EXECUTE statement without using AT clause
+ *        ---test result: ok
+ * testcase16. using DECLARE STATEMENT without using AT clause, using PREPARE and EXECUTE statement at con2
+ *        ---test result: ok
+ * testcase17. using DECLARE STATEMENT without using AT clause, using PREPARE and CURSOR statement without using AT clause
+ *        ---test result: ok
+ * testcase18. using DECLARE STATEMENT without using AT clause, using PREPARE and CURSOR statement at con2
+ *        ---test result: ok
+ * testcase19. using DECLARE STATEMENT without using AT clause, using DESCRIBE statement without using AT clause
+ *        ---test result: ok
+ * testcase20. using DECLARE STATEMENT without using AT clause, using DESCRIBE statement at con2
+ *        ---test result: ok
+
+ * testcase21. using DECLARE STATEMENT at con1, using PREPARE and EXECUTE statement at con2
+ *            using quoted string as declared name
+ *        ---test result: ok
+ * testcase22. using DECLARE STATEMENT at con1, using PREPARE and CURSOR statement at con2
+ *            using quoted string as declared name
+ *        ---test result: ok
+ * testcase23. using DECLARE STATEMENT at con1, using DESCRIBE statement at con2
+ *            using quoted string as declared name
+ *        ---test result: ok
+ *
+ * testcase24. using DECLARE STATEMENT at con1, using PREPARE and EXECUTE statement at con2
+ *            using host variable as declared name
+ *        ---test result:
+ *
+ * testcase25. using DECLARE STATEMENT at con1, using PREPARE and EXECUTE statement at con2 and without referring the DECLARE statement
+ *        ---test result: ok
+ * testcase26. using DECLARE STATEMENT at con1, using PREPARE and CURSOR statement at con2 and without referring the DECLARE statement
+ *        ---test result: ok
+ * testcase27. using DECLARE STATEMENT at con1, using PREPARE and DESCRIBE statement at con2 and without referring the DECLARE statement
+ *        ---test result: ok
+ *
+ * testcase28. Using host variable as cursor name in the DECLARE/OPEN CURSOR statement,
+ *             using the content in the host variable as the cursor name in the CLOSE CURSOR statement
+ *             This is nothing with DECLARE STATEMENT feature, this case just verify a bug that cursor name can be closed by using
+ *             content of host variable while the cursor name is declared/opened by using the host variable.
+ *        ---test result: ok
+ *
+ * testcase29. using DECLARE STATEMENT at con1, using PREPARE and CURSOR statement without using AT clause
+ *             one cursor is set to "open" and "close" twice.
+ *             Check the declared name can be referred by the cursor at the second time correctly
+ *        ---test result: ok
+ */
+void declare_test(char * tc_name)
+{
+    EXEC SQL BEGIN DECLARE SECTION;
+    int i;
+
+    char    *selectString = "SELECT f1,f2,f3 FROM source where f1<4";
+    char    *selectTb1 = "SELECT * FROM tb1";
+
+    char    *stmt_4 = "str_stmt_4";
+    char    *stmt_6 = "str_stmt_6";
+    char    *stmt_8 = "str_stmt_8";
+
+    char    *cur_6 = "str_cur_6";
+
+    char    *desc_8 = "str_desc_8";
+
+    EXEC SQL END DECLARE SECTION;
+
+    if(!strcmp(tc_name,"testcase1"))
+    {
+        reset();
+
+        EXEC SQL DECLARE stmt_1 STATEMENT;
+        EXEC SQL DECLARE cur_1 CURSOR FOR stmt_1;
+        EXEC SQL PREPARE stmt_1 FROM :selectString;
+        EXEC SQL OPEN cur_1;
+
+        EXEC SQL WHENEVER NOT FOUND DO BREAK;
+        i = 0;
+        while(1)
+        {
+            EXEC SQL FETCH cur_1 INTO :f1[i],:f2[i],:f3[i];
+            i++;
+        }
+
+        EXEC SQL CLOSE cur_1;
+        EXEC SQL DEALLOCATE PREPARE stmt_1;
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase2"))
+    {
+        reset();
+
+        EXEC SQL DECLARE cur_2 CURSOR FOR stmt_2;
+        EXEC SQL PREPARE stmt_2 FROM :selectString;
+        EXEC SQL OPEN cur_2;
+
+        EXEC SQL WHENEVER NOT FOUND DO BREAK;
+        i = 0;
+        while(1)
+        {
+            EXEC SQL FETCH cur_2 INTO :f1[i],:f2[i],:f3[i];
+            i++;
+        }
+
+        EXEC SQL CLOSE cur_2;
+        EXEC SQL DEALLOCATE PREPARE stmt_2;
+
+        EXEC SQL WHENEVER NOT FOUND CONTINUE;
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase3"))
+    {
+        reset();
+
+        EXEC SQL AT con1 DECLARE stmt_3 STATEMENT;
+        EXEC SQL PREPARE stmt_3 FROM :selectString;
+        EXEC SQL EXECUTE stmt_3 INTO :f1,:f2,:f3;
+
+        EXEC SQL DEALLOCATE PREPARE stmt_3;
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase4"))
+    {
+        reset();
+
+        EXEC SQL AT con1 DECLARE stmt_4 STATEMENT;
+        EXEC SQL AT con2 PREPARE stmt_4 FROM :selectString;
+        EXEC SQL AT con2 EXECUTE stmt_4 INTO :f1,:f2,:f3;
+
+        EXEC SQL DEALLOCATE PREPARE stmt_4;
+
+        printResultF123(tc_name,3);
+
+        reset();
+
+        EXEC SQL AT con1 DECLARE :stmt_4 STATEMENT;
+        EXEC SQL AT con2 PREPARE :stmt_4 FROM :selectString;
+        EXEC SQL AT con2 EXECUTE :stmt_4 INTO :f1,:f2,:f3;
+
+        EXEC SQL DEALLOCATE PREPARE :stmt_4;
+
+        printResultF123(NULL,3);
+    }
+    else if(!strcmp(tc_name,"testcase5"))
+    {
+        reset();
+
+        EXEC SQL AT con1 DECLARE stmt_5 STATEMENT;
+        EXEC SQL PREPARE stmt_5 FROM :selectString;
+        EXEC SQL DECLARE cur_5 CURSOR FOR stmt_5;
+        EXEC SQL OPEN cur_5;
+
+        EXEC SQL WHENEVER NOT FOUND DO BREAK;
+        i = 0;
+        while(1)
+        {
+            EXEC SQL FETCH cur_5 INTO :f1[i],:f2[i],:f3[i];
+            i++;
+        }
+
+        EXEC SQL CLOSE cur_5;
+        EXEC SQL DEALLOCATE PREPARE stmt_5;
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase6"))
+    {
+        reset();
+
+        EXEC SQL AT con1 DECLARE stmt_6 STATEMENT;
+        EXEC SQL AT con2 PREPARE stmt_6 FROM :selectString;
+        EXEC SQL AT con2 DECLARE cur_6 CURSOR FOR stmt_6;
+        EXEC SQL AT con2 OPEN cur_6;
+
+        EXEC SQL WHENEVER NOT FOUND DO BREAK;
+        i = 0;
+        while(1)
+        {
+            EXEC SQL AT con2 FETCH cur_6 INTO :f1[i],:f2[i],:f3[i];
+            i++;
+        }
+
+        EXEC SQL AT con2 CLOSE cur_6;
+        EXEC SQL AT con2 DEALLOCATE PREPARE stmt_6;
+        EXEC SQL WHENEVER NOT FOUND CONTINUE;
+
+        printResultF123(tc_name,3);
+
+        reset();
+
+        EXEC SQL AT con1 DECLARE :stmt_6 STATEMENT;
+        EXEC SQL AT con2 PREPARE :stmt_6 FROM :selectString;
+        EXEC SQL AT con2 DECLARE :cur_6 CURSOR FOR :stmt_6;
+        EXEC SQL AT con2 OPEN :cur_6;
+
+        EXEC SQL WHENEVER NOT FOUND DO BREAK;
+        i = 0;
+        while(1)
+        {
+            EXEC SQL AT con2 FETCH :cur_6 INTO :f1[i],:f2[i],:f3[i];
+            i++;
+        }
+
+        EXEC SQL AT con2 CLOSE :cur_6;
+        EXEC SQL AT con2 DEALLOCATE PREPARE :stmt_6;
+        EXEC SQL WHENEVER NOT FOUND CONTINUE;
+
+        printResultF123(NULL,3);
+    }
+    else if(!strcmp(tc_name,"testcase7"))
+    {
+        reset();
+
+        EXEC SQL ALLOCATE DESCRIPTOR desc_7;
+
+        EXEC SQL AT con1 DECLARE stmt_7 STATEMENT;
+        EXEC SQL PREPARE stmt_7 FROM :selectTb1;
+        EXEC SQL DESCRIBE stmt_7 into SQL DESCRIPTOR desc_7;
+
+        for(i=1; i<4; i++)
+        {
+            EXEC SQL GET DESCRIPTOR desc_7 value :i :field_name[i-1] = name;
+        }
+
+        EXEC SQL DEALLOCATE DESCRIPTOR desc_7;
+        EXEC SQL DEALLOCATE PREPARE stmt_7;
+
+        printFieldName(tc_name);
+    }
+    else if(!strcmp(tc_name,"testcase8"))
+    {
+        reset();
+
+        EXEC SQL ALLOCATE DESCRIPTOR desc_8;
+
+        EXEC SQL AT con1 DECLARE stmt_8 STATEMENT;
+        EXEC SQL AT con2 PREPARE stmt_8 FROM :selectTb1;
+        EXEC SQL AT con2 DESCRIBE stmt_8 into SQL DESCRIPTOR desc_8;
+
+        for(i=1; i<4; i++)
+        {
+            EXEC SQL GET DESCRIPTOR desc_8 value :i :field_name[i-1] = name;
+        }
+
+        EXEC SQL DEALLOCATE DESCRIPTOR desc_8;
+        EXEC SQL AT con2 DEALLOCATE PREPARE stmt_8;
+
+        printFieldName(tc_name);
+
+
+        reset();
+
+        EXEC SQL ALLOCATE DESCRIPTOR :desc_8;
+
+        EXEC SQL AT con1 DECLARE :stmt_8 STATEMENT;
+        EXEC SQL AT con2 PREPARE :stmt_8 FROM :selectTb1;
+        EXEC SQL AT con2 DESCRIBE :stmt_8 into SQL DESCRIPTOR :desc_8;
+
+        for(i=1; i<4; i++)
+        {
+            EXEC SQL GET DESCRIPTOR :desc_8 value :i :field_name[i-1] = name;
+        }
+
+        EXEC SQL DEALLOCATE DESCRIPTOR :desc_8;
+        EXEC SQL AT con2 DEALLOCATE PREPARE :stmt_8;
+
+        printFieldName(NULL);
+    }
+    else if(!strcmp(tc_name,"testcase9"))
+    {
+        reset();
+
+        EXEC SQL AT con3 DECLARE stmt_9 STATEMENT;
+        EXEC SQL PREPARE stmt_9 FROM :selectString;
+        EXEC SQL EXECUTE stmt_9 INTO :f1,:f2,:f3;
+
+        EXEC SQL DEALLOCATE PREPARE stmt_9;
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase10"))
+    {
+        reset();
+
+        EXEC SQL AT con3 DECLARE stmt_10 STATEMENT;
+        EXEC SQL AT con2 PREPARE stmt_10 FROM :selectString;
+        EXEC SQL AT con2 EXECUTE stmt_10 INTO :f1,:f2,:f3;
+
+        EXEC SQL AT con2 DEALLOCATE PREPARE stmt_10;
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase11"))
+    {
+        reset();
+
+        EXEC SQL AT con3 DECLARE stmt_11 STATEMENT;
+        EXEC SQL PREPARE stmt_11 FROM :selectString;
+        EXEC SQL DECLARE cur_11 CURSOR FOR stmt_11;
+        EXEC SQL OPEN cur_11;
+
+        EXEC SQL WHENEVER NOT FOUND DO BREAK;
+        i = 0;
+        while(1)
+        {
+            EXEC SQL FETCH cur_11 INTO :f1[i],:f2[i],:f3[i];
+            i++;
+        }
+
+        EXEC SQL CLOSE cur_11;
+        EXEC SQL DEALLOCATE PREPARE stmt_11;
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase12"))
+    {
+        reset();
+
+        EXEC SQL AT con3 DECLARE stmt_12 STATEMENT;
+        EXEC SQL AT con2 PREPARE stmt_12 FROM :selectString;
+        EXEC SQL AT con2 DECLARE cur_12 CURSOR FOR stmt_12;
+        EXEC SQL AT con2 OPEN cur_12;
+
+        EXEC SQL WHENEVER NOT FOUND DO BREAK;
+        i = 0;
+        while(1)
+        {
+            EXEC SQL AT con2 FETCH cur_12 INTO :f1[i],:f2[i],:f3[i];
+            i++;
+        }
+
+        EXEC SQL AT con2 CLOSE cur_12;
+        EXEC SQL AT con2 DEALLOCATE PREPARE stmt_12;
+        EXEC SQL WHENEVER NOT FOUND CONTINUE;
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase13"))
+    {
+        reset();
+
+        EXEC SQL ALLOCATE DESCRIPTOR desc_13;
+
+        EXEC SQL AT con3 DECLARE stmt_13 STATEMENT;
+        EXEC SQL PREPARE stmt_13 FROM :selectTb1;
+        EXEC SQL DESCRIBE stmt_13 into SQL DESCRIPTOR desc_13;
+
+        for(i=1; i<4; i++)
+        {
+            EXEC SQL GET DESCRIPTOR desc_13 value :i :field_name[i-1] = name;
+        }
+
+        EXEC SQL DEALLOCATE DESCRIPTOR desc_13;
+        EXEC SQL DEALLOCATE PREPARE stmt_13;
+
+        printFieldName(tc_name);
+    }
+    else if(!strcmp(tc_name,"testcase14"))
+    {
+        reset();
+
+        EXEC SQL ALLOCATE DESCRIPTOR desc_14;
+
+        EXEC SQL AT con3 DECLARE stmt_14 STATEMENT;
+        EXEC SQL AT con2 PREPARE stmt_14 FROM :selectTb1;
+        EXEC SQL AT con2 DESCRIBE stmt_14 into SQL DESCRIPTOR desc_14;
+
+        for(i=1; i<4; i++)
+        {
+            EXEC SQL GET DESCRIPTOR desc_14 value :i :field_name[i-1] = name;
+        }
+
+        EXEC SQL DEALLOCATE DESCRIPTOR desc_14;
+        EXEC SQL AT con2 DEALLOCATE PREPARE stmt_14;
+
+        printFieldName(tc_name);
+    }
+    else if(!strcmp(tc_name,"testcase15"))
+    {
+        reset();
+
+        EXEC SQL DECLARE stmt_15 STATEMENT;
+        EXEC SQL PREPARE stmt_15 FROM :selectString;
+        EXEC SQL EXECUTE stmt_15 INTO :f1,:f2,:f3;
+
+        EXEC SQL DEALLOCATE PREPARE stmt_15;
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase16"))
+    {
+        reset();
+
+        EXEC SQL DECLARE stmt_16 STATEMENT;
+        EXEC SQL AT con2 PREPARE stmt_16 FROM :selectString;
+        EXEC SQL AT con2 EXECUTE stmt_16 INTO :f1,:f2,:f3;
+
+        EXEC SQL AT con2 DEALLOCATE PREPARE stmt_16;
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase17"))
+    {
+        reset();
+
+        EXEC SQL DECLARE stmt_17 STATEMENT;
+        EXEC SQL PREPARE stmt_17 FROM :selectString;
+        EXEC SQL DECLARE cur_17 CURSOR FOR stmt_17;
+        EXEC SQL OPEN cur_17;
+
+        EXEC SQL WHENEVER NOT FOUND DO BREAK;
+        i = 0;
+        while(1)
+        {
+            EXEC SQL FETCH cur_17 INTO :f1[i],:f2[i],:f3[i];
+            i++;
+        }
+
+        EXEC SQL CLOSE cur_17;
+        EXEC SQL DEALLOCATE PREPARE stmt_17;
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase18"))
+    {
+        reset();
+
+        EXEC SQL DECLARE stmt_18 STATEMENT;
+        EXEC SQL AT con2 PREPARE stmt_18 FROM :selectString;
+        EXEC SQL AT con2 DECLARE cur_18 CURSOR FOR stmt_18;
+        EXEC SQL AT con2 OPEN cur_18;
+
+        EXEC SQL WHENEVER NOT FOUND DO BREAK;
+        i = 0;
+        while(1)
+        {
+            EXEC SQL AT con2 FETCH cur_18 INTO :f1[i],:f2[i],:f3[i];
+            i++;
+        }
+
+        EXEC SQL AT con2 CLOSE cur_18;
+        EXEC SQL AT con2 DEALLOCATE PREPARE stmt_18;
+        EXEC SQL WHENEVER NOT FOUND CONTINUE;
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase19"))
+    {
+        reset();
+
+        EXEC SQL ALLOCATE DESCRIPTOR desc_19;
+
+        EXEC SQL DECLARE stmt_19 STATEMENT;
+        EXEC SQL PREPARE stmt_19 FROM :selectTb1;
+        EXEC SQL DESCRIBE stmt_19 into SQL DESCRIPTOR desc_19;
+
+        for(i=1; i<4; i++)
+        {
+            EXEC SQL GET DESCRIPTOR desc_19 value :i :field_name[i-1] = name;
+        }
+
+        EXEC SQL DEALLOCATE DESCRIPTOR desc_19;
+        EXEC SQL DEALLOCATE PREPARE stmt_19;
+
+        printFieldName(tc_name);
+    }
+    else if(!strcmp(tc_name,"testcase20"))
+    {
+        reset();
+
+        EXEC SQL ALLOCATE DESCRIPTOR desc_20;
+
+        EXEC SQL DECLARE stmt_20 STATEMENT;
+        EXEC SQL AT con2 PREPARE stmt_20 FROM :selectTb1;
+        EXEC SQL AT con2 DESCRIBE stmt_20 into SQL DESCRIPTOR desc_20;
+
+        for(i=1; i<4; i++)
+        {
+            EXEC SQL GET DESCRIPTOR desc_20 value :i :field_name[i-1] = name;
+        }
+
+        EXEC SQL DEALLOCATE DESCRIPTOR desc_20;
+        EXEC SQL AT con2 DEALLOCATE PREPARE stmt_20;
+
+        printFieldName(tc_name);
+    }
+    else if(!strcmp(tc_name,"testcase21"))
+    {
+        reset();
+
+        EXEC SQL AT con1 DECLARE "stmt_21" STATEMENT;
+        EXEC SQL AT con2 PREPARE "stmt_21" FROM :selectString;
+        EXEC SQL AT con2 EXECUTE "stmt_21" INTO :f1,:f2,:f3;
+
+        EXEC SQL DEALLOCATE PREPARE "stmt_21";
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase22"))
+    {
+        reset();
+
+        EXEC SQL AT con1 DECLARE "stmt_22" STATEMENT;
+        EXEC SQL AT con2 PREPARE "stmt_22" FROM :selectString;
+        EXEC SQL AT con2 DECLARE "cur_22" CURSOR FOR "stmt_22";
+        EXEC SQL AT con2 OPEN "cur_22";
+
+        EXEC SQL WHENEVER NOT FOUND DO BREAK;
+        i = 0;
+        while(1)
+        {
+            EXEC SQL AT con2 FETCH "cur_22" INTO :f1[i],:f2[i],:f3[i];
+            i++;
+        }
+
+        EXEC SQL AT con2 CLOSE "cur_22";
+        EXEC SQL AT con2 DEALLOCATE PREPARE "stmt_22";
+        EXEC SQL WHENEVER NOT FOUND CONTINUE;
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase23"))
+    {
+        reset();
+
+        EXEC SQL ALLOCATE DESCRIPTOR desc_23;
+
+        EXEC SQL AT con1 DECLARE "stmt_23" STATEMENT;
+        EXEC SQL AT con2 PREPARE "stmt_23" FROM :selectTb1;
+        EXEC SQL AT con2 DESCRIBE "stmt_23" into SQL DESCRIPTOR desc_23;
+
+        for(i=1; i<4; i++)
+        {
+            EXEC SQL GET DESCRIPTOR desc_23 value :i :field_name[i-1] = name;
+        }
+
+        EXEC SQL DEALLOCATE DESCRIPTOR desc_23;
+        EXEC SQL AT con2 DEALLOCATE PREPARE "stmt_23";
+
+        printFieldName(tc_name);
+    }
+    else if(!strcmp(tc_name,"testcase24"))
+    {
+        EXEC SQL BEGIN DECLARE SECTION;
+        char *char_stmt_24 = "strSTMT24";
+        EXEC SQL END DECLARE SECTION;
+
+        reset();
+
+        EXEC SQL AT con1 DECLARE :char_stmt_24 STATEMENT;
+        EXEC SQL AT con2 PREPARE :char_stmt_24 FROM :selectString;
+        EXEC SQL AT con2 EXECUTE :char_stmt_24 INTO :f1,:f2,:f3;
+
+        EXEC SQL DEALLOCATE PREPARE :char_stmt_24;
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase25"))
+    {
+        reset();
+
+        EXEC SQL AT con1 DECLARE stmt_25 STATEMENT;
+        EXEC SQL AT con2 PREPARE pre_stmt_25 FROM :selectString;
+        EXEC SQL AT con2 EXECUTE pre_stmt_25 INTO :f1,:f2,:f3;
+
+        EXEC SQL AT con2 DEALLOCATE PREPARE pre_stmt_25;
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase26"))
+    {
+        reset();
+
+        EXEC SQL AT con1 DECLARE stmt_26 STATEMENT;
+        EXEC SQL AT con2 PREPARE pre_stmt_26 FROM :selectString;
+        EXEC SQL AT con2 DECLARE cur_26 CURSOR FOR pre_stmt_26;
+        EXEC SQL AT con2 OPEN cur_26;
+
+        EXEC SQL WHENEVER NOT FOUND DO BREAK;
+        i = 0;
+        while(1)
+        {
+            EXEC SQL AT con2 FETCH cur_26 INTO :f1[i],:f2[i],:f3[i];
+            i++;
+        }
+
+        EXEC SQL AT con2 CLOSE cur_26;
+        EXEC SQL AT con2 DEALLOCATE PREPARE pre_stmt_26;
+        EXEC SQL WHENEVER NOT FOUND CONTINUE;
+
+        printResultF123(tc_name,3);
+    }
+    else if(!strcmp(tc_name,"testcase27"))
+    {
+        reset();
+
+        EXEC SQL ALLOCATE DESCRIPTOR desc_27;
+
+        EXEC SQL AT con1 DECLARE stmt_27 STATEMENT;
+        EXEC SQL AT con2 PREPARE pre_stmt_27 FROM :selectTb1;
+        EXEC SQL AT con2 DESCRIBE pre_stmt_27 into SQL DESCRIPTOR desc_27;
+
+        for(i=1; i<4; i++)
+        {
+            EXEC SQL GET DESCRIPTOR desc_27 value :i :field_name[i-1] = name;
+        }
+
+        EXEC SQL DEALLOCATE DESCRIPTOR desc_27;
+        EXEC SQL AT con2 DEALLOCATE PREPARE pre_stmt_27;
+
+        printFieldName(tc_name);
+    }
+    else if(!strcmp(tc_name,"testcase28"))
+    {
+        EXEC SQL BEGIN DECLARE SECTION;
+        char    *cur_28 = "str_cur_28";
+        EXEC SQL END DECLARE SECTION;
+
+        reset();
+
+        EXEC SQL AT con1 DECLARE stmt_28 STATEMENT;
+        EXEC SQL AT con2 PREPARE stmt_28 FROM :selectString;
+        EXEC SQL AT con2 DECLARE :cur_28 CURSOR FOR stmt_28;
+        EXEC SQL AT con2 OPEN :cur_28;
+
+        EXEC SQL WHENEVER NOT FOUND DO BREAK;
+        i = 0;
+        while(1)
+        {
+            EXEC SQL AT con2 FETCH :cur_28 INTO :f1[i],:f2[i],:f3[i];
+            i++;
+        }
+
+        EXEC SQL AT con2 CLOSE str_cur_28;
+        EXEC SQL AT con2 DEALLOCATE PREPARE stmt_28;
+        EXEC SQL WHENEVER NOT FOUND CONTINUE;
+
+        printResultF123(tc_name,3);
+
+    }
+    else if(!strcmp(tc_name,"testcase29"))
+    {
+        reset();
+
+        EXEC SQL AT con1 DECLARE stmt_29 STATEMENT;
+        EXEC SQL PREPARE stmt_29 FROM :selectString;
+        EXEC SQL DECLARE cur_29 CURSOR FOR stmt_29;
+
+        EXEC SQL OPEN cur_29;
+
+        EXEC SQL WHENEVER NOT FOUND DO BREAK;
+        i = 0;
+        while(1)
+        {
+            EXEC SQL FETCH cur_29 INTO :f1[i],:f2[i],:f3[i];
+            i++;
+        }
+
+        EXEC SQL CLOSE cur_29;
+        printResultF123(tc_name,3);
+
+        reset();
+        /* Open and fetch cursor again */
+        EXEC SQL OPEN cur_29;
+        i = 0;
+        while(1)
+        {
+            EXEC SQL FETCH cur_29 INTO :f1[i],:f2[i],:f3[i];
+            i++;
+        }
+
+        EXEC SQL CLOSE cur_29;
+        EXEC SQL DEALLOCATE PREPARE stmt_29;
+        EXEC SQL WHENEVER NOT FOUND CONTINUE;
+
+        printResultF123(NULL,3);
+    }
+    else
+    {
+        EXEC SQL WHENEVER NOT FOUND CONTINUE;
+        printf("Sorry, there isn't this testcase: %s!\n",tc_name);
+    }
+}
+
+
+/*
+ * success -- 0
+ * failed -- -1
+ */
+int createTable()
+{
+    EXEC SQL AT con1 CREATE TABLE source (f1 integer, f2 integer, f3 varchar(20));
+    EXEC SQL AT con2 CREATE TABLE source (f1 integer, f2 integer, f3 varchar(20));
+    EXEC SQL AT con3 CREATE TABLE source (f1 integer, f2 integer, f3 varchar(20));
+
+    EXEC SQL AT con1 CREATE TABLE tb1 (con1_f1 integer, con1_f2 integer, con1_f3 varchar(20));
+    EXEC SQL AT con2 CREATE TABLE tb1 (con2_f1 integer, con2_f2 integer, con2_f3 varchar(20));
+    EXEC SQL AT con3 CREATE TABLE tb1 (con3_f1 integer, con3_f2 integer, con3_f3 varchar(20));
+
+    EXEC SQL AT con1 CREATE TABLE target (f1 integer, f2 integer, f3 varchar(20));
+    EXEC SQL AT con2 CREATE TABLE target (f1 integer, f2 integer, f3 varchar(20));
+    EXEC SQL AT con3 CREATE TABLE target (f1 integer, f2 integer, f3 varchar(20));
+
+
+
+    EXEC SQL AT con1 INSERT INTO source VALUES(1,10,'db on con1');
+    EXEC SQL AT con1 INSERT INTO source VALUES(2,20,'db on con1');
+    EXEC SQL AT con1 INSERT INTO source VALUES(3,30,'db on con1');
+
+    EXEC SQL AT con2 INSERT INTO source VALUES(1,10,'db on con2');
+    EXEC SQL AT con2 INSERT INTO source VALUES(2,20,'db on con2');
+    EXEC SQL AT con2 INSERT INTO source VALUES(3,30,'db on con2');
+
+    EXEC SQL AT con3 INSERT INTO source VALUES(1,10,'db on con3');
+    EXEC SQL AT con3 INSERT INTO source VALUES(2,20,'db on con3');
+    EXEC SQL AT con3 INSERT INTO source VALUES(3,30,'db on con3');
+
+    commitTable();
+
+    return 0;
+}
+
+/*
+ * success -- 0
+ * failed -- -1
+ */
+void dropTable()
+{
+    EXEC SQL AT con1 DROP TABLE IF EXISTS source;
+    EXEC SQL AT con2 DROP TABLE IF EXISTS source;
+    EXEC SQL AT con3 DROP TABLE IF EXISTS source;
+
+    EXEC SQL AT con1 DROP TABLE IF EXISTS target;
+    EXEC SQL AT con2 DROP TABLE IF EXISTS target;
+    EXEC SQL AT con3 DROP TABLE IF EXISTS target;
+
+    EXEC SQL AT con1 DROP TABLE IF EXISTS tb1;
+    EXEC SQL AT con2 DROP TABLE IF EXISTS tb1;
+    EXEC SQL AT con3 DROP TABLE IF EXISTS tb1;
+
+    commitTable();
+}
+
+void reCreateTable()
+{
+    dropTable();
+    createTable();
+}
+
+void truncateTable()
+{
+    EXEC SQL AT con1 TRUNCATE TABLE target;
+    EXEC SQL AT con2 TRUNCATE TABLE target;
+    EXEC SQL AT con3 TRUNCATE TABLE target;
+
+    commitTable();
+}
+
+void commitTable()
+{
+    EXEC SQL AT con1 COMMIT;
+    EXEC SQL AT con2 COMMIT;
+    EXEC SQL AT con3 COMMIT;
+}
+
+/*
+ * reset all the output variables
+ */
+void reset()
+{
+    int i;
+
+    truncateTable();
+
+    memset(f1,0,sizeof(f1));
+    memset(f2,0,sizeof(f2));
+    memset(f3,0,sizeof(f3));
+
+    for(i=0; i<COLUMN_NUM; i++)
+    {
+        memset(field_name[i],0, FIELD_NAME_LEN);
+    }
+}
+
+int initValues()
+{
+    return 0;
+}
+
+void releaseValues()
+{
+}
+
+void printResultF123(char *tc_name, int loop)
+{
+    int i;
+
+    if(loop>OUT_ARRAY_SZIE)
+    {
+        loop = OUT_ARRAY_SZIE;
+    }
+
+    if(tc_name)
+    {
+        printf("****%s test results:****\n",tc_name);
+    }
+
+    for (i = 0; i < loop; i++)
+        printf("f1=%d, f2=%d, f3=%s\n", f1[i], f2[i], f3[i]);
+
+    printf("\n");
+}
+
+void printResultIndF123(char *tc_name, int loop)
+{
+    int i;
+
+    if(loop>OUT_ARRAY_SZIE)
+    {
+        loop = OUT_ARRAY_SZIE;
+    }
+
+    if(tc_name)
+    {
+        printf("****%s indicator results:****\n",tc_name);
+    }
+
+    for (i = 0; i < loop; i++)
+        printf("ind_f1=%d, ind_f2=%d, ind_f3=%d\n", ind_f1[i], ind_f2[i], ind_f3[i]);
+
+    printf("\n");
+}
+
+void printFieldName(char *tc_name)
+{
+    int i;
+
+    if(tc_name)
+    {
+        printf("****%s test results:****\n",tc_name);
+    }
+
+    for (i = 0; i < COLUMN_NUM; i++)
+    {
+        printf("field[%d]'s name = %s\n", i, field_name[i]);
+    }
+
+    printf("\n");
+}
