Discussion:
dBASE - Set Relation To - Calculated Field - Set Key To
(too old to reply)
Carlos A. Pereira [APKomp]
2008-11-20 22:30:34 UTC
Permalink
The "Set Relation To" does not work (?)
under a "Calculated Field" and under a "Set Key To"
(in dBASE Plus) (not in Visual dBASE 5.7)

Thanks for your attention, in advance

Carlos A. Pereira
APKomp

********************************************************************************
* Example code
****************
***
* condition to filter && line 01
ynumerecibo=12050 && line 02
*** && line 03
* open table1 && line 04
SELECT 1 && line 05
USE table1 ORDER numerecibo ALIAS table1 && line 06
SET FIELDS TO table1->numerecibo && line 07
* open table2 && line 08
SELECT 2 && line 09
USE table2 ORDER numerecibo ALIAS table2 && line 10
SET FIELDS TO table2->denoentida && line 11
SET FIELDS TO datadocume=table2->datarecibo && line 12 (enable/disable "Calculated Field")
*** && line 13
* set key to (filter) // && table1 order: STR(numerecibo,10,0) && line 14
SELECT table1 && 1 && line 15
SET KEY TO STR(ynumerecibo,10,0) && line 16 (disable/enable "Set Key To")
GOTO TOP && line 17
*** && line 18
* set relation to // && table2 order: STR(numerecibo,10,0) && line 19
SELECT table1 && 1 && line 20
SET RELATION TO STR(table1->numerecibo,10,0) INTO table2 ADDITIVE && line 21
GOTO TOP && line 22
*** && line 23
COPY TO table3 ALL && line 24
*** && line 25
SELECT 1 && table1 && line 26
SET RELATION TO && line 27
SET KEY TO && line 28
CLOSE TABLES && line 29
********************************************************************************
* Test Code
****************
*
* IF - enabled line 12: SET FIELDS TO datadocume=table2->datarecibo
* - enabled line 16: SET KEY TO STR(ynumerecibo,10,0))
* RESUL: NOT OK (set relation NOT OK)
*
* IF - enabled line 12: SET FIELDS TO datadocume=table2->datarecibo
* - disabled line 16: *SET KEY TO STR(ynumerecibo,10,0))
* RESUL: OK (set relation OK)
*
* IF - disabled line 12: *SET FIELDS TO datadocume=table2->datarecibo
* - enabled line 16: SET KEY TO STR(ynumerecibo,10,0))
* RESUL: OK (set relation OK)
*
********************************************************************************
* View Test Code
****************
USE table3
BROWSE
*USE
********************************************************************************
Marty Kay
2008-11-21 19:07:42 UTC
Permalink
Hi Carlos,

You neglected to specify the index order on table2.
The child table in a set relation must have an active index specified either
via
SET INDEX TO someindex (for an .NDX index)

or

SET ORDER TO someIndexTag (for an .MDX index)

- Marty -

Martin Kay
dataBased Intelligence, Inc.


"Carlos A. Pereira [APKomp]" <***@apkomp.pt> wrote in message news:***@news-server...
The "Set Relation To" does not work (?)
under a "Calculated Field" and under a "Set Key To"
(in dBASE Plus) (not in Visual dBASE 5.7)

Thanks for your attention, in advance

Carlos A. Pereira
APKomp

********************************************************************************
* Example code
****************
***
* condition to filter &&
line 01
ynumerecibo=12050 &&
line 02
*** &&
line 03
* open table1 &&
line 04
SELECT 1 &&
line 05
USE table1 ORDER numerecibo ALIAS table1 &&
line 06
SET FIELDS TO table1->numerecibo &&
line 07
* open table2 &&
line 08
SELECT 2 &&
line 09
USE table2 ORDER numerecibo ALIAS table2 &&
line 10
SET FIELDS TO table2->denoentida &&
line 11
SET FIELDS TO datadocume=table2->datarecibo &&
line 12 (enable/disable "Calculated Field")
*** &&
line 13
* set key to (filter) // && table1 order: STR(numerecibo,10,0) &&
line 14
SELECT table1 && 1 &&
line 15
SET KEY TO STR(ynumerecibo,10,0) &&
line 16 (disable/enable "Set Key To")
GOTO TOP &&
line 17
*** &&
line 18
* set relation to // && table2 order: STR(numerecibo,10,0) &&
line 19
SELECT table1 && 1 &&
line 20
SET RELATION TO STR(table1->numerecibo,10,0) INTO table2 ADDITIVE &&
line 21
GOTO TOP &&
line 22
*** &&
line 23
COPY TO table3 ALL &&
line 24
*** &&
line 25
SELECT 1 && table1 &&
line 26
SET RELATION TO &&
line 27
SET KEY TO &&
line 28
CLOSE TABLES &&
line 29
********************************************************************************
* Test Code
****************
*
* IF - enabled line 12: SET FIELDS TO datadocume=table2->datarecibo
* - enabled line 16: SET KEY TO STR(ynumerecibo,10,0))
* RESUL: NOT OK (set relation NOT OK)
*
* IF - enabled line 12: SET FIELDS TO datadocume=table2->datarecibo
* - disabled line 16: *SET KEY TO STR(ynumerecibo,10,0))
* RESUL: OK (set relation OK)
*
* IF - disabled line 12: *SET FIELDS TO datadocume=table2->datarecibo
* - enabled line 16: SET KEY TO STR(ynumerecibo,10,0))
* RESUL: OK (set relation OK)
*
********************************************************************************
* View Test Code
****************
USE table3
BROWSE
*USE
********************************************************************************
Bruce Beacham
2008-11-24 10:27:42 UTC
Permalink
Post by Marty Kay
You neglected to specify the index order on table2.
SET ORDER TO someIndexTag (for an .MDX index)
Er, I see he issued this in area 2...

