Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread date encode error on new record
Mon, Aug 21 2006 3:47 PMPermanent Link

Jerry Blumenthal
One of my clients reports a "date encode error" every time he tries to
add a new record to a master table.  He sent me his data and I discover
that if I eliminate the master-detail relationship, then no error occurs.

Why?
And how do I fix it?

When I add a new master record, I am not adding a new detail record, so
I dont know why the detail table is producing the error.  And I cant
manipulate the onNewRecord stuff in the detail record, because there is
no detail record.

Any suggestions helpful.   (dbisam 2.12, D4)

(maybe I should eliminate the master detail relationship until the
master table is saved and then reinstate it?  sounds awfully complicated
and messy.)


Jerry
Mon, Aug 21 2006 4:29 PMPermanent Link

Jerry Blumenthal
I expanded the code for the master's navigator plus sign, and added the
following:

detail.active := false;
master.insert;
detail.active := true;

And that seems to avoid the problem.  But I really dont understand what
is going on, and why it is that only this one guy is having a problem.

Jerry
Tue, Aug 22 2006 1:09 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Jerry,

<< One of my clients reports a "date encode error" every time he tries to
add a new record to a master table.  He sent me his data and I discover that
if I eliminate the master-detail relationship, then no error occurs. >>

It sounds like there's an issue with a blank or zero date in the master
record when it comes to setting the detail range.  It's probably a bug in
2.x when handling zero dates, and the workaround is to either set a default
value for the master date field or to set/reset the master detail link as
necessary.

BTW, the master-detail linkage *is* on a date field, correct ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Aug 22 2006 1:30 PMPermanent Link

Jerry Blumenthal
Tim Young [Elevate Software] wrote:
> Jerry,
>
> << One of my clients reports a "date encode error" every time he tries to
> add a new record to a master table.  He sent me his data and I discover that
> if I eliminate the master-detail relationship, then no error occurs. >>
>
> It sounds like there's an issue with a blank or zero date in the master
> record when it comes to setting the detail range.  It's probably a bug in
> 2.x when handling zero dates, and the workaround is to either set a default
> value for the master date field or to set/reset the master detail link as
> necessary.
>
> BTW, the master-detail linkage *is* on a date field, correct ?
>


No, the master-detail link is on an integer.

And when I tried to set all of the DATE fields in the master record to
today's date, nothing changed.  I did this in the OnNewRecord event, and
the problem always occurred after that event was done.

The detail record also has a date field, but I dont know why that should
matter.  Maybe I should restructure that field to always have a default?

If the solution I did find, to set the detail table as inactive, then
insert the record in the master, and then set the detail table as
active---  if that works out ok, and I dont see why it should not, then
I should be okay with this.  I just wondered....

Jerry (grateful as always to you and to the forum members)
Tue, Aug 22 2006 9:05 PMPermanent Link

"Jerry Clancy"
Jerry

If normally your intent is to add at least one detail record for a new
master, try creating the detail record first with the necessary key/linkage
fields followed by the master. A couple of other thoughts:

* Could an index be using an uninitialized field (particularly a date), per
Tim's comment?
* Are you using any calc fields likewise using null fields or perhaps
referencing detail fields?

Jerry C.

"Jerry Blumenthal" <jerry@blumenthalsoftware.com> wrote in message
news:CAB4E0B2-9416-4BCD-B1F3-AB239452D31A@news.elevatesoft.com...
| Tim Young [Elevate Software] wrote:
| > It sounds like there's an issue with a blank or zero date in the master
| > record when it comes to setting the detail range.  It's probably a bug
in
| > 2.x when handling zero dates, and the workaround is to either set a
default
| > value for the master date field or to set/reset the master detail link
as
| > necessary.
| >
| > BTW, the master-detail linkage *is* on a date field, correct ?
| >


