dbTalk Databases Forums  

Ignoring an SQL INSERT error

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss Ignoring an SQL INSERT error in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Shawn Chisholm
 
Posts: n/a

Default Ignoring an SQL INSERT error - 06-07-2004 , 12:54 PM







Hi,

Does anyone know of a way to perform an insert that does not abort the
transaction if it fails?

I am trying to implement a rule that will allow the insertion data into a
view (for backward compatability) by performing inserts in other tables, and
there are situations where an insert into one of the underlying tables is
unnecessary and causes a unique key constraint violation. Ideally I would
like to do an insert and ignore any errors...

Thanks,

Shawn

PS. I am using PostgreSql 7.4



---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)


Reply With Quote
  #2  
Old   
Josh Berkus
 
Posts: n/a

Default Re: Ignoring an SQL INSERT error - 06-07-2004 , 03:03 PM






Shawn,

Quote:
Does anyone know of a way to perform an insert that does not abort the
transaction if it fails?
Unfortunately, there is no way to do this at this time. It will become
possible when the Nested Transactions feature is added, hopefully in
PostgreSQL7.5 (it is being tested now, you are welcome to help test).

Quote:
I am trying to implement a rule that will allow the insertion data into a
view (for backward compatability) by performing inserts in other tables,
and there are situations where an insert into one of the underlying tables
is unnecessary and causes a unique key constraint violation. Ideally I
would like to do an insert and ignore any errors...
The best way for you to do this on your current production system is to test
for the failure condition in advance.

If you need further help with this, I suggest hopping to the PGSQL-SQL mailing
list; that is where the largest # of people who do rules, triggers, etc. hang
out.

--
Josh Berkus
Aglio Database Solutions
San Francisco

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match



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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.