Unix Technical Forum

Re: error handling

This is a discussion on Re: error handling within the pgsql Novice forums, part of the PostgreSQL category; --> Sean Davis schrieb: > Just keep in mind that the trigger runs on EVERY insert, even those for > ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Novice

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 09:52 PM
Verena Ruff
 
Posts: n/a
Default Re: error handling

Sean Davis schrieb:

> Just keep in mind that the trigger runs on EVERY insert, even those for
> which the unique clause is not violated. If that is the behavior you need,
> then use the trigger. However, if you know that after you have clean data
> in the table, you will not be inserting "duplicates" (I think this is the
> typical case), then a trigger may not be the way to go.
>

These were my concerns in the first place I was thinking about using
triggers. Maybe I haven't really understood your suggestion right. When
would the temporary table be created? Isn't it neccessary to create it
on every insert, too? With wich statement could I do this without using
a trigger which is fired on every insert?

Thanks for your patience.

Regards,
Verena



---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 09:52 PM
Sean Davis
 
Posts: n/a
Default Re: error handling

Verena Ruff wrote:
> Sean Davis schrieb:
>
>> Just keep in mind that the trigger runs on EVERY insert, even those for
>> which the unique clause is not violated. If that is the behavior you
>> need,
>> then use the trigger. However, if you know that after you have clean
>> data
>> in the table, you will not be inserting "duplicates" (I think this is the
>> typical case), then a trigger may not be the way to go.
>>

>
> These were my concerns in the first place I was thinking about using
> triggers. Maybe I haven't really understood your suggestion right. When
> would the temporary table be created? Isn't it neccessary to create it
> on every insert, too? With wich statement could I do this without using
> a trigger which is fired on every insert?
>
> Thanks for your patience.


No problem. I was thinking that you had a bunch of data that you wanted
to load ONCE, clean up, and then you would NOT be inserting duplicated
values. If you are going to be inserting duplicates potentially with
every insert, I think that a trigger is the only way to go on the DB
side of things. Of course, you could do things on the client side, as
well (do a lookup, find nothing--do insert, find something--do nothing
or do update).

Sean

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 09:52 PM
Verena Ruff
 
Posts: n/a
Default Re: error handling

Hi,

Sean Davis schrieb:
> No problem. I was thinking that you had a bunch of data that you
> wanted to load ONCE, clean up, and then you would NOT be inserting
> duplicated values. If you are going to be inserting duplicates
> potentially with every insert, I think that a trigger is the only way
> to go on the DB side of things. Of course, you could do things on the
> client side, as well (do a lookup, find nothing--do insert, find
> something--do nothing or do update).


Thanks for your opinion. Then I'll go with a trigger.

Regards,
Verena

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:12 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com