For anyone who runs into this problem, and needs to know the deletion
control parameters on a relationship, this seemed to be the most direct way
to do it.
See also the documentation for the System Tables, available to 4D SQL
commands:
<https://doc.4d.com/4Dv15/4D/15/System-Tables.300-2288116.en.html>
// ----------------------------------------------------
// User name (OS): Doug Hall
// Date and time: 12/04/19, 08:27:43
// ----------------------------------------------------
// Method: Fld_ForeignKeyDeleteRule
// Description: Returns the deletion rule associated with foreign key $1->.
(RESTRICT or CASCADE)
//
//
// Parameters
// ----------------------------------------------------
*C_TEXT*(*$0*;$deleteRule)
*C_POINTER*(*$1*;$pForeignKey)
$pForeignKey:=*$1*
$deleteRule:=""
*C_LONGINT*($oneTableNum;$oneFieldNum;$manyTableNum)
*GET RELATION PROPERTIES*($pForeignKey;$oneTableNum;$oneFieldNum)
*If* (($oneTableNum>0) & ($oneFieldNum>0)) // Should not happen.
Otherwise, $pForeignKey WASN'T a foreign key.
$manyTableNum:=*Table*($pForeignKey)
*Begin SQL*
* Select* DELETE_RULE *from* _USER_CONSTRAINTS
*where* CONSTRAINT_TYPE='4DR'
*and* TABLE_ID= <<$manyTableNum>>
*and* RELATED_TABLE_ID= <<$oneTableNum>>
*into* <<$deleteRule>>
*End SQL*
*End if*
*$0*:=$deleteRule
---
Then, depending on your need, test what these methods return for the proper
foreign key...
// ----------------------------------------------------
// User name (OS): Doug Hall
// Date and time: 05/11/17, 09:29:04
// ----------------------------------------------------
// Method: Tbl_CannotDeleteRelatedMany
// Description: Returns true if the table with foreign key $1
// cannot be deleted as defined in the relationship defined on the foreign
key.
//
//
// Parameters
// ----------------------------------------------------
*C_BOOLEAN*(*$0*) // Deletes Related Many
*C_POINTER*(*$1*;$pForeignKey)
$pForeignKey:=*$1*
*$0*:=(*Fld_ForeignKeyDeleteRule* ($pForeignKey)="RESTRICT")
---
and also...
// ----------------------------------------------------
// Method: Tbl_DeletesRelatedMany
// Author: dhall
// Date and time: 11/01/06, 11:19:04
// ----------------------------------------------------
// Called from: Rec_CanDeleteRelated
// Description: Returns whether records of table with foreign key field
$1-> is
// deleted if the primary (One) table record is deleted.
//
//
// Parameters
// ----------------------------------------------------
*C_BOOLEAN*(*$0*) // Deletes Related Many
*C_POINTER*(*$1*;$pForeignKey)
$pForeignKey:=*$1*
*$0*:=(*Fld_ForeignKeyDeleteRule* ($pForeignKey)="CASCADE")
---
Note that an empty string is returned by my Fld_ForeignKeyDeleteRule method
if the designer chose the "Leave related many intact" radio button in the
Deletion Control area.
Doug
On Tue, Dec 3, 2019 at 4:58 PM Keisuke Miyako via 4D_Tech <
[email protected]> wrote:
> you could parse the xml returned from the export structure command.
>
>
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive: http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub: mailto:[email protected]
> **********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************