Endorphin
March 25th, 2009, 12:54 PM
Using Oracle.
I have two tables
TABLE1
id,
name,
attribute
TABLE2
id,
name,
attribute
I need to copy all rows from TABLE1 to TABLE2 where name = :name,
However when doing this I have to also set the id of all the fields being copied into TABLE2 to :id (this value remains constant across all fields that are being copied).
So if :id = 1000, irrespective of what their value in TABLE1.id is, all rows being copied to TABLE2 will have the id.value of 1000.
I know I need something like
INSERT INTO TABLE2 (id, name, attribute) SELECT (id, name, attribute) FROM TABLE1 WHERE name = :name
But just need to get at that id value to set it.
I have two tables
TABLE1
id,
name,
attribute
TABLE2
id,
name,
attribute
I need to copy all rows from TABLE1 to TABLE2 where name = :name,
However when doing this I have to also set the id of all the fields being copied into TABLE2 to :id (this value remains constant across all fields that are being copied).
So if :id = 1000, irrespective of what their value in TABLE1.id is, all rows being copied to TABLE2 will have the id.value of 1000.
I know I need something like
INSERT INTO TABLE2 (id, name, attribute) SELECT (id, name, attribute) FROM TABLE1 WHERE name = :name
But just need to get at that id value to set it.