Path: utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!julius.cs.uiuc.edu!apple!mips!wdl1.wdl.fac.com!wdl47!eric From: eric@wdl47.wdl.fac.com (Eric Kuhnen) Newsgroups: comp.databases Subject: Re: How to change each row in a table using SQL ? Message-ID: <1990Nov5.191125.3008@wdl1.wdl.fac.com> Date: 5 Nov 90 19:11:25 GMT References: <1990Oct25.081639.14155@abblund.se> <1990Nov1.144502.18208@pds3> Sender: root@wdl1.wdl.fac.com (SUPER USER) Organization: LORAL Western Development Labs Lines: 32 Nntp-Posting-Host: wdl47 ravi@pds3 (Gorur R. Ravi) writes: > I would write a small Pro*C program for problems like these. There >might be an easier way to do this which I can't think of at this moment. >You need to select ROWID in your SQL statement and get >records using FETCH statement. Then update records in a while loop using >ROWID in the WHERE clause. A partial code might look like this. > EXEC SQL DECLARE C1 CURSOR FOR SELECT ROWID FROM ; > EXEC SQL OPEN C1; > EXEC SQL WHENEVER NOT FOUND GOTO FINISH; > while(1) > { > EXEC SQL FETCH C1 INTO :rowid; > rowid.arr[rowid.len] = '\0'; > > EXEC SQL UPDATE SET ERR_FLD = WHERE > ROWID = :rowid; > } > FINISH: EXEC SQL CLOSE C1; I think you'll find that the SQL "update" command will do everything that you've outlined here, and with less confusion. The solution is: update set elapsed_time = elapsed_time - starting_time; No cursors, rowids, fetch loops, muss, or fuss. One simple command does it all! Plus, if you act now, we'll throw in this wonderful . . . . Well, you get the idea. "Q"