Reputation: 21
Is it possible to create a trigger that outputs a CSV file selecting Fields 1 from Table 1 right after Table 2 is updated?
I have tried using
CREATE OR ALTER trigger test_a0 for Table 2
active after insert or update position 0
AS
begin
if (updating and new.field1 is not null) then
output ('C:\test\test.csv');
select field1 from table1;
output;
commit;
end
Upvotes: 2
Views: 1713
Reputation: 6808
I suppose you can do it with IBExpert tools ibeblock
execute ibeblock
as
begin
txt='';
for
select firstname, lastname
from customer
into :fn,:ln
do
begin
txt=txt+fn+';'+ln+ibec_crlf();
end;
ibec_SaveToFile('C:\txt.csv',txt,__stfOverwrite);
end
Upvotes: 1
Reputation: 109137
No, this it is not possible to output to a CSV file in triggers in Firebird 2.5. If you want to output to a file, you either need to do that in a client application, or use an external table (which technically is a binary format, not a text format). It might be possible to create a convoluted solution using UDFs.
In Firebird 3, a simpler solution might be possible using a UDR (User Defined Routines), but this is largely unknown territory, so I'm not actually sure if it can be done that way.
Upvotes: 2