========================================================================
   TRANSFER COLUMN VALUES BETWEEN TABLES (POSTING) - THE EASY WAY   
   ========================================================================
   PRODUCT   :  R:BASE                  VERSION      :  3.1 or Higher
   CATEGORY  :  PROGRAMMING             SUBCATEGORY  :  UPDATE
   ========================================================================
 
 
   You don't need to program or understand the intricacies of DECLARE CURSOR 
   to create dynamic R:BASE programs that transfer (post) column values from 
   one table to another. Output from the SELECT command creates a command 
   file of UPDATE commands, each of which operates on one row.
 
   You can precede a column name in a SELECT command with a text string 
   constant enclosed in quotation marks. R:BASE displays that literal text 
   string as well as the column value. You can do this for multiple columns, 
   separating each item in the SELECT list with commas.
 
   To post values from one table to another, use the SELECT command to create 
   a series of UPDATE commands by combining text strings with column values. 
   The basic structure of this SELECT command is as follows:
 
   SELECT 'UPDATE t2 SET t2col2 ='=w,+
   t1col2, 'WHERE t2col1 ='=w,t1col1 FROM t1
 
   You select the data values from one table along with the text string 
   constants that will create UPDATE commands for the second table, 
   including a condition to link the two tables when doing the update. 
   In the above command, t1 and t1col2 are the source table and column; 
   t2 and t2col2 are the target table and column; t1col1 and t2col2 are 
   used to link the tables so that matching rows are updated. Note the 
   quotation marks around the text string constants that will become the 
   UPDATE command and WHERE clause.
 
   Use the SET HEADINGS OFF command to suppress the column heading, and use 
   the =w option to specify the display width of the text strings. Count the 
   number of characters in the text string to find the width. 
 
   The output from the command looks like this:
 
   UPDATE t2 SET t2col2=  t1c2value1  WHERE t2col1 =  t1c1value1
   UPDATE t2 SET t2col2=  t1c2value2  WHERE t2col1 =  t1c1value2
   UPDATE t2 SET t2col2=  t1c2value3  WHERE t2col1 =  t1c1value3
   UPDATE t2 SET t2col2=  t1c2value4  WHERE t2col1 =  t1c1value4
.
.
.
 
 
   By sending the output of the SELECT to a file, you create a dynamic file 
   of update commands that you run to post the data from one table to 
   another. When you are done, you'll have a record of the updates stored 
   in the output file.
 
   Here's an example using the CONCOMP database:
 
   OUTPUT updtrans.rmd
   SET HEADINGS OFF
   SELECT 'UPDATE transmaster SET netamount ='=34, SUM(extprice), +
   'WHERE transid ='=15, transid FROM transdetail GROUP BY transid
   SET HEADINGS ON
   OUTPUT SCREEN
   RUN updtrans.rmd 
 
   The UPDTRANS.RMD file contains the following UPDATE commands,
   which will post the totals from the TRANSDETAIL table to the 
   TRANSMASTER table:
 
    UPDATE transmaster SET netamount=       $27,000.00 WHERE transid=   4760
    UPDATE transmaster SET netamount=        $9,500.00 WHERE transid=   4780
    UPDATE transmaster SET netamount=       $76,800.00 WHERE transid=   4790
    UPDATE transmaster SET netamount=      $176,000.00 WHERE transid=   4795
    UPDATE transmaster SET netamount=      $100,250.00 WHERE transid=   4800
    UPDATE transmaster SET netamount=        $9,125.00 WHERE transid=   4865
    UPDATE transmaster SET netamount=       -$5,250.00 WHERE transid=   4970
    UPDATE transmaster SET netamount=       $87,500.00 WHERE transid=   4975
    UPDATE transmaster SET netamount=       $22,500.00 WHERE transid=   4980
    UPDATE transmaster SET netamount=       $40,500.00 WHERE transid=   5000
    UPDATE transmaster SET netamount=      $108,750.00 WHERE transid=   5010
    UPDATE transmaster SET netamount=       $80,500.00 WHERE transid=   5015
    UPDATE transmaster SET netamount=       $56,250.00 WHERE transid=   5050
    UPDATE transmaster SET netamount=       $57,500.00 WHERE transid=   5060
    UPDATE transmaster SET netamount=      $140,300.00 WHERE transid=   5065
    UPDATE transmaster SET netamount=       $95,500.00 WHERE transid=   5070
    UPDATE transmaster SET netamount=      $155,500.00 WHERE transid=   5075
    UPDATE transmaster SET netamount=       $88,000.00 WHERE transid=   5080
    UPDATE transmaster SET netamount=      $130,500.00 WHERE transid=   5085