Subject Re: [ib-support] Insert Into
Author Helen Borrie
At 11:15 AM 25-01-02 -0600, Mike Grover wrote:
>I need to do a select on one table and insert the records into another
>in a particular order.
>
>the second table is a external Table.

Sounds like it's time to discover the magic world of stored procedures, Mike. :)

create procedure stuffemin (input1 sometype input2 sometype)
returns (out1 char(m), out2 char(n),....<all wanted fields>, linebreak char(2))
as
begin
linebreak=CRLF(); /* declared from FreeUDFLib.dll */
for select blah, blah1, .....
from atable
where <match inputs>
order by <something>
into :out1, :out2, ...and the rest....
do begin
insert into extable (<field list>, linebreak)
values( cast(:out1 as char(m), cast(:out2 as char(n)....rest of list in right order, :linebreak);
suspend;
when any do
begin
<handle or lose the row that caused the exception>
end
end
end

You can massage the data (at row and column level) any way you like inside the processing block, including trap exceptions and silence them with WHEN ANY DO

Probably some traps here but you get the picture...

regards,
Helen

All for Open and Open for All
Firebird Open SQL Database ยท http://firebirdsql.org
_______________________________________________________