"Ed Reed" <EReed@stripped> wrote on 08/30/2005 04:08:57 PM:
> Can anyone please tell me why this fails, I've done this type of
> thing before without a problem
>
> Insert Into tbl1 Select 10306, fld2, fld3, fld4 From tbl1 Where
fld1=8114
>
>
> tbl1 has five fields all ints with fld5 being the autoincrement index.
>
> I've also tried it as,
>
> Insert Into tbl1 (fld1, fld2, fld3, fld4)
> Values(Select 10306, fld2, fld3, fld4 From tbl1 Where fld1=8114)
>
>
> I think its obvious what I want but just in case, I want to
> duplicate all the records where fld1 matches my value and assign all
> the duplicate records a new value for fld1. When I do it the first
> way I get a "Column Count doesn't match value count at row 1" error.
> When I do it the second way I just get a syntax error.
>
> Thanks!
>
The correct syntax for the second method doesn't use "VALUES()". I would
always use this form if I were going to exclude any columns from receiving
data. It's just safer and relies less on the SQL engine to correctly
divine what it is you want to do.
Insert Into tbl1 (fld1, fld2, fld3, fld4)
Select 10306, fld2, fld3, fld4 From tbl1 Where fld1=8114;
Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.