Binary Link onDelete

Bart Pietercil bart.pietercil at gmail.com
Wed May 2 11:07:49 CDT 2007


Hi Ruslan,

I thought instead of all those pesky licensing questions a good old  
API question would be refreshing :-)


On 2-mei-07, at 17:39, Ruslan Zasukhin wrote:

> On 2/5/07 6:05 PM, "Bart Pietercil" <bart.pietercil at gmail.com> wrote:
>
> Hi Bart,
>
>> this statement generates an Vexception
>>
>>      aBinaryLink = CreateBinaryLink
>> ("mm_compcard_functprofile_to_my_competences",Table
>> ("mm_compcard_functprofile"),Table
>> ("my_competences"),EVLinkType.kMany,EVLinkType.kMany,EVOnDelete.kCasc 
>> ade
>> ,EVStorageType.kDisk)
>>
>> while this one is OK
>>
>>      aBinaryLink = CreateBinaryLink
>> ("mm_compcard_functprofile_to_my_competences",Table
>> ("mm_compcard_functprofile"),Table
>> ("my_competences"),EVLinkType.kMany,EVLinkType.kMany,EVOnDelete.kDefa 
>> ult
>> ,EVStorageType.kDisk)
>>
>>
>> The difference is the EVOnDelete.kDefault is accepted, kCascade is  
>> not.
>>
>> Why ?
>
> May be your BinaryLink is of 1:1 or M:M kind ?
>
> In this case you need specify explicitly which table is OWNER/Parent.
>
>> And what does kDefault mean in a many to many link ?
>
> Aha, so you have Many to Many link.
> Then you need specify OWNER-table.
>

As you can see I am using the API way. In the kernel or V2RB pdf's  
under VBinary class there is no mention of "Owner" table in the  
create statement, although there is in the explanation



VBinaryLink(
  inName as String,
  inLeftTable as VTable,
  inRightTable as VTable
  inLeftPower as  EVLinkType = kOne,
  inRightPower as EVLinkType = kMany
  inOnDelete as EVStorageType = kDefault
  inStorageType as Boolean = false ) as VLink
Creates a new Binary Link between 2 tables of this database.
To specify a link you need to define the following:
• A name of the link, unique in the scope of the database.
• Pointers to 2 tables. One table is named  Left, the other is named  
Right.
• The type of link, i.e. if it is 1 : 1  or 1 : M or M : M.
• The behavior of the link on deletion of a record in the Table-Owner.
- In the case of a 1 : M link. The ONE table is the owner table
- In the rest of the cases (1:1 and M:M) the developer can assign any  
table to be the
owner.



So is the correct way

1) CreateLink with EVOnDelete.KDefault  on Table[A] and Table[B]

where I think kDefault means: when I delete a record from the owner  
table all records from the child table are also deleted

AT RUN Time:

2) BEFORE deleting a record from a table[A] that is used in a M:M  
binary link  I set VLink.Owner = table[A]
3) Delete the record from table[A]
4) because I set the owner all entries in the binary link that use  
the (now deleted) recid also are removed from binary link automaticly ?


AT Run Time

2) BEFORE deleting a record from a table[B] that is used in a M:M  
binary link  I set VLink.Owner = table[B]
3) Delete the record from table[B]
4) because I set the owner all entries in the binary link that use  
the (now deleted) recid also are removed from binary link automaticly ?


...reading more

> Read please
>
> http://www.valentina-db.com/dokuwiki/doku.php? 
> id=paradigma:public:en:documen
> tation:vsql:reference:create_link
>
>


...confused:

But maybe not if I understood correctly what kDefault means...
Is kDefault = kCascade when an Owner is set ? And kDefault is there  
because when I create the link I do not now how the cascade delete  
has to work (left to right or right to left)
So further down the road when I know I want to delete a record, I  
know which table ( for this routine) should be Owner, so I can do

VLink.Owner = VTable

and now the VLink which has onDelete.kDefault becomes implicitly  
kCascade

Correct ?

TIA

Bart







More information about the Valentina mailing list