Subject | Re: [IBO] Real Stumper of an error, Please help.--Jason, Use of IB_Monitor |
---|---|
Author | Chuck Belanger |
Post date | 2012-12-07T19:44:25Z |
Jason:
I wanted to give an update on this series of issues.
This issue seems to be about using IB_Query or IBOQuery within a While
not EOF loop and in that loop there is an Edit, Field1.value :=
Field2.Value; then POST.
I can supply the IB_Monitor log for both issues that came up (another
one came up after I solved the first).
What I have seen in the past (4.8.7, now 5.2) is that sometimes I simply
cannot do some relatively simple dataset operation like above, but if I
simply change from IBOQuery to IB_Query or vice versa, everything works
just fine. It is just something I worked out when desperate to resolve a
problem and trying everything.
The errors were the same for both situations. A PK violation, when the
POST was not touching the PK field (and there are no triggers to update
another table). The table was the same for both (CV_TABLE_COLUMNS). I
looked over the export table and db and import table of that name and db
and could find nothing wrong with either. I could isolate the problem
down to the record and that data was fine on both sides of the
field.value assignment. In the first issue, the Loop-Edit-Post worked
fine for 5 records then did not. In the second, the routine threw an
error on the first record.
In the first case, it was the above While not EOF loop with a POST. I
changed from IB_Query to IBOQuery and it worked fine.
In the second case, again it was a While not EOF loop with a POST. I
changed from IB_Query to IBOQuery and it still threw an error. Then I
changed the Field.value assignment with Post to a IB_DSQL.Update
statement instead and it now works just fine.
Learning to use the IB_Monitor has been worth this experience. And this
experience took up most of this week to resolve.
For those, like myself who are database and programming challenged (this
is more a hobby of mine to support my professional work), here's how you
set up IB_Monitor with IB_LogFiles.pas
1. Drop the component on the form in question.
2. I set the Monitor to record for most everything.
3. In your Uses add IB_LogFiles.
Private
ALogFile: TLogFiles;
4. In the form create add:
// set up of IB_Monitor for logging, when needed, Monitor.enable := true;
ALogFile := TLogFiles.Create;
with ALogFile do
begin
LogDir := ExtractFilePath(Application.ExeName);
LogFmt := '"log_' + FormatDateTime('yyymmddhhmmnn', now) + '"';
ItemFmt := '';
IB_Monitor1.OnMonitorOutputItem := MonitorOutputItem;
end;
5. Add to the Form Destroy event:
if IB_Monitor1.Enabled then
begin
IB_Monitor1.Enabled := FALSE;
end;
IB_Monitor1.OnMonitorOutputItem := nil;
if Assigned(ALogFile) then
ALogFile.Free;
6. I'm not sure if you need to actually set IB_Monitor.Enabled := false;
to close and save the log file. But I did add that to a routine I use
for the IB.OnError event.
in OnError of IBO components
IB_Monitor1.Enabled := FALSE;
//not sure these are necessary here...
IB_Monitor1.OnMonitorOutputItem := nil;
ALogFile.Free;
7. I added conditional logic to Enable the IB_Monitor just where I
wanted it. Very easy.
Example:
if TableName = 'CV_TABLE_COLUMNS' then
begin
IB_Monitor1.Enabled := True;
Application.ProcessMessages; <- not sure this is needed.
end;
or
you can simply bracket the code you want to monitor with
IB_Monitor1.Enabled := True;
then
IB_Monitor1.Enabled := False;
And you can turn it off when out of the code you want to review the DB
routines:
There is a lot of information in the log file and I am not sure how to
interpret it all, but it did help to see what what going on. Thomas
loaned me a full license to FB Trace Mgr and I did figure out how to set
a trace with that, but IB_Monitor is easier to set up and the log file
is easier to read then going back and forth between the browse grid and
the raw text output. The double click feature to go from the grid to the
raw text output associated with the grid row did not work. In the end,
to these eyes, the information was very much the same between IB_Monitor
and FB Trace Mgr, but I had only a cursory use of the obviously very
powerful system. I lost my license access when I needed to advance my
system date to force a FTP download in my application, so I had limited
use of FB Trace Manager and I would not take my experience as either a
good or bad review.
What I could see from the IB_Monitor log was that a POST is interpreted
by FB as an UPDATE and interestingly the UPDATE includes every field,
even if the POST only includes a few fields. That UPDATE included the PK
field. I am really not sure this is part of the problem that I
encountered, nor did I run another IB_Monitor session for comparison
after my "fix." I was simply running out of time to get the required
database update routine to work again (first time with the upgrade from
Delphi 2007 to XE2 and with the IBO 5 components)
I want to thank Jason and Thomas for their help. If there is something
else I can do to help out, please let me know, like grab a log of the
fixed code.
Best regards,
Chuck Belanger
I wanted to give an update on this series of issues.
This issue seems to be about using IB_Query or IBOQuery within a While
not EOF loop and in that loop there is an Edit, Field1.value :=
Field2.Value; then POST.
I can supply the IB_Monitor log for both issues that came up (another
one came up after I solved the first).
What I have seen in the past (4.8.7, now 5.2) is that sometimes I simply
cannot do some relatively simple dataset operation like above, but if I
simply change from IBOQuery to IB_Query or vice versa, everything works
just fine. It is just something I worked out when desperate to resolve a
problem and trying everything.
The errors were the same for both situations. A PK violation, when the
POST was not touching the PK field (and there are no triggers to update
another table). The table was the same for both (CV_TABLE_COLUMNS). I
looked over the export table and db and import table of that name and db
and could find nothing wrong with either. I could isolate the problem
down to the record and that data was fine on both sides of the
field.value assignment. In the first issue, the Loop-Edit-Post worked
fine for 5 records then did not. In the second, the routine threw an
error on the first record.
In the first case, it was the above While not EOF loop with a POST. I
changed from IB_Query to IBOQuery and it worked fine.
In the second case, again it was a While not EOF loop with a POST. I
changed from IB_Query to IBOQuery and it still threw an error. Then I
changed the Field.value assignment with Post to a IB_DSQL.Update
statement instead and it now works just fine.
Learning to use the IB_Monitor has been worth this experience. And this
experience took up most of this week to resolve.
For those, like myself who are database and programming challenged (this
is more a hobby of mine to support my professional work), here's how you
set up IB_Monitor with IB_LogFiles.pas
1. Drop the component on the form in question.
2. I set the Monitor to record for most everything.
3. In your Uses add IB_LogFiles.
Private
ALogFile: TLogFiles;
4. In the form create add:
// set up of IB_Monitor for logging, when needed, Monitor.enable := true;
ALogFile := TLogFiles.Create;
with ALogFile do
begin
LogDir := ExtractFilePath(Application.ExeName);
LogFmt := '"log_' + FormatDateTime('yyymmddhhmmnn', now) + '"';
ItemFmt := '';
IB_Monitor1.OnMonitorOutputItem := MonitorOutputItem;
end;
5. Add to the Form Destroy event:
if IB_Monitor1.Enabled then
begin
IB_Monitor1.Enabled := FALSE;
end;
IB_Monitor1.OnMonitorOutputItem := nil;
if Assigned(ALogFile) then
ALogFile.Free;
6. I'm not sure if you need to actually set IB_Monitor.Enabled := false;
to close and save the log file. But I did add that to a routine I use
for the IB.OnError event.
in OnError of IBO components
IB_Monitor1.Enabled := FALSE;
//not sure these are necessary here...
IB_Monitor1.OnMonitorOutputItem := nil;
ALogFile.Free;
7. I added conditional logic to Enable the IB_Monitor just where I
wanted it. Very easy.
Example:
if TableName = 'CV_TABLE_COLUMNS' then
begin
IB_Monitor1.Enabled := True;
Application.ProcessMessages; <- not sure this is needed.
end;
or
you can simply bracket the code you want to monitor with
IB_Monitor1.Enabled := True;
then
IB_Monitor1.Enabled := False;
And you can turn it off when out of the code you want to review the DB
routines:
There is a lot of information in the log file and I am not sure how to
interpret it all, but it did help to see what what going on. Thomas
loaned me a full license to FB Trace Mgr and I did figure out how to set
a trace with that, but IB_Monitor is easier to set up and the log file
is easier to read then going back and forth between the browse grid and
the raw text output. The double click feature to go from the grid to the
raw text output associated with the grid row did not work. In the end,
to these eyes, the information was very much the same between IB_Monitor
and FB Trace Mgr, but I had only a cursory use of the obviously very
powerful system. I lost my license access when I needed to advance my
system date to force a FTP download in my application, so I had limited
use of FB Trace Manager and I would not take my experience as either a
good or bad review.
What I could see from the IB_Monitor log was that a POST is interpreted
by FB as an UPDATE and interestingly the UPDATE includes every field,
even if the POST only includes a few fields. That UPDATE included the PK
field. I am really not sure this is part of the problem that I
encountered, nor did I run another IB_Monitor session for comparison
after my "fix." I was simply running out of time to get the required
database update routine to work again (first time with the upgrade from
Delphi 2007 to XE2 and with the IBO 5 components)
I want to thank Jason and Thomas for their help. If there is something
else I can do to help out, please let me know, like grab a log of the
fixed code.
Best regards,
Chuck Belanger
> Jason:
>
> Any sample code on how to use IB_LogFiles with
> IB_Monitor.OnMonitorOutput? It is not that self-evident to me.
>
> Thanks,
>
> Chuck
>> The regression testing app is part of IBO 5. Sorry to mislead you.
>> The TIB_Monitor component just gives you an event that dumps out a string.
>> Stuff the string wherever you want to. That log file component probably
>> would work or just look in the IBO source for IB_LogFile.pas and make use of
>> mine.
>>
>> Jason
>>
>>
>> -----Original Message-----
>> From:IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] On Behalf
>> Of Chuck Belanger
>> Sent: 05 December 2012 01:32 PM
>> To:IBObjects@yahoogroups.com
>> Subject: Re: [IBO] Real Stumper of an error, Please help.--Jason
>>
>> Thanks, Jason:
>>
>> I found at Torrey site: TLogFile. Is that the component you mentioned?
>>
>> Also, I cannot find the Regression Testing Application you mention both
>> here and on your site for 4.9. Not in Samples folder nor Addons.
>>
>> Could you confirm and point to the Application so I can see how to add
>> logging to the IB_Monitor?
>>
>> Thanks
>> Chuck
>>> It may help to speed things up to set the MonitorGroup mgRows off. This
>> way
>>> you won't be tracing the record fetches.
>>>
>>> Jason
>>>
>>>
>>> -----Original Message-----
>>> From:IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] On
>> Behalf
>>> Of Chuck Belanger
>>> Sent: 04 December 2012 02:21 PM
>>> To:IBObjects@yahoogroups.com
>>> Subject: Re: [IBO] Real Stumper of an error, Please help.
>>>
>>> Cool.
>>> I am running it now to the point all this happens and will start the SQL
>>> monitor.
>>>
>>> Any special switches I might consider?
>>>
>>> I am saving it to a log file so maybe we can review the output.
>>>
>>> BTW, tried to simply delete that specific record and the program just
>>> went on to the next record and got the same error. The first 5 records
>>> have no error.
>>>
>>> Chuck
>>>> Chuck,
>>>>
>>>> Yes, I am.
>>>>
>>>> Yes, it does.
>>>>
>>>> Jason
>>>>
>>>> -----Original Message-----
>>>> From:IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] On
>>> Behalf
>>>> Of Chuck Belanger
>>>> Sent: 04 December 2012 12:55 PM
>>>> To:IBObjects@yahoogroups.com
>>>> Subject: Re: [IBO] Real Stumper of an error, Please help.
>>>>
>>>> Are you talking about the SQL Monitor that we added to the project?
>>>>
>>>> Does this work in a Dataset.Edit; Field.Value := Field.Value; then POST
>>>> situation?
>>>>
>>>> Like I said, I actually traced this code and looped through all the
>>>> fields that were being edited for that record. There is no single edit,
>>>> but a series depending on whether the field in question is part of a
>>>> list of field names that should be updated for the table. Nothing out of
>>>> the ordinary. The code is old and full of fairly complex logic that I do
>>>> not want to rewrite at this point to use an UPDATE statement.
>>>>
>>>> Chuck
>>>>> Did you look at the IBO generated SQL trace?
>>>>> This should tell you exactly what statement was being executed and with
>>>> what
>>>>> exact values being sent to the server.
>>>>>
>>>>> Jason
>>>>>
>>>>> -----Original Message-----
>>>>> From:IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] On
>>>> Behalf
>>>>> Of Chuck Belanger
>>>>> Sent: 04 December 2012 11:55 AM
>>>>> To: IBObjects Listserve
>>>>> Subject: [IBO] Real Stumper of an error, Please help.
>>>>>
>>>>> Hello:
>>>>>
>>>>> Using Delphi XE2, Win7-64, IBO 5.2 (latest update from Jason)
>>>>>
>>>>> I am using two IB_Queries to move data between two identical tables from
>>>>> two DBs. It is a part of an DB update routine which updates/adds new
>>>>> data from a master DB that is distributed to numerous users. It is a
>>>>> desktop application used in clinics. Not all clinics are hooked up to
>>>>> the internet, so forget the idea of using an internet based solution :)
>>>>> Plus, the patient data HIPPA issues.
>>>>>
>>>>> I am getting the following error:
>>>>> "Violation of PK pk_cv_table_columns on table CV_Table_Columns"
>>>>>
>>>>> Here's the stumper:
>>>>>
>>>>> This is on a post of a series of individual field edits. No Append, no
>>>>> insert.
>>>>> The fields actually edited do not include the PK, CV_Column_ID.
>>>>> The process works fine on other records of the same exact structure
>>>>> included in the dataset and in many cases the same exact data (because
>>>>> the data can be repetitive).
>>>>> I have looked at the data in a trace and in IBExpert browser. Nothing
>>>>> looks amiss.
>>>>> In fact, the edit update, is not actually changing any data for this
>>>>> specific record, i.e. the field data is identical for both tables being
>>>>> pumped/updated. I have looked at the field values during a trace.
>>>>> This error comes up for this exact same record being edited across more
>>>>> than one DB.
>>>>>
>>>>> This is part of a very large routine to update users' DB and is stopping
>>>>> the entire process from finishing.
>>>>>
>>>>> I would appreciate any help or direction on what to look at.
>>>>>
>>>>> Thank you!
>>>>> Chuck Belanger
>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------
>>>>>
>>>>>
>> ___________________________________________________________________________
>>>>> IB Objects - direct, complete, custom connectivity to Firebird or
>>>> InterBase
>>>>> without the need for BDE, ODBC or any other layer.
>>>>>
>> ___________________________________________________________________________
>>>>> http://www.ibobjects.com - your IBO community resource for Tech Info
>>>> papers,
>>>>> keyword-searchable FAQ, community code contributions and more !
>>>> Yahoo! Groups Links
>>>> ------------------------------------
>>>>
>>>>
>> ___________________________________________________________________________
>>>> IB Objects - direct, complete, custom connectivity to Firebird or
>>> InterBase
>>>> without the need for BDE, ODBC or any other layer.
>>>>
>> ___________________________________________________________________________
>>>> http://www.ibobjects.com - your IBO community resource for Tech Info
>>> papers,
>>>> keyword-searchable FAQ, community code contributions and more !
>>>> Yahoo! Groups Links
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ------------------------------------
>>>>
>>>>
>> ___________________________________________________________________________
>>>> IB Objects - direct, complete, custom connectivity to Firebird or
>>> InterBase
>>>> without the need for BDE, ODBC or any other layer.
>>>>
>> ___________________________________________________________________________
>>>> http://www.ibobjects.com - your IBO community resource for Tech Info
>>> papers,
>>>> keyword-searchable FAQ, community code contributions and more !
>>> Yahoo! Groups Links
>>> ------------------------------------
>>>
>>>
>> ___________________________________________________________________________
>>> IB Objects - direct, complete, custom connectivity to Firebird or
>> InterBase
>>> without the need for BDE, ODBC or any other layer.
>>>
>> ___________________________________________________________________________
>>> http://www.ibobjects.com - your IBO community resource for Tech Info
>> papers,
>>> keyword-searchable FAQ, community code contributions and more !
>>> Yahoo! Groups Links
>>>
>>>
>>>
>>>
>>>
>>> ------------------------------------
>>>
>>>
>> ___________________________________________________________________________
>>> IB Objects - direct, complete, custom connectivity to Firebird or
>> InterBase
>>> without the need for BDE, ODBC or any other layer.
>>>
>> ___________________________________________________________________________
>>> http://www.ibobjects.com - your IBO community resource for Tech Info
>> papers,
>>> keyword-searchable FAQ, community code contributions and more !
>> Yahoo! Groups Links
>>>
>> ------------------------------------
>>
>> ___________________________________________________________________________
>> IB Objects - direct, complete, custom connectivity to Firebird or InterBase
>> without the need for BDE, ODBC or any other layer.
>> ___________________________________________________________________________
>> http://www.ibobjects.com - your IBO community resource for Tech Info papers,
>> keyword-searchable FAQ, community code contributions and more !
>> Yahoo! Groups Links
>>
>>
>>
>>
>>
>> ------------------------------------
>>
>> ___________________________________________________________________________
>> IB Objects - direct, complete, custom connectivity to Firebird or InterBase
>> without the need for BDE, ODBC or any other layer.
>> ___________________________________________________________________________
>> http://www.ibobjects.com - your IBO community resource for Tech Info papers,
>> keyword-searchable FAQ, community code contributions and more ! Yahoo! Groups Links
>>
>>
>>
>>
>
> ------------------------------------
>
> ___________________________________________________________________________
> IB Objects - direct, complete, custom connectivity to Firebird or InterBase
> without the need for BDE, ODBC or any other layer.
> ___________________________________________________________________________
> http://www.ibobjects.com - your IBO community resource for Tech Info papers,
> keyword-searchable FAQ, community code contributions and more ! Yahoo! Groups Links
>
>
>
>