Foreign key reference issue.

Foreign key reference issue.

  

Hi,

I am trying to delete a table records from parent  its throwing an error  says child record found in a deleted table.

My question is if the table is deleted or is not active, then why its throwing such error?

 any idea?



Thanks

Rajendra Singh

Hi Raj,

I assume that you deleted the Entity only from the eSpace, but that doesn't delete it from the database! You could use the DBCleaner to remove all the old, no longer accesible, data.

EDIT: As Eduardo said, the Platform removes contraints, so it shouldn't happen with OS Entities.

Hello Raj,

Could you put here an image of the error that is found in the Service Center Monitoring Errors?
And explain with more detail the scenario (what is this "deleted" table and if they are OutSystems entities or imported entities from an external database?)

By default, OutSystems do not delete tables from database when the entity is deleted, but it removes the constraints, or change the delete rule to DELETE/IGNORE (don't know for sure), so that you can delete records in the parent even if there are somerecords pointing to them in the deleted entity.

I just tested and this works.

So, I would like to understand better your scenario in order to help you.

Cheers.

EDIT: I updated my answer a little (in red), to take into account that I don't know if the constraints are removed or the delete rule is set to DELETE/IGNORE.

Hi Raj,

Can you please explain your problem along with your cases with respective image it will be helpful to analyzing the problem.


Regards

-SK-

Kilian Hekhuis wrote:

Hi Raj,

I assume that you deleted the Entity only from the eSpace, but that doesn't delete it from the database! You could use the DBCleaner to remove all the old, no longer accesible, data.

EDIT: As Eduardo said, the Platform removes contraints, so it shouldn't happen with OS Entities.

Thanks Kilian.


Thanks Everyone, I think my question was not clear let me elaborate the issue;

We are archiving the data using the java service, and by mistake child table got deleted from the Outsystem,

So while archiving the data java service is trying to delete the parent record and throwing the below error.

### Cause: java.sql.SQLIntegrityConstraintViolationException: ORA-02292: integrity constraint (Schema.Deletedtablename) violated - child record found

I think i am clear now I need to delete the table parliamentary from oracle or Active the table again 

I have one more doubt if i will delete the table from the outsystem will it remove the foreign key constraint? because if it removes the foreign key constraint then it should not through an exception.


Thanks

Rajendra Singh

Sorry Raj, but you got me confused now.

When you say "Java Service", are you talking about a web service made in JAVA? Something completely disconnected from your OutSystems application?

In any case, this behavior is strange. Exactly HOW did you delete this entity? From Service Studio?

At least in the servers where I tested, deleting a "child" entity (one with a FK to a "parent" entity), do not prevent you from delete records in the parent (the constraint is removed or the delete rrule is changed). Maybe you have a different configuration in your server, I don't know.

One way to solve this would be to restore a version of the application prior to the entity deletion. This should solve the problem (I think), but would have consequences (any changes made to the application would rollback).

Or, if you have access to the database, truncate the child entity.

Cheers.

P.S. If the entity is an OUTSYSTEMS entity, DBCleaner can delete the physical table from the system.

Eduardo Jauch wrote:

Sorry Raj, but you got me confused now.

When you say "Java Service", are you talking about a web service made in JAVA? Something completely disconnected from your OutSystems application?

In any case, this behavior is strange. Exactly HOW did you delete this entity? From Service Studio?

At least in the servers where I tested, deleting a "child" entity (one with a FK to a "parent" entity), do not prevent you from delete records in the parent (the constraint is removed or the delete rrule is changed). Maybe you have a different configuration in your server, I don't know.

One way to solve this would be to restore a version of the application prior to the entity deletion. This should solve the problem (I think), but would have consequences (any changes made to the application would rollback).

Or, if you have access to the database, truncate the child entity.

Cheers.

P.S. If the entity is an OUTSYSTEMS entity, DBCleaner can delete the physical table from the system.

yes Eduardo Jauch,its web service made in JAVA , and table got deleted from the service studio by right click on the table and delete.

yes Edurado its not preventing if i am doing from the outsystem 

I am going to truncate the table.


Thanks

Rajendra Singh

Hi Raj,

Afaik, you can restore that delete by publishing an older version of that eSpace that still had that table (or, iirc, merge your current version with the older version).