Subject | RE: [firebird-support] Re: Absolute Mystery |
---|---|
Author | Edwin A. Epstein, III |
Post date | 2005-02-16T00:02:55Z |
Heh. 10046. That must of been my subconcious there :)
raised within it would be visible to the caller and would have to be handled
there, hence IB Workbench would pop up the dialog box asking me what to do
with it. Also the DROP_FILE table has no PK or constraints on it. So an
exceptions inside the WHEN ANY DO are transliteration errors or values that
are too big. I have largely solved this problem and the transliteration
errors are few, but once again visible.
I have tested this extensively before to show that it is a good method to
accomplish our goals. For 2 reasons. The WHEN ANY DO causes SERVER side
exception handling and DROP_FILE creation. If it is commented out, or
alternate procedures created without it, then all the exceptions raised
within the SP deliberately or otherwise are handled APP side. We use SERVER
side mostly since we have had the need to query the DROP_FILE on more than
one occasion.
files.
script lines are unique though.
However, duplicates will not cause me any problems. In fact I am counting
on them. The stored procedure itself looks for many different errors and
throws the exceptions itself. The WHEN ANY DO catches the exception and
then performs an INSERT on the DROP_FILE. The record itself will have a
descriptor "DUPLICATE".
This particular case I made sure they were unique. I don't always. This
was to save time since it was so large a batch. Usually I allow duplicate
lines in the script since they represent duplicates being presented to us.
The SP will catch the fact it is a duplicate and then throw the proper
exception which gets represented in the DROP_FILE. I actually check what
kind of duplicate it is. I can tell if it a duplicate of data in database
already, duplicates of data being imported in this particular batch, or
duplicates of data with the same source.
That's the wierd thing here. All the exceptions are accounted for and
visible. Exceptions outside the WHEN ANY DO get a global set and then
processed, Exceptions inside the WHEN ANY DO cause a dialog box to pop up
and pause the script. If it is an exception, then it silent for some
reason. How can an exception be silent?
-----Original Message-----
From: Adam [mailto:s3057043@...]
Sent: Tuesday, February 15, 2005 3:43 PM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Re: Absolute Mystery
Hi Edwin,
It looks like your methodology is pretty good. The only thing I might
clarify though is that the when any do .... code does not catch
exceptions that occur within it.
Simplifying the example just a bit further, you have something like
this:
begin
insert into tablea (id, name) values (5, 'Adam');
when any do
begin
insert into problema (id, name) values (5, 'Adam');
end
end
^
Now if the first insert excepts, it will be handled by the when any
do clause. However if the second insert excepts, this will not be
handled.
One experiment you could do is to create a temporary generator, which
might look something like this.
declare variable tmp integer;
begin
insert into tablea (id, name) values (5, 'Adam');
when any do
begin
tmp = gen_id (tablea_errors,1);
insert into problema (id, name) values (5, 'Adam');
end
end
^
Now when you run the procedure, you would expect the same number of
records in problema as is the current value of tablea_errors. If
there is a discrepancy, then the second insert must have failed
somewhere.
I would also pay careful attention to line 10046 (wow that looks like
a winsock error message :p) Is there something about this line. Is it
the same line every attempt?
Possibly also do a count of the distinct rows from access (if that
can support distinct count(*) syntax yet), as you know duplicates
will cause primary key violations in firebird.
Adam
--- In firebird-support@yahoogroups.com, "Edwin A. Epstein, III"
<eepstein@c...> wrote:
>>Now if the first insert excepts, it will be handled by the when anyYou are correct. When I ran my tests on the WHEN ANY DO, any exceptions
>>do clause. However if the second insert excepts, this will not be
>>handled.
raised within it would be visible to the caller and would have to be handled
there, hence IB Workbench would pop up the dialog box asking me what to do
with it. Also the DROP_FILE table has no PK or constraints on it. So an
exceptions inside the WHEN ANY DO are transliteration errors or values that
are too big. I have largely solved this problem and the transliteration
errors are few, but once again visible.
I have tested this extensively before to show that it is a good method to
accomplish our goals. For 2 reasons. The WHEN ANY DO causes SERVER side
exception handling and DROP_FILE creation. If it is commented out, or
alternate procedures created without it, then all the exceptions raised
within the SP deliberately or otherwise are handled APP side. We use SERVER
side mostly since we have had the need to query the DROP_FILE on more than
one occasion.
>>I would also pay careful attention to line 10046 (wow that looks likeNo. No distinct pattern here. Randomly distributed throughout the script
>>a winsock error message :p) Is there something about this line. Is it
>>the same line every attempt?
files.
>>Possibly also do a count of the distinct rows from access (if thatI am pretty sure MS Access supports DISTINCT. I have made sure that the
>>can support distinct count(*) syntax yet), as you know duplicates
>>will cause primary key violations in firebird.
script lines are unique though.
However, duplicates will not cause me any problems. In fact I am counting
on them. The stored procedure itself looks for many different errors and
throws the exceptions itself. The WHEN ANY DO catches the exception and
then performs an INSERT on the DROP_FILE. The record itself will have a
descriptor "DUPLICATE".
This particular case I made sure they were unique. I don't always. This
was to save time since it was so large a batch. Usually I allow duplicate
lines in the script since they represent duplicates being presented to us.
The SP will catch the fact it is a duplicate and then throw the proper
exception which gets represented in the DROP_FILE. I actually check what
kind of duplicate it is. I can tell if it a duplicate of data in database
already, duplicates of data being imported in this particular batch, or
duplicates of data with the same source.
That's the wierd thing here. All the exceptions are accounted for and
visible. Exceptions outside the WHEN ANY DO get a global set and then
processed, Exceptions inside the WHEN ANY DO cause a dialog box to pop up
and pause the script. If it is an exception, then it silent for some
reason. How can an exception be silent?
-----Original Message-----
From: Adam [mailto:s3057043@...]
Sent: Tuesday, February 15, 2005 3:43 PM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Re: Absolute Mystery
Hi Edwin,
It looks like your methodology is pretty good. The only thing I might
clarify though is that the when any do .... code does not catch
exceptions that occur within it.
Simplifying the example just a bit further, you have something like
this:
begin
insert into tablea (id, name) values (5, 'Adam');
when any do
begin
insert into problema (id, name) values (5, 'Adam');
end
end
^
Now if the first insert excepts, it will be handled by the when any
do clause. However if the second insert excepts, this will not be
handled.
One experiment you could do is to create a temporary generator, which
might look something like this.
declare variable tmp integer;
begin
insert into tablea (id, name) values (5, 'Adam');
when any do
begin
tmp = gen_id (tablea_errors,1);
insert into problema (id, name) values (5, 'Adam');
end
end
^
Now when you run the procedure, you would expect the same number of
records in problema as is the current value of tablea_errors. If
there is a discrepancy, then the second insert must have failed
somewhere.
I would also pay careful attention to line 10046 (wow that looks like
a winsock error message :p) Is there something about this line. Is it
the same line every attempt?
Possibly also do a count of the distinct rows from access (if that
can support distinct count(*) syntax yet), as you know duplicates
will cause primary key violations in firebird.
Adam
--- In firebird-support@yahoogroups.com, "Edwin A. Epstein, III"
<eepstein@c...> wrote:
> Good Questions :)many)
>
> >>The only gotcha I can think of at the moment, is maybe one (or
> >>of the transactions is still uncommitted, or your transaction youare
> >>running select count(*) from was started before all of the insertwill by
> >>transactions were committed.
>
> All of the lines are run inside a single transaction. A single SP
> itself perform many count(*)'s and then perform an insert on eitherTABLE_A
> or DROP_FILE. It is all performed serial, so there is no problemhere.
> Also, I don't see how it would make a record not processed at all.This
> would just create more drops than necessary, etc.the
>
> >>What happens when this code raises an exception (duplicate key
> >>violation or similar)? Does your application raise this, or does
> >>script stop on these errors?Workbench to
>
> For this situation, there is no "app" side. I am using IB
> process the script. I could just as easily use the SQL utility aswell.
> The WHEN ANY DO code in the SP catches all server side exceptionsand then
> performs an INSERT into the DROP_FILE table. This does not stopthe SP or
> any subsequent calls to the SP. You would need to raise anadditional
> exception within the WHEN ANY DO code to do that. So allexceptions for any
> reason are caught and do not stop processing.record
>
> >>How have you calculated the original script query count? Are you
> >>possibly including blank lines in this count?
>
> Yep. Used MS Access to load up the script file and got myself a
> count where the field was not null. Any blank lines would of beenaccounted
> for.into
>
> >>Is it possible for the input to have too many characters to fit
> >>the input parameter of the stored procedure?script
>
> Now this has occasionally happened to me. In this case however the
> stops processing and I receive a dialog box asking if I want toignore or
> abort. If I abort, the whole script is aborted and the transactionis rolled
> back, if I ignore it then processing continues as normal and thatparticular
> execution of the SP never occured as far as the database isconcerned. I
> have since stopped this from happening completely by creating thescript
> with functions that select only the first X amount of charactersfrom the
> input string. The only situation unresolved is transliterationerrors which
> is completely my fault since I left the field with NONE for thecharacter
> set. In any case, these errors are few, highly visible, andaccounted for.
>did
> >>Perhaps you could try and locate the last record you attempted to
> >>insert from each script, and see whether there is any script that
> >>not totally complete? When it is inserting hundreds of records perfiles. No
> >>second, you have to be watching closely to see a problem.
>
> Heh. I performed this very same check. Now here is the mystery....
>
> SCRIPT LINE 10045 'EXECUTED'
> SCRIPT LINE 10046 'MISSED'
> SCRIPT LINE 10047 'EXECUTED'
> SCRIPT LINE 10048 'EXECUTED'
>
> The missed lines are distributed randomly throughout the script
> clear pattern or indication of why. Line 10045 executed with noerrors, no
> malformed parameters, no transliteration errors, nothing. Why Line10046
> just did not execute is beyond me. Line 10047 executed just fine,so
> clearly 10046 did not stop the whole process, and COMMIT hasnothing to do
> with it, since if it did ALL 4 lines would not be present in eitherTABLE_A
> or DROP_FILE. 10045,10047, and 10048 are.Yahoo! Groups Links
>
> Once again, I am stumped :)
>