AdsDDGetRefIntegrityProperty

Advantage Client Engine

Gets a specified property from the data dictionary for a referential integrity (RI) constraint.

Syntax

UNSIGNED 32

AdsDDGetRefIntegrityProperty(ADSHANDLE hDBConn,

UNSIGNED8 *pucRIName,

UNSIGNED16 usPropertyID,

UNSIGNED8 *pucProperty,

UNSIGNED16 *pusPropertyLen );

 

Parameters

hDBConn (I)

Handle of a database connection.

pucRefName (I)

The name of the RI constraint in the data dictionary.

usPropertyID (I)

The property to retrieve. (See below for possible values.)

pucProperty (O)

A buffer to hold the property value.

pusPropertyLen (I/O)

Length of given buffer on input, length of returned data on output.

Description

AdsDDGetRefIntegrityProperty will retrieve the specified RI property for a table from the data dictionary.

The following are the valid values for usPropertyID:

usPropertyID

Description

ADS_DD_RI_PRIMARY_TABLE

The name of the parent table of the RI constraint that contains the primary key index. This property is returned as a NULL terminated string. This property can only be retrieved by users with administrative permissions. See Advantage Data Dictionary User Permissions for more information.

ADS_DD_RI_PRIMARY_INDEX

The name of the primary key index of the RI constraint. This property is returned as a NULL terminated string. This property can only be retrieved by users with administrative permissions. See Advantage Data Dictionary User Permissions for more information.

ADS_DD_RI_FOREIGN_TABLE

The name of the child table of the RI constraint that contains the foreign key index. ADS_DD_RI_FOREIGN_TABLE is returned as a NULL terminated string. This property can only be retrieved by users with administrative permissions. See Advantage Data Dictionary User Permissions for more information.

ADS_DD_RI_FOREIGN_INDEX

The name of the foreign key index of the RI constraint. ADS_DD_RI_FOREIGN_INDEX is returned as a NULL terminated string. This property can only be retrieved by users with administrative permissions. See Advantage Data Dictionary User Permissions for more information.

ADS_DD_RI_NO_PKEY_ERROR

The custom error message used for primary key violation errors. This property can only be retrieved by users with administrative permissions. See Advantage Data Dictionary User Permissions for more information.

ADS_DD_RI_CASCADE_ERROR

The custom error message used for cascade errors. This property can only be retrieved by users with administrative permissions. See Advantage Data Dictionary User Permissions for more information.

ADS_DD_RI_UPDATERULE

The update rule for the RI constraint. ADS_DD_RI_UPDATERULE is returned as a 1-byte (UNSIGNED8) number with the following possible values: ADS_DD_RI_CASCADE, ADS_DD_RI_RESTRICT, ADS_DD_RI_SETNULL, ADS_DD_RI_SETDEFAULT. This property can only be retrieved by users with administrative permissions. See Advantage Data Dictionary User Permissions for more information.

ADS_DD_RI_DELETERULE

The delete rule for the RI constraint. ADS_DD_RI_DELETERULE is returned as a 1-byte (UNSIGNED8) number with the following possible values: ADS_DD_RI_CASCADE, ADS_DD_RI_RESTRICT, ADS_DD_RI_SETNULL, ADS_DD_RI_SETDEFAULT. This property can only be retrieved by users with administrative permissions. See Advantage Data Dictionary User Permissions for more information.

Special Return Codes

AE_INVALID_PROPERTY_ID

Either the value supplied in usPropertyID is not a valid table property or the specified property cannot be retrieved.

AE_INSUFFICIENT_BUFFER

The size of the property to be copied into pvProperty is larger than the buffer size specified by usPropertyLen. The required buffer length is returned in usPropertyLen when this error occurs.

AE_PROPERTY_NOT_SET

The requested property is not set in the data dictionary. No data is returned in pvProperty and usPropertylen.

Example

void DumpRIObjectInfo( ADSHANDLE hDD, UNSIGNED8 *pucRIName )

