BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Table Referential Integrity

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress)
View previous topic :: View next topic  
Author Message
Roger Venad
Guest





PostPosted: Mon Nov 24, 2003 12:37 pm    Post subject: Table Referential Integrity Reply with 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.
Thanks in advance.
Roger Venad
Back to top
Craig Stuntz [TeamB]
Guest





PostPosted: Mon Nov 24, 2003 1:56 pm    Post subject: Re: Table Referential Integrity Reply with quote



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





PostPosted: Wed Dec 10, 2003 2:27 pm    Post subject: Re: Table Referential Integrity Reply with quote



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, Cool 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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.