USE table2 ORDER numerecibo ALIAS table2

- and I can't see that he overrode it.


I suspect the problem lies with the SET FIELDS command. He does this:
SET FIELDS TO table1->numerecibo
SELECT 2
USE table2 ORDER numerecibo ALIAS table2
SET FIELDS TO table2->denoentida
SET FIELDS TO datadocume=table2->datarecibo

As I understand it, only the last statement has any effect (whatever it
means, with that "=" in the expression), and it overrides the SET FIELDS
in area 1. I can't predict what the outcome would be as I don't know
the field structure.

Moreover it's an interesting power of PLUS if he can have the table
ordered on a field that is not in the fields list!


Bruce Beacham
Marty Kay
2008-11-24 16:40:48 UTC
Permalink
Hi Bruce,

You're correct - somehow I overlooked the ORDER clauses.


I'll have to look more closely at his code to figure it out...

Thanks,

- Marty -

Martin Kay
dataBased Intelligence, Inc.
Carlos A. Pereira [APKomp]
2008-12-02 00:17:41 UTC
Permalink
Dear Martin Kay, and,
Dear Bruce Beacham

Thank you for your concern.
Excuse me I had not indicate that tables and code were attached.
Excuse me I would not have answered you.

And, please, do not forget:
- This is a bug (perhaps more a "old bequest" of Visual dBASE 7);
- This code runs perfectly in Visual dBASE 5.7.

This issue came up during our conversion from Visual dBase 5.7 for dBase Plus 2.61.5,
where we continue to use substantially XDML in the manipulation of data,
rather than the "started" OODML (even with / despite some problems
(in class browse pictures, data memory violation, ...)).
Functions created type
AppendRowIn(<Form(variable)>,<Browse or Grid object name>,<cMIFields>,<countYN>),
has allowed us to circumvent all the problems during the conversion to version dBase Plus 2.61.5
(which is actually the best of all: XDML Sessions (CREATE SESSION ...) work very well,
stability is very large, and transpires in the code the standardization of criteria.

We are very excited, and hope deeply that the new version comes out calmly and with foundation,
without walking behind, and,
without us having "to repeat" development work (with repeated costs).

Once again, thanks for everything to the whole dBASE Team.

Carlos A. Pereira
APKomp

Marty Kay
2008-11-21 19:10:42 UTC
Permalink
In addition, SET KEY also requires that an index already be active.

- Marty -

Martin Kay
dataBased Intelligence, Inc.


"Carlos A. Pereira [APKomp]" <***@apkomp.pt> wrote in message news:***@news-server...
The "Set Relation To" does not work (?)
under a "Calculated Field" and under a "Set Key To"
(in dBASE Plus) (not in Visual dBASE 5.7)

Thanks for your attention, in advance

Carlos A. Pereira
APKomp

********************************************************************************
* Example code
****************
***
* condition to filter &&
line 01
ynumerecibo=12050 &&
line 02
*** &&
line 03
* open table1 &&
line 04
SELECT 1 &&
line 05
USE table1 ORDER numerecibo ALIAS table1 &&
line 06
SET FIELDS TO table1->numerecibo &&
line 07
* open table2 &&
line 08
SELECT 2 &&
line 09
USE table2 ORDER numerecibo ALIAS table2 &&
line 10
SET FIELDS TO table2->denoentida &&
line 11
SET FIELDS TO datadocume=table2->datarecibo &&
line 12 (enable/disable "Calculated Field")
*** &&
line 13
* set key to (filter) // && table1 order: STR(numerecibo,10,0) &&
line 14
SELECT table1 && 1 &&
line 15
SET KEY TO STR(ynumerecibo,10,0) &&
line 16 (disable/enable "Set Key To")
GOTO TOP &&
line 17
*** &&
line 18
* set relation to // && table2 order: STR(numerecibo,10,0) &&
line 19
SELECT table1 && 1 &&
line 20
SET RELATION TO STR(table1->numerecibo,10,0) INTO table2 ADDITIVE &&
line 21
GOTO TOP &&
line 22
*** &&
line 23
COPY TO table3 ALL &&
line 24
*** &&
line 25
SELECT 1 && table1 &&
line 26
SET RELATION TO &&
line 27
SET KEY TO &&
line 28
CLOSE TABLES &&
line 29
********************************************************************************
* Test Code
****************
*
* IF - enabled line 12: SET FIELDS TO datadocume=table2->datarecibo
* - enabled line 16: SET KEY TO STR(ynumerecibo,10,0))
* RESUL: NOT OK (set relation NOT OK)
*
* IF - enabled line 12: SET FIELDS TO datadocume=table2->datarecibo
* - disabled line 16: *SET KEY TO STR(ynumerecibo,10,0))
* RESUL: OK (set relation OK)
*
* IF - disabled line 12: *SET FIELDS TO datadocume=table2->datarecibo
* - enabled line 16: SET KEY TO STR(ynumerecibo,10,0))
* RESUL: OK (set relation OK)
*
********************************************************************************
* View Test Code
****************
USE table3
BROWSE
*USE
********************************************************************************
Bruce Beacham
2008-11-24 11:08:20 UTC
Permalink
Post by Carlos A. Pereira [APKomp]
SELECT 2
USE table2 ORDER numerecibo ALIAS table2 &&
What is the expression behind the index tag "numerecibo"?
Post by Carlos A. Pereira [APKomp]
SET RELATION TO STR(table1->numerecibo,10,0) INTO table2 ADDITIVE &&
Bruce Beacham
Loading...