473,487 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

CREATE TRIGGER -> writing to file???

FM
Hello:

I want to create a trigger wich performs a write-action to a text file.
I'm intending to create it with:
CREATE TRIGGER TR_ALARMA_TSPRE
AFTER INSERT ON T_ALARMA_TS
FOR EACH STATEMENT
BEGIN ATOMIC
VALUES (SELECT a1,a2,a3 FROM T_TABLE >c:\TRIGGERTEST.LOG);
END

It is possible to do it???

Many thanks in advance,
Felix

Aug 28 '06 #1
8 7168
FM wrote:
Hello:

I want to create a trigger wich performs a write-action to a text file.
I'm intending to create it with:
CREATE TRIGGER TR_ALARMA_TSPRE
AFTER INSERT ON T_ALARMA_TS
FOR EACH STATEMENT
BEGIN ATOMIC
VALUES (SELECT a1,a2,a3 FROM T_TABLE >c:\TRIGGERTEST.LOG);
END
Simply define a C UDF that does the job.
I think there samples in sqllib/samples/c and IIRC developerWorks DB2
has some source code as well.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Aug 28 '06 #2
Hi!

Go to
http://www-128.ibm.com/developerwork...0302izuha.html
There you will find put_line function that we use a lot for writing stuff
into a file from procedures.
The problem with put_line is that we experience random crashes of the
put_line DLL itself. It can work for months without a problem. And also the
problem is that there is no 64-bit version of it. And I didn't find a way
how to compile it into 64-bit version using MinGW :((( Please let me know
if you have any experience is this field.
So we are using the 32-bit version of put_line on 64-bit version DB2 like a
FENCED function. The problem with this is that after a while we have to
restart the instance, since it seem that put_line takes too much resources
and it doesn't want to cooperate anymore. :(((

My take on this is: It is great as start, but if you know how to write your
own C code do it yourself (and then share the code with me :))) ).
I've also thought about writing a little Java stored procedure for this, but
I'm not wuite sure about the performance of those. I'll have to do more
tests.

Best regards,
Kovi

FM wrote:
Hello:

I want to create a trigger wich performs a write-action to a text file.
I'm intending to create it with:
CREATE TRIGGER TR_ALARMA_TSPRE
AFTER INSERT ON T_ALARMA_TS
FOR EACH STATEMENT
BEGIN ATOMIC
VALUES (SELECT a1,a2,a3 FROM T_TABLE >c:\TRIGGERTEST.LOG);
END

It is possible to do it???

Many thanks in advance,
Felix
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Aug 31 '06 #3
Gregor Kovač wrote:
Hi!

Go to
http://www-128.ibm.com/developerwork...0302izuha.html
There you will find put_line function that we use a lot for writing stuff
into a file from procedures.
The problem with put_line is that we experience random crashes of the
put_line DLL itself.
I had a look at the code and it might be that you run into a buffer overflow
that subsequently causes the crash. Another problem may be that null
indicators are incorrectly handled. The code just isn't robust enough and
should be reworked quite a bit... Maybe this one is more stable:
http://tinyurl.com/nfxs9

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Aug 31 '06 #4
Knut Stolze wrote:
Gregor Kovač wrote:
>Hi!

Go to
http://www-128.ibm.com/developerwork...0302izuha.html
>There you will find put_line function that we use a lot for writing stuff
into a file from procedures.
The problem with put_line is that we experience random crashes of the
put_line DLL itself.

