"H�bschen, Peter" wrote:
> Hello,
>
> I was running into this problem earlier, but now I need an
> explanation,
> cause it's important for project. Earlier I only deleted the
> referential
> constraint.
> My tables are defined:
> CREATE TABLE "TBL_RUECKMELDUNG"
> (
> "LFD_RUECKFRAGENUMMER" Integer NOT
> NULL DEFAULT
> SERIAL (1),
> "RUECKMELDEDATUM" Timestamp DEFAULT TIMESTAMP,
> "LFD_ANFRAGENUMMER" Integer,
> .....
> PRIMARY KEY ("LFD_RUECKFRAGENUMMER"),
> FOREIGN KEY "REF_RUECK_STAFFEL" ("LFD_ANFRAGENUMMER")
> REFERENCES
> "TBL_STAFFELRUECKM" ("LFD_STAFFELNR") ON DELETE CASCADE
> )
>
> CREATE TABLE "TBL_STAFFELRUECKM"
> (
> "LFD_RUECKFRAGENUMMER" Integer NOT NULL,
> .....
> "LFD_STAFFELNR" Fixed (10,0) NOT NULL
> DEFAULT
> SERIAL (1),
> PRIMARY KEY ("LFD_STAFFELNR")
> )
>
>
> If I try to insert a new line into TBL_RUECKMELDUNG (through
> SQL-Studio
> (latest Version)) I get an integrity constraint violation. If
> I insert a new
> line into TBL_STAFFELRUECKM it works.
> My intention is:
> TBL_RUECKMELDUNG contains one line and TBL_STAFFELRUECKM
> contains one or
> more lines which are "linked" to the one line in
> TBL_RUECKMELDUNG. If I
> delete this one line in TBL_RUECKMELDUNG I want to delete the
> "linked" lines
> in TBL_STAFFELRUECKM
> So I made the constraint TBL_RUECKMELDUNG ->
> TBL_STAFFELRUECKM. But after my
> experience from below it seems that I have to make a constraint
> TBL_STAFFELRUECKM -> TBL_RUECKMELDUNG. Is this right?
Yes
> I have to fill my first table first, since it contains the
> main data and the
> second one contains more 'detailed' data or maybe no data for
> that record in
> TBL_RUECKMELDUNG.
That's right
>
> I nearly forgot: I'm using a Redhat 9 box with SAPDB 7.4.3.25
The definition of the referential constraint has to be in the table which references,
i.e. which has to be checked if an insert is done in that table.
The referenced table (which has to be checked when update/delete are done in)
does not have the referential constraint definition in.
--> TBL_STAFFELRUECKM has to have the referential constraint definition
if for one of its numbers it has to be assured that this number is in TBL_RUECKMELDUNG
as well.
Please pay attention to the fact about keycolumns/unique index columns
which are needed for the referential constraint.
Elke
SAP Labs Berlin
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general