Subject Re: [IBO] Copying rows with executable procedures
Author Paul Vinkenoog
Hi yaedos2000,

> I'm trying to use an executable procedure to copy a row from one
> table to another. What's the best way of doing this? I'm currently
> trying to use a SELECT statement to read the row, then an INSERT to
> add it to the other table.
>
> for
> SELECT DATA FROM TABLE_1 WHERE ID = :SOMETHING INTO :LOCAL_VARIABLE
> do
> begin
> INSERT INTO TABLE_2 VALUES (:LOCAL_VARIABLE)
> end
>
> but this isn't working. Is there a better way of doing this, like a
> specific function for copying rows?

This is actually not an IBO question, but the answer is short:

insert into table_2 select data from table_1 where id = :something

will copy all the matching rows. No loop needed.


Greetings,
Paul Vinkenoog