 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Roger Venad Guest
|
Posted: Mon Nov 24, 2003 12:37 pm Post subject: Table Referential Integrity |
|
|
Could someone tell me if there exists a function that I can use with dbexpress to find the referential Integrity of a table which resides in Oracle, SQL Server or AS400.
Thanks in advance.
Roger Venad
|
|
| Back to top |
|
 |
Craig Stuntz [TeamB] Guest
|
Posted: Mon Nov 24, 2003 1:56 pm Post subject: Re: Table Referential Integrity |
|
|
Roger Venad wrote:
| Quote: | Could someone tell me if there exists a function that I can use with
dbexpress to find the referential Integrity of a table which resides
in Oracle, SQL Server or AS400.
|
Not that I'm aware of, but the SQL-92 standard does define some system
views which can be used for this purpose. This method is preferable
anyway since it's independent of dbExpress. Search your DB server
documentation for REFERENTIAL_CONSTRAINTS to find out whether or not
they are supported on each server.
Even if these VIEWs are not natively supported, you may be able to
define a similar view on your own.
-Craig
--
Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH
Delphi/InterBase Weblog : http://delphi.weblogs.com
InterBase Performance Monitor -- Analyze and control your IB7
server: http://delphi.weblogs.com/IBPerformanceMonitor
|
|
| Back to top |
|
 |
Michel Sabourin Guest
|
Posted: Wed Dec 10, 2003 2:27 pm Post subject: Re: Table Referential Integrity |
|
|
Roger,
On iSeries (AS/400), you can use the following query on system SQL views to
extract constraints related to <YourTable> in <YourSchema>:
SELECT CONSTRAINT_NAME
FROM SYSREFCST
WHERE UNIQUE_CONSTRAINT_SCHEMA CONCAT UNIQUE_CONSTRAINT_NAME IN (
SELECT CONSTRAINT_SCHEMA CONCAT CONSTRAINT_NAME
FROM SYSCST
WHERE TABLE_NAME = '<YourTable>'
AND TABLE_SCHEMA = '<YourSchema>'
AND CONSTRAINT_TYPE IN ('PRIMARY KEY', 'UNIQUE'))
UNION
SELECT CONSTRAINT_NAME
FROM SYSCST
WHERE TABLE_NAME = '<YourTable>'
AND TABLE_SCHEMA = '<YourSchema>'
ORDER BY CONSTRAINT_NAME;
Alternatively, you can access underlying system physical tables, in this
case to display the complete picture of constraints related to <YourTable>
in <YourSchema>:
select cst.DBCCNM as Constraint, DBCCTY as Type,
DBCCKC KEY,
substr(trim(cst.DBCCFL) CONCAT '/' CONCAT trim(DBCCFF), 1, 16) as Child,
substr(trim(cst.DBCPFL) CONCAT '/' CONCAT trim(DBCPFF), 1, 16) as Parent,
DBCRDR as ON_DELETE , DBCRUR as ON_UPDATE ,
substr(char(DBCTMS), 1, 10) as date,
substr(char(DBCTMS), 12, as time,
DBCCDN as condition, DBCCWK as field_order
from qadbfcst as CST
LEFT OUTER JOIN QADBCCST AS KEY
on key.DBCCKL = cst.DBCCNL AND
key.DBCCKN = cst.DBCCNM
where (DBCCFF = '<YourTable>' AND DBCCFL = '<YourSchema>') OR
(DBCPFF = '<YourTable>' AND DBCPFL = '<YourSchema>')
ORDER BY CONSTRAINT, field_order ;
Regards,
Michel Sabourin
"Craig Stuntz [TeamB]" <cstuntz (AT) nospam (DOT) please [a.k.a. vertexsoftware.com]> a
écrit dans le message de news:3fc21c10 (AT) newsgroups (DOT) borland.com...
| Quote: | Roger Venad wrote:
Could someone tell me if there exists a function that I can use with
dbexpress to find the referential Integrity of a table which resides
in Oracle, SQL Server or AS400.
Not that I'm aware of, but the SQL-92 standard does define some system
views which can be used for this purpose. This method is preferable
anyway since it's independent of dbExpress. Search your DB server
documentation for REFERENTIAL_CONSTRAINTS to find out whether or not
they are supported on each server.
Even if these VIEWs are not natively supported, you may be able to
define a similar view on your own.
-Craig
--
Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH
Delphi/InterBase Weblog : http://delphi.weblogs.com
InterBase Performance Monitor -- Analyze and control your IB7
server: http://delphi.weblogs.com/IBPerformanceMonitor
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|