Finding the referenced entities

Hello there,

Probably most of us have already tried to delete data from a central table, and then bumped into the foreign key constraints....

Usually, the solution i adopt for a small system is to map all my entities into an advanced query that deletes them all...

But the problem urges (only because i am bit of a laizy guy when it comes to do rotine work that could be automated) when you find a big dynamic entity model set, with lots of dependencies.

I know there are scripts in SQL than find all the dependencies and allow one to do a "manual" cascade delete (and if you have one please share...), but i wonder If Outsystems stores the foreign key dependencies in their meta-model, or even has some kind of script that returns all the foreign dependencies of a given attribute/table.


Best Regards,

Diogo Cordovil S. Cordeiro
Hi Diogo,

As far as I am aware, OutSystems doesn't store the dependencies in the meta-model. As you mentioned, I assume you can infer them using some SQL scripts, but I'm not sure there is a single place where you can find them all.

If someone has such a script - or if there's a better way to do it - I hope someone lets us know :)


Paulo Tavares
Hey Paulo, after discussing with my office companions, i've been able to reach for a solution to this.

Outsystems does keep track of foreign keys, in a somewhat singular way. One can find a Table's dependencies with the following query : (the connector is the attribute "type" from the table Entity_Attr.)

SELECT distinct {Entity}.[Name] from {Entity}
inner join {Entity_Attr} on {Entity_Attr}.[Entity_Id]={Entity}.[Id]
,{Entity} e2 
inner join {Espace} on {Espace}.[Id] = e2.[Espace_Id]
where {Entity_Attr}.[Type] like '%'+e2.[SS_Key]
and {Espace}.[Name]=@NomeEspace
and e2.[Name] = @NomeLogicoTabela 
and {Entity_Attr}.[Is_Active] = 1
and {Entity}.[Is_Active] = 1
and e2.[Is_Active] = 1

and {Espace}.[Is_Active] = 1

With this query one can pull out a few tricks....

Best Regards,

Diogo Cordovil S. Cordeiro
I have found that the Entity_Attr sometimes dont have the same name column that the physical table.Is there any way to refresh this Entity_Attr table with the database?