{

UNSIGNED8 aucBig[65000];

UNSIGNED16 usBufferSize;

SIGNED32 lGraphID;

FILE *hFile;

 

hFile = fopen( "c:\\temp\\output.txt", "a+" );

 

fprintf( hFile, "\n" );

fprintf( hFile, "RI OBJECT NAME: %s\n", pucRIName );

 

usBufferSize = sizeof( aucBig );;

if ( AE_SUCCESS == AdsDDGetRefIntegrityProperty( hDD, pucRIName, ADS_DD_RI_PRIMARY_TABLE, aucBig, &usBufferSize ))

{

fprintf( hFile, "Primary Table: %s\n", aucBig );

}

else

fprintf( hFile, "No primary table?!?\n" );

 

usBufferSize = sizeof( aucBig );;

if ( AE_SUCCESS == AdsDDGetRefIntegrityProperty( hDD, pucRIName, ADS_DD_RI_PRIMARY_INDEX, aucBig, &usBufferSize ))

{

fprintf( hFile, " Primary Index: %s\n", aucBig );

}

else

fprintf( hFile, " No primary index?!?\n" );

 

usBufferSize = sizeof( aucBig );;

if ( AE_SUCCESS == AdsDDGetRefIntegrityProperty( hDD, pucRIName, ADS_DD_RI_FOREIGN_TABLE, aucBig, &usBufferSize ))

{

fprintf( hFile, "Foreign Table: %s\n", aucBig );

}

else

fprintf( hFile, "No foreign table?!?\n" );

 

usBufferSize = sizeof( aucBig );;

if ( AE_SUCCESS == AdsDDGetRefIntegrityProperty( hDD, pucRIName, ADS_DD_RI_FOREIGN_INDEX, aucBig, &usBufferSize ))

{

fprintf( hFile, " Foreign Index: %s\n", aucBig );

}

else

fprintf( hFile, " No foreign index?!?\n" );

 

usBufferSize = sizeof( UNSIGNED8 );;

if ( AE_SUCCESS == AdsDDGetRefIntegrityProperty( hDD, pucRIName, ADS_DD_RI_UPDATERULE, aucBig, &usBufferSize ))

{

fprintf( hFile, "Update Rule: " );

switch( aucBig[0] )

{

case ADS_DD_RI_CASCADE : fprintf( hFile, "cascade\n" ); break;

case ADS_DD_RI_RESTRICT : fprintf( hFile, "restrict\n" ); break;

case ADS_DD_RI_SETNULL : fprintf( hFile, "set null\n" ); break;

case ADS_DD_RI_SETDEFAULT : fprintf( hFile, "set default\n" ); break;

default: fprintf( hFile, "ERROR, UNKNOWN UPDATE RULE!\n" );

}

}

else

fprintf( hFile, "ERROR GETTING UPDATE RULE!\n" );

 

usBufferSize = sizeof( UNSIGNED8 );;

if ( AE_SUCCESS == AdsDDGetRefIntegrityProperty( hDD, pucRIName, ADS_DD_RI_DELETERULE, aucBig, &usBufferSize ))

{

fprintf( hFile, "Delete Rule: " );

switch( aucBig[0] )

{

case ADS_DD_RI_CASCADE : fprintf( hFile, "cascade\n" ); break;

case ADS_DD_RI_RESTRICT : fprintf( hFile, "restrict\n" ); break;

case ADS_DD_RI_SETNULL : fprintf( hFile, "set null\n" ); break;

case ADS_DD_RI_SETDEFAULT : fprintf( hFile, "set default\n" ); break;

default: fprintf( hFile, "ERROR, UNKNOWN DELETE RULE!\n" );

}

}

else

fprintf( hFile, "ERROR GETTING DELETE RULE!\n" );

fclose( hFile );

 

}

See Also

AdsDDCreateRefIntegrity62

AdsDDRemoveRefIntegrity

system.relations