473,763 Members | 2,930 Online
Bytes | Software Development & Data Engineering Community
+ 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 7199
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**********@mi kropis.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**********@mi kropis.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**********@mi kropis.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
4592
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 at the same time. Neither works at all under Solaris sqlplus. Does anyone see what the problem is? create or replace trigger aut_itri
1
3830
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 = Count(*) from Inserted If @Count > 0 Begin
1
17342
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 date columns) if the row is being inserted and set a column (e.g. just the modified date column) if the row is being updated. I know how to do this in oracle plsql. I would define it as a before insert or update trigger and reference old and new...
1
2580
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 "zzz"... CAREATE TABLE zzz ( ... ... );
1
4461
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 function created to do this task. The function I am trying to create is as follows: CREATE FUNCTION customer_bak_proc(integer) RETURNS boolean as 'INSERT INTO customer_bak (SELECT * from customer where id = $1 )' LANGUAGE 'SQL';
0
2042
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 for the table. Let's consider the following simple example: ------------------- create table testTable(id NUMBER(10) PRIMARY KEY, name VARCHAR(20));
1
1641
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# form and how to check if the trigger already exist regards Sandi Antono
3
7258
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
2434
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 value entered in the name column. Let's say a new column is entered with the value of name column as mickey. I want to create a table called mickey, with the help of triggers. I'm really new to this and i would like some help. Thanks in advance for...
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 taken the value from the table BARCODE. I have write this but doesnt work ==========================================
0
9563
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9383
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9992
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9935
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7364
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5268
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3916
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 we have to send another system
3
2790
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.