Обсуждение: trigger insert duplicate rows question

Поиск
Список
Период
Сортировка

trigger insert duplicate rows question

От
T.R.Missner@Level3.com
Дата:
I have designed a trigger that will insert a row
in a table if a check to see if the row is already there fails.
Everything works as expected when running slow or with few threads.
but when I kick up the threads that handle the initial insert that
'triggers' the trigger I run into some trouble.  It seems that
in some cases after the trigger function has done a selct to see it
the data already exist then moves on to the insert the insert fails
because another thread has already finished inserting the same row.
I get an error about duplicate rows etc.

This in itself is really not a problem.  What I would like to do
is suppress the error message somehow.  I am using jdbc on the client side
and can't figure out how to suppress the error from going to stdout.

Can I capture it in the procedure code?

Any other suggestions?

Is there a way to get a return from the insert statement in the prodecure?

thanks in advance.
t.r. missner

Re: trigger insert duplicate rows question

От
Martijn van Oosterhout
Дата:
On Tue, Sep 25, 2001 at 10:39:05PM -0600, T.R.Missner@Level3.com wrote:
> Can I capture it in the procedure code?

I don't know about JDBC but I'm pretty sure the C library has a callback
function to deal with NOTICEs from the server, thus allowing you to suppress
them.

> Any other suggestions?

Don't try to insert so many duplicate rows? This may not be possible in your
application.

> Is there a way to get a return from the insert statement in the prodecure?

After you do an insert the result tells you the number of rows inserted. I
beleive this can be used to see if the insert succeeded.

HTH,
--
Martijn van Oosterhout <kleptog@svana.org>
http://svana.org/kleptog/
> Magnetism, electricity and motion are like a three-for-two special offer:
> if you have two of them, the third one comes free.