Re: ORDA question: how do I add related fields to an entity selection?

2018-08-01 Thread Chip Scheide via 4D_Tech
Tim,
I have been creating a LOT of custom constants recently (removing IP 
vars used as constants)
[sidebar - I am down to < 40 ipvars from over 550]

Yes, it is a minor PITA to have to restart, but if you 'watch' the 
loading process 4D loads the custom constants BEFORE running almost 
everything - including the native login screen.

I have seen this, as I have been screwing around with a custom constant 
the xml did not like and during the load of the xlif file 4D would 
choke and throw an error -- before the login screen.

so.. I understand why custom constants are this way...

Chip

On Wed, 01 Aug 2018 14:20:23 -0500, Tim Nevels via 4D_Tech wrote:
> On Aug 1, 2018, at 9:49 AM, Jeremy French wrote:
> 
>> Try creating 2-tables with a one-to-many relation. Say "Owner" (one 
>> table) and "Item" (many table.)
>> In the Relation Inspector, name the relations:
>> 
>> Many to one as "theOwner"
>> One to many as "theItems"
>> 
>> Don't forget to restart 4D before examining in the Debugger. With 
>> ORDA, any structure change requires restarting 4D to be recognized.
> 
> They really need to fix that. 
> 
> Reminds me of how custom constants work. Such a PITA to have to 
> restart to be able to use a newly created constant. So much a PITA 
> that I’ve avoided custom constants because of it. And thus far 4D has 
> never addressed that. 
> 
> Hope they treat ORDA differently than they have done with custom constants. 
> 
> Tim
> 
> *
> Tim Nevels
> Innovative Solutions
> 785-749-3444
> timnev...@mac.com
> *
> 
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: ORDA question: how do I add related fields to an entity selection?

2018-08-01 Thread Tim Nevels via 4D_Tech
On Aug 1, 2018, at 9:49 AM, Jeremy French wrote:

> Try creating 2-tables with a one-to-many relation. Say "Owner" (one table) 
> and "Item" (many table.)
> In the Relation Inspector, name the relations:
> 
> Many to one as "theOwner"
> One to many as "theItems"
> 
> Don't forget to restart 4D before examining in the Debugger. With ORDA, any 
> structure change requires restarting 4D to be recognized.

They really need to fix that. 

Reminds me of how custom constants work. Such a PITA to have to restart to be 
able to use a newly created constant. So much a PITA that I’ve avoided custom 
constants because of it. And thus far 4D has never addressed that. 

Hope they treat ORDA differently than they have done with custom constants. 

Tim

*
Tim Nevels
Innovative Solutions
785-749-3444
timnev...@mac.com
*

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: ORDA question: how do I add related fields to an entity selection?

2018-07-31 Thread Jeremy French via 4D_Tech
Hi Julio,

Have you looked at:
http://doc.4d.com/4Dv17/4D/17/dataClassAttributerelatedDataClass.303-3884018.en.html

Relation attributes have 3-properties:
1) kind
2) name
3) relatedDataClass

The "kind" property tells you the type of relation: one or many.
The "name" property is the name you assign in the 4D Relation Inspector.
The "relatedDataClass" identifies the name of the related table.

Try creating 2-tables with a one-to-many relation. Say "Owner" (one table) and 
"Item" (many table.)
In the Relation Inspector, name the relations:

Many to one as "theOwner"
One to many as "theItems"

Don't forget to restart 4D before examining in the Debugger. With ORDA, any 
structure change requires restarting 4D to be recognized.

In the debugger's expression pane, examine the DataClass for each table.

ds.Owner
ds.Item

The relation attributes will look something like this:

ds.Item.theOwner shows this value:
{name:theOwner,kind:relatedEntity,relatedDataClass:Owner}

ds.Owner.theItems shows this value:
{name:theItems,kind:relatedEntities,relatedDataClass:Item}

Note the relation type (relatedEntity OR relatedEntities) is identified along 
with the name of the related table (Owner OR Item).

Does this info help?

- Jeremy


> On Jul 31, 2018, at 4:10 AM, Julio Carneiro via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
> …that only tells me I have a relation attribute and that relation’s name. It 
> does not tell me if it is a relations between A and B, or A and C.
> Is there a way to get that?

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: ORDA question: how do I add related fields to an entity selection?