I had a look at the code and it might be that you run into a buffer
overflow
that subsequently causes the crash. Another problem may be that null
indicators are incorrectly handled. The code just isn't robust enough and
should be reworked quite a bit... Maybe this one is more stable:
http://tinyurl.com/nfxs9
Thanks, I'll give it a try.
I've also written a Java stored procedure that writes to a file, but is five
times slower than the C version (put_line) :((

Best regards,
Kovi
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Sep 1 '06 #5
Knut Stolze wrote:
Gregor Kovač wrote:
>Hi!

Go to
http://www-128.ibm.com/developerwork...0302izuha.html
>There you will find put_line function that we use a lot for writing stuff
into a file from procedures.
The problem with put_line is that we experience random crashes of the
put_line DLL itself.

I had a look at the code and it might be that you run into a buffer
overflow
that subsequently causes the crash. Another problem may be that null
indicators are incorrectly handled. The code just isn't robust enough and
should be reworked quite a bit... Maybe this one is more stable:
http://tinyurl.com/nfxs9
I've seen that you are using SCRATCHPAD in your functions. I'm wondering if
I use the functions in my stored procedures will they work correctly if I
run them at the same time ?

--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
| Gregor Kovac | Gr**********@mikropis.si |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Sep 1 '06 #6
Gregor Kovač wrote:
I've seen that you are using SCRATCHPAD in your functions. I'm wondering
if I use the functions in my stored procedures will they work correctly if
I run them at the same time ?
Yes, they will. Each function invocation has its own scratchpad. Even if
you use the same function multiple times in the same SQL statements, the
scratchpads will not be shared between the occurrences. Of course, the
same applies to function invocations in different SQL statements.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Sep 1 '06 #7
FM

Knut Stolze wrote:
Gregor Kovac wrote:
Hi!

Go to
http://www-128.ibm.com/developerwork...0302izuha.html
There you will find put_line function that we use a lot for writing stuff
into a file from procedures.
The problem with put_line is that we experience random crashes of the
put_line DLL itself.

I had a look at the code and it might be that you run into a buffer overflow
that subsequently causes the crash. Another problem may be that null
indicators are incorrectly handled. The code just isn't robust enough and
should be reworked quite a bit... Maybe this one is more stable:
http://tinyurl.com/nfxs9

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Hello Mr.Stolze:
Thank you for this samples wich are very helpfully.
One question: Is there a posibility to dump the results in multiple
lines?

Thank you one more time for your help,
Flix Manresa Madrona
Bases de Datos (DB2/UDB)
Ciudad del Grupo Santander

Sep 4 '06 #8
FM wrote:
>
Knut Stolze wrote:
>Gregor Kovac wrote:
Hi!

Go to
http://www-128.ibm.com/developerwork...0302izuha.html
There you will find put_line function that we use a lot for writing
stuff into a file from procedures.
The problem with put_line is that we experience random crashes of the
put_line DLL itself.

I had a look at the code and it might be that you run into a buffer
overflow
that subsequently causes the crash. Another problem may be that null
indicators are incorrectly handled. The code just isn't robust enough
and
should be reworked quite a bit... Maybe this one is more stable:
http://tinyurl.com/nfxs9

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Hello Mr.Stolze:
Thank you for this samples wich are very helpfully.
One question: Is there a posibility to dump the results in multiple
lines?
Yes, there is. You can do whatever you want in the file-writing function.
So you can insert linebreaks where you like. (The current implementation
adds a line break after each function call.)

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Sep 5 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4561
by: Darren | last post by:
Hello, I have some 'CREATE TRIGGER' definitions that work when cut/pasted into SQL*Plus worksheet and execute separately but fail with a 'trigger created with compilation errors' when executed...
1
3808
by: Jack | last post by:
I created a trigger in the "source table" that will "feed" and second table. The trigger is as follows: CREATE TRIGGER ON dbo.FromUPS FOR INSERT AS Declare @Count int Select @Count =...
1
17325
by: efinney | last post by:
Hi, I'm a newbie to sql server and this may be a really dumb question for some you. I'm trying to find some examples of sql server triggers that will set columns (e.g. the created and modified...
1
2550
by: Ling Xiaoyu | last post by:
Hello there. Can anybody help me with Postgresql triggers? what I need is a trigger which update value of field "tables_rows.total_rows" to rows count of table "zzz" if I insert new row in table...
1
4432
by: Barbara Lindsey | last post by:
I am a postgres newbie. I am trying to create a trigger that will put a copy of a record into a backup table before update or delete. As I understand it, in order to do this I must have a...
0
2019
by: Yogesh | last post by:
Hello Everyone I have to create Oracle tables in my application on the fly, which have an Autonumber field. So, everytime I create a table, I have to create a corresponding sequence and trigger...
1
1622
by: sandi | last post by:
Please Advice... I need to create SqlServer2005 trigger from C# form. so all my trigger can re-create if i push one button on my app.... i need to know how i create and delete trigger from c#...
3
7233
by: satish | last post by:
hi, CAn i have one trigger for both Update and Delete Delete Trigger --------------------- create Trigger on . for delete as begin insert into z_user_log select * from deleted end
2
2417
by: lakuma | last post by:
Hi, I have a table called A (say) with columns called name, place, animal and thing. I would want to write an on insert trigger on this table, which would create a table with the name of the...
3
1811
by: Andrea MF | last post by:
Hi all, i have a problem when creating a trigger on DB2 ver 7.2 on WINDOWS. I have two tables MOVIMAG and BARCODE, the trigge when INSERT INTO MOVIMAG will be UPDATE a MOVIMAG field BARCODE...
0
7105
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7132
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7180
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
4870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.