Page 1 of 1
error syntax NET
Posted: Mon 05 Dec 2005 14:47
by felmarla
As it is the syntax of the handling of execution of cursors in NET since it leaves syntax error to me surrounds to all and I have asi.
pgcoman.CommandText=("fetch all in \"ref\"");
Posted: Mon 05 Dec 2005 15:17
by SecureGen
Such code works ok in my tests. Please make sure that you open and fetch cursor in the same transaction.
PgSqlCommand cursorCmd = new PgSqlCommand("fetch all in \"dept\"", pgSqlConnection);
// need to start transaction, because cursor is acessible only in transaction
PgSqlTransaction tr = pgSqlConnection.BeginTransaction();
try{
try {
....
// Opens named cursor
....
// fetch data from named cursor
PgSqlDataReader dataReader = cursorCmd.ExecuteReader();
while (dataReader.Read()) {
object obj = dataReader.GetValue(0);
recCount++;
}
dataReader.Close();
}
finally{
// commit transaction
tr.Commit();
}