| No, the master-detail link is on an integer.
|
| And when I tried to set all of the DATE fields in the master record to
| today's date, nothing changed.  I did this in the OnNewRecord event, and
| the problem always occurred after that event was done.
|
| The detail record also has a date field, but I dont know why that should
| matter.  Maybe I should restructure that field to always have a default?
|
| If the solution I did find, to set the detail table as inactive, then
| insert the record in the master, and then set the detail table as
| active---  if that works out ok, and I dont see why it should not, then
| I should be okay with this.  I just wondered....
|
| Jerry (grateful as always to you and to the forum members)
|

Tue, Aug 22 2006 10:34 PMPermanent Link

Jerry Blumenthal
1. A detail record should not be added for a new master in this
situation.  I suppose I could phony up a reason for adding a detail
record, but there really is no reason to do so in the real world.

2. The detail table does have a secondary index based on a date field.
But I just dont understand why that should matter.

3. No calc fields using null fields etc.  I put a line into the OnCalc
events:  if masterTAble.state = dsInsert then exit;

Maybe it is that secondary index.  The fact that the problem goes away
when I close the detail table certainly is suggestive.

Jerry




Jerry Clancy wrote:
> Jerry
>
> If normally your intent is to add at least one detail record for a new
> master, try creating the detail record first with the necessary key/linkage
> fields followed by the master. A couple of other thoughts:
>
> * Could an index be using an uninitialized field (particularly a date), per
> Tim's comment?
> * Are you using any calc fields likewise using null fields or perhaps
> referencing detail fields?
>
> Jerry C.
>
> "Jerry Blumenthal" <jerry@blumenthalsoftware.com> wrote in message
> news:CAB4E0B2-9416-4BCD-B1F3-AB239452D31A@news.elevatesoft.com...
> | Tim Young [Elevate Software] wrote:
> | > It sounds like there's an issue with a blank or zero date in the master
> | > record when it comes to setting the detail range.  It's probably a bug
> in
> | > 2.x when handling zero dates, and the workaround is to either set a
> default
> | > value for the master date field or to set/reset the master detail link
> as
> | > necessary.
> | >
> | > BTW, the master-detail linkage *is* on a date field, correct ?
> | >
>
>
> | No, the master-detail link is on an integer.
> |
> | And when I tried to set all of the DATE fields in the master record to
> | today's date, nothing changed.  I did this in the OnNewRecord event, and
> | the problem always occurred after that event was done.
> |
> | The detail record also has a date field, but I dont know why that should
> | matter.  Maybe I should restructure that field to always have a default?
> |
> | If the solution I did find, to set the detail table as inactive, then
> | insert the record in the master, and then set the detail table as
> | active---  if that works out ok, and I dont see why it should not, then
> | I should be okay with this.  I just wondered....
> |
> | Jerry (grateful as always to you and to the forum members)
> |
>
>
Wed, Aug 23 2006 3:37 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Jerry,

<< Maybe it is that secondary index.  The fact that the problem goes away
when I close the detail table certainly is suggestive. >>

Is it possible that you're trying to establish a master-detail link with the
date index active on the detail table instead of the desired integer-based
index ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Aug 23 2006 7:16 PMPermanent Link

Jerry Blumenthal
Tim Young [Elevate Software] wrote:
> Jerry,
>
> << Maybe it is that secondary index.  The fact that the problem goes away
> when I close the detail table certainly is suggestive. >>
>
> Is it possible that you're trying to establish a master-detail link with the
> date index active on the detail table instead of the desired integer-based
> index ?
>


No, I dont think so.

That detail table is actually never used with the date index.  When I
need to look at the records in date order, I use a different
dbisamtable, not the one linked to the master table.

At this point, does it matter?  Setting Detail closed and then
re-opening it after the Master.Insert has worked around the problem
effectively.

One interesting issue:  Looking at the MASTER table with DbSys, I find
that there are 7 records which are filled with garbage, some of which
have no account numbers, which are the integers which are used to link
to the detail table.  I plan to delete those records as soon as I can
arrange a phone conference with my customer.

Jerry
Image