Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 1 of 1 total
Thread INSERT-SELECT bug
Mon, Mar 31 2008 4:24 AMPermanent Link

"David Cornelius"
It appears that when I execute the following SQL statement to copy
records with a new value:

 INSERT INTO TableA (field1, field2, field3)
 SELECT 'constant-value', field2, field3
   FROM TableB WHERE field3 = 'XYZ'

that if there are several records that match the WHERE clause, there
will be several new records in the table (as expected) but only the
first of those will have field1 set to the 'constant-value'.

Since the SELECT statement by itself with a 'constant-value' works
fine, the work around is to put the SELECT clause into a CURSOR with a
WHILE NOT EOF loop and select each field into a variable, then use the
explicit form of the INSERT command inside the WHILE loop.

--
David Cornelius
CorneliusConcepts.com
custom designed software
Image