1 million recs on DB - want to execute a calculation on only 100 recs

Barry G. Sumpter BarrySum at BigPond.Net.AU
Tue Oct 2 20:17:17 CDT 2007


Hi all,

Just trying to sort this out.


I have a very simple calculation.

Step1
Round up the item price to the next dollar
Step 2
Add 10% to the result in step 1
Step 3
Round to the nearest point
Step 4
Use the result in step 3 to update the xxx db field

As I don't want to:
  execute a SQL to retrieve the 100 recs.
  Loop thru each rec and execute a singe update SQL for each rec


I want the DB to do all the work thru a single SQL command.   

What's the best method for this calculation?

i.e. a stored calculation procedure ?
    as we use this calculation in many places
      where we could use a single SQL Update Command 
           that selects the 100 recs 
              and calls the stored calculation procedure 

or perhaps a single SQL update command 
   that selects the 100 recs 
     that somehow contain this calculation embedded in the SQL 
            (not as a stored procedure)

Thanks,
    Barry G. Sumpter




More information about the Valentina mailing list