Updating the records in to the cursor

In computer science, a database cursor is a control structure that enables traversal over the records in a database.

Cursors facilitate subsequent processing in conjunction with the traversal, such as retrieval, addition and removal of database records.

Rows Only does not seem to work with the FOR UPDATE clause.

updating the records in to the cursor-24updating the records in to the cursor-86

The employee deletion from the transaction table is performed using the WHERE CURRENT OF clause as shown below.

In SQL procedures, a cursor makes it possible to define a result set (a set of data rows) and perform complex logic on a row by row basis.

By using the same mechanics, a SQL procedure can also define a result set and return it directly to the caller of the SQL procedure or to a client application.

So, lets use a quick and dirty little A R RECORD A STATUS 1A COLHDG('Active Users' '*ON or *OFF') A VALUES('0' '1') A USERNAME 10A COLHDG('This blokes name') A USERDESC 200A COLHDG('Some other guff') A FLAG 1A COLHDG('A silly flag X/Y') A VALUES('X' 'Y') A K STATUSnote: before you leave a snarky comment saying “why didn’t you just put the flag as part of the key” – my equally salty answer is “it’s obviously deliberate to make the example clear for RPG freshers” 😉**FREE dcl-f SILLYFILE keyed usage(*update) usropn; Open SILLYFILE; status = '1'; Setll (status) filename; Reade (status) filename; Dow not %EOF(filename); if flag = 'X'; // some program logic stuff could be here flag = 'Y'; update record; endif; Reade (status) SILLYFILE; Enddo; Close SILLYFILE; *inlr = *on;“.

So, I am not going to give any excuse for my lack of comments… 🙂 So, now lets update that exact same program and change it to use SQL to do the exact same thing.


Leave a Reply