views:

247

answers:

1

I perform some actions on a table retrieved from a db2 database row by row in a C# project. but when I try to update it using cursors row by row to the database using the following statement selectCommand.CommandText = "DECLARE crsr1 CURSOR FOR select * from " + tableName+" ;" , an exception is generated.

From my understanding of this, using cursors statements of db2 is not supported in .net languages. I am connected to the database using IBM DB2 ODBC drivers.

Is there is any way around using cursors , or if somecane can tell whether there is something I am missing here.

I tried alot searching on net , but not much is available on this problem.

this is the exception I got for the above statement --

{"ERROR [42601] [IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token \"DECLARE CRSR1 CURSOR FOR select * from MYTA\" was found following \"BEGIN-OF-STATEMENT\". Expected tokens may include: \"\". SQLSTATE=42601\r\n"}

any help or suggestions are highly appreciated.

A: 

I think that you probably want to put that into a proc - you don't normally do a 'declare cursor..' outside of a Stored proc {unless you were debugging in the CLI or something}

phatmanace