2018-07-31 Thread Keisuke Miyako via 4D_Tech
I suppose it could be "nice" to have such a feature,
indeed there were hints on the forums that it is in the pipeline,
but I think it is important to stop and consider why the feature is not 
available at this point in time.

code is never tokenised in ORDA.
as developers, we should embrace it, not fight it.

suppose you have some code like:

Table_1.someRelatedTable_2.someAttribute

you can refactor someRelatedTable_2 (using a different table, switching from 
local to remote, persistent database to variable, etc.) without changing any 
code.

ORDA is supposed to serve as an abstraction layer.

it goes against the paradigm to have code that depends on the implementation of 
"someRelatedTable_2".

2018/07/31 17:10、Julio Carneiro via 4D_Tech 
<4d_tech@lists.4d.com>のメール:
Is there a way to get that?


**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: ORDA question: how do I add related fields to an entity selection?

2018-07-31 Thread Julio Carneiro via 4D_Tech
Interesting Miyako, but that only tells me I have a relation attribute and that 
relation’s name. It does not tell me if it is a relations between A and B, or A 
and C.
Is there a way to get that?

And there is one key member function missing that tells me to which Table an 
Entity or Entity Selection belongs to.

cheers,
julio

> On Jul 31, 2018, at 3:17 AM, Keisuke Miyako via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
> or, DA.
> 
> C_COLLECTION($one;$many)
> 
> $one:=New collection
> $many:=New collection
> 
> For each ($attribute;ds.Table_1)
> 
> $kind:=ds.Table_1[$attribute].kind
> 
> Case of
> : ($kind="storage")
> 
> 
> : ($kind="relatedEntity")
> $one.push($attribute)
> 
> : ($kind="relatedEntities")
> $many.push($attribute)
> 
> End case
> 
> End for each
> 
> http://doc.4d.com/4Dv17/4D/17/dataClassAttributekind.303-3777559.en.html
> 
>> 2018/07/31 6:07、Julio Carneiro via 4D_Tech <4d_tech@lists.4d.com>のメール:
>> As a thank you for the tip, here is some code to get a Relation name, given 
>> 2 related tables…
> 
> 
> 
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

--
Julio Carneiro
jjfo...@gmail.com



**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: ORDA question: how do I add related fields to an entity selection?

2018-07-30 Thread Keisuke Miyako via 4D_Tech
or, DA.

C_COLLECTION($one;$many)

$one:=New collection
$many:=New collection

For each ($attribute;ds.Table_1)

$kind:=ds.Table_1[$attribute].kind

Case of
: ($kind="storage")


: ($kind="relatedEntity")
$one.push($attribute)

: ($kind="relatedEntities")
$many.push($attribute)

End case

End for each

http://doc.4d.com/4Dv17/4D/17/dataClassAttributekind.303-3777559.en.html

> 2018/07/31 6:07、Julio Carneiro via 4D_Tech <4d_tech@lists.4d.com>のメール:
> As a thank you for the tip, here is some code to get a Relation name, given 2 
> related tables…



**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: ORDA question: how do I add related fields to an entity selection?

2018-07-30 Thread Julio Carneiro via 4D_Tech
Thanks Lahav, that works.

I’m using an Entity Selection to display on a Listbox and I needed to include 
some related field columns.
Using relation names did the trick.

This is all generic code written a long time ago and I’m upgrading it to 
V17+ORDA.

As a thank you for the tip, here is some code to get a Relation name, given 2 
related tables…
> C_TEXT($0)
> C_LONGINT($1;$tableNo;$2;$relatedTableNo)
> 
>   //--- copy parameters to locals
> $tableNo:=$1
> $relatedTableNo:=$2
> 
>   //--- locals
> 
>   //--- code
> ARRAY TEXT($aConstraint;0)
> Begin SQL
>   select CONSTRAINT_NAME
>   from _USER_CONSTRAINTS
>   where CONSTRAINT_TYPE = '4DR' and TABLE_ID = :$tableNo and 
> RELATED_TABLE_ID = :$relatedTableNo
>   into :$aConstraint
> End SQL
> If (Size of array($aConstraint)=1)
>   $0:=$aConstraint{1}
> Else 
>   $0:=""
> End if 


> On Jul 30, 2018, at 7:01 PM, lists via 4D_Tech <4d_tech@lists.4d.com> wrote:
> 
> Hi Julio,
> 
> You need to name your relations, which then shows up as an entity in your 
> collection, containing the related data.
> 
> Assuming a table named A and a relation to table B named My_B_Link, after 
> loading a selection of table A into collection My_Col, you can get your 
> related data from table B like this:
> 
> My_Col.My_B_Link.AnyFieldYouLike
> 
> Regards,
> 
> Lahav
> 
> -Original Message-
> From: 4D_Tech <4d_tech-boun...@lists.4d.com> On Behalf Of Julio Carneiro via 
> 4D_Tech
> Sent: Monday, July 30, 2018 10:18 AM
> To: 4D iNug Technical <4d_tech@lists.4d.com>
> Cc: Julio Carneiro 
> Subject: ORDA question: how do I add related fields to an entity selection?
> 
> Let’s say I have 2 tables in my database, MANY and ONE, where MANY has a many 
> to one relation to ONE.
> 
> Using a MANY based SELECTION TO ARRAY I can populate arrays with fields from 
> the MANY table, of course, but I can also include fields from the ONE table. 
> If automatic relations is set to true 4D will resolve the relations 
> automatically and populate the arrays accordingly. Works great and I’ve used 
> it a LOT :-)
> 
> Now, using ORDA, how can I get related fields into an Entity Selection? is 
> that possible? looking at the docs I could not find a way to do that. Except 
> by manually going thru the selection and manually resolving the relation and 
> populating the fields needed.
> 
> Maybe that is one of those cases where it is better to stick with the “old 
> way” and use Arrays.
> 
> --
> Julio Carneiro
> jjfo...@gmail.com
> 
> 
> 
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

--
Julio Carneiro
jjfo...@gmail.com



**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

RE: ORDA question: how do I add related fields to an entity selection?

2018-07-30 Thread lists via 4D_Tech
Hi Julio,

You need to name your relations, which then shows up as an entity in your 
collection, containing the related data.

Assuming a table named A and a relation to table B named My_B_Link, after 
loading a selection of table A into collection My_Col, you can get your related 
data from table B like this:

My_Col.My_B_Link.AnyFieldYouLike

Regards,

Lahav

-Original Message-
From: 4D_Tech <4d_tech-boun...@lists.4d.com> On Behalf Of Julio Carneiro via 
4D_Tech
Sent: Monday, July 30, 2018 10:18 AM
To: 4D iNug Technical <4d_tech@lists.4d.com>
Cc: Julio Carneiro 
Subject: ORDA question: how do I add related fields to an entity selection?

Let’s say I have 2 tables in my database, MANY and ONE, where MANY has a many 
to one relation to ONE.

Using a MANY based SELECTION TO ARRAY I can populate arrays with fields from 
the MANY table, of course, but I can also include fields from the ONE table. If 
automatic relations is set to true 4D will resolve the relations automatically 
and populate the arrays accordingly. Works great and I’ve used it a LOT :-)

Now, using ORDA, how can I get related fields into an Entity Selection? is that 
possible? looking at the docs I could not find a way to do that. Except by 
manually going thru the selection and manually resolving the relation and 
populating the fields needed.

Maybe that is one of those cases where it is better to stick with the “old way” 
and use Arrays.

--
Julio Carneiro
jjfo...@gmail.com



**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

ORDA question: how do I add related fields to an entity selection?

2018-07-30 Thread Julio Carneiro via 4D_Tech
Let’s say I have 2 tables in my database, MANY and ONE, where MANY has a many 
to one relation to ONE.

Using a MANY based SELECTION TO ARRAY I can populate arrays with fields from 
the MANY table, of course, but I can also include fields from the ONE table. If 
automatic relations is set to true 4D will resolve the relations automatically 
and populate the arrays accordingly. Works great and I’ve used it a LOT :-)

Now, using ORDA, how can I get related fields into an Entity Selection? is that 
possible? looking at the docs I could not find a way to do that. Except by 
manually going thru the selection and manually resolving the relation and 
populating the fields needed.

Maybe that is one of those cases where it is better to stick with the “old way” 
and use Arrays.

--
Julio Carneiro
jjfo...@gmail.com



**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**