Index

DKForeignKeyDefICM

Purpose:

Use this class to represent a foreign key definition for a component type.

Class summary:

class DKEXPORT DKForeignKeyDefICM
{
 public:
                                DKForeignKeyDefICM();
                                DKForeignKeyDefICM(dkDatastore* ds);
                                DKForeignKeyDefICM(const DKForeignKeyDefICM& foreignKey);
    virtual                     ~DKForeignKeyDefICM();
                void            setDatastore(dkDatastore* ds);   
                dkDatastore*    getDatastore();
                void            setSourceCompTypeName(const char* srcCompTypeName);
                DKString        getSourceCompTypeName();
                void            setTargetCompTypeName(const char* tgtCompTypeName);
                DKString        getTargetCompTypeName();
                void            setTargetTableName(const char* tgtTableName);
                DKString        getTargetTableName();
                void            setTargetSchemaName(const char* tgtSchemaName);
                DKString        getTargetSchemaName();
                void            setConstraintName(const char* constraintName);    
                DKString        getConstraintName();
                void            setDeleteRule(short deleteRule);
                short           getDeleteRule();    
                void            setUpdateRule(short updateRule);
                short           getUpdateRule();
                void            addSrcAndTgtAttrName(const char* srcAttrName, const char* tgtAttrName,long columnSeq);
                void            removeSourceAttrName(const char* srcAttrName);
                DKString*       listSourceAttrNames(long& arraySize);
                DKString*       listTargetAttrNames(long& arraySize);
                dkCollection*   listForeignKeyAttrInfo();
                
 };

Members:

Constructors and destructor
DKForeignKeyDefICM()

Default constructor. Constructs a foreign key object.

DKForeignKeyDefICM(dkDatastore* ds)

Constructs a foreign key object and initialize it with the datastore.

Parameters: ds - A reference to a datastore object where the item type, whose foreign keys this object represents is defined Copy Constructor

DKForeignKeyDefICM(const DKForeignKeyDefICM& foreignKey)

A copy constructor for the foreign key object which make a copy of the specified foreign key.

Parameters: foreignKey- an foreign key object. Destructor

virtual ~DKForeignKeyDefICM()

Destructor for this object.

setDatastore
Sets the datastore where the item type, whose foreign keys this object represents is defined.

Parameters: ds - datastore

void setDatastore(dkDatastore* ds);

getDataStore
Gets the datastore where the item type, whose foreign keys this object represents is defined.

Returns: dkDatastore datastore

dkDatastore* getDatastore();

setSourceCompTypeName
Sets the source component type name for which this foreign key is defined. This name can be up to 15 characters.

Parameters: srcCompTypeName - source component type name

void setSourceCompTypeName(const char* srcCompTypeName);

getSourceCompTypeName
Gets source component type name for which this foreign key is defined.

Returns: source component type name

DKString        getSourceCompTypeName();

setTargetCompTypeName
Sets the target component type name which this foreign key references. This name can be up to 15 characters. A target component can be used if the foreign key references another component type within the ICM datastore.

Parameters: tgtCompTypeName - target component type name which this foreign key references.

Throws: DKException - if error occurs. /DL> See Also: DKSetTargetTableName

void setTargetCompTypeName(const char* tgtCompTypeName);

getTargetCompTypeName
Gets the target component type name which this foreign key references.

Returns: target component type name

DKString  getTargetCompTypeName();

setTargetTableName
sets the target table name which this foreign key references. A target table can be used if the foreign key references an external database table.The schema name to which this table belongs should also be set.

Parameters: tgtTableName - target table name

Throws: DKException - if error occurs Note: setTargetCompTypeName and setTargetTableName are mutually exclusive. The foreign key can either reference a component type which is internal to the ICM datastore or a external database table.

void setTargetTableName(const char* tgtTableName);

getTargetTableName
Gets the target table name which this foreign key references.

Returns: target table name

DKString  getTargetTableName();

setTargetSchemaName
Sets the target schema name to which the target table belongs to. The target schema name should be specified if this foreign references an external table.

Returns: tgtSchemaName - target schema name

void setTargetSchemaName(const char* tgtSchemaName);

getTargetSchemaName
Gets the target schema name to which the target external table belongs to. Note: the target schema name is not available if the target is a component

Returns: target schema name

DKString        getTargetSchemaName();

setConstraintName
Sets a constraint name for this foreign key. This name can be up to 18 characters.

Parameters: constraintName

void setConstraintName(const char* constraintName);

getConstraintName
Gets the constraint name for this foreign key.

Returns: constraintName

DKString  getConstraintName();

setDeleteRule
Sets the delete rule for this foreign key constraint.

Parameters:

3 : No action

2 : Set null

1 : Cascade

0 : Restrict (default)

void setDeleteRule(short deleteRule);

getDeleteRule
Gets the delete rule for this foreign key constraint.

Returns:delete rule for this foreign key constraint.

short getDeleteRule();

setUpdateRule
Sets the update rule for this foreign key constraint.

Parameters: updateRule - update rule for this foreign key constraint. The possible values are:

3 : No action

0 : Restrict (default)

void setUpdateRule(short updateRule);

getUpdateRule
Gets the update rule for this foreign key constraint.

Returns: update rule for this foreign key constraint.

short getUpdateRule();

addSrcAndTgtAttrName
Adds a source attributes and the corresponding target attribute or column name to this foreign key. The target attribute name is specified if the target is a component type name and column name is specified if the target is an external table. Note: The target attribute or column should be a unique key or primary key. Both the source and the target attribute or column must have the same attribute type or data type and length.

Throws: DKException and DKAlreadyExistException - if error occurs

void addSrcAndTgtAttrName(const char* srcAttrName, const char* tgtAttrName, long columnSeq);

removeSourceAttrName
Removes a source attribute from this foreign key.

Parameters: srcAttrName - attrname of the attribute need to be removed

Throws: DKException and DKNotExistException - if error occurs

void removeSourceAttrName(const char* srcAttrName);

listSourceAttrNames
List source attributes from this foreign key.

Parameters: arraySize - the size of the DKString array being returned

Returns: an array of DKString, which are the names of the source attributes

Throws: DKException - if error occurs

DKString* listSourceAttrNames(long& arraySize);

listTargetAttrNames
Lists target attributes from this foreign key.

Parameters: arraySize - the size of the DKString array being returned

Returns: an array of DKString, which are the names of the source attributes

Throws: DKException - if error occurs

DKString* listTargetAttrNames(long& arraySize);

listForeignKeyAttrInfo
Lists source and target attributes and column sequence from this foreign key.

Returns: a dkcollection containing

String[3]: objects

String[0]: column seq

String[1]: source attribute

String[2]: target attribute

dkCollection*    listForeignKeyAttrInfo();

(c) Copyright International Business Machines Corporation 1996, 2003. IBM Corp. All rights reserved.