version 6.5
OC GET FOREIGN KEY LIST (cursor_ID; pkTableTarget; fkTableTarget; pkTableQualifier; pkTableOwner; pkTableName; pkColumnName; fkTableQualifier; fkTableOwner; fkTableName; fkColumnName; keySeq; updateRule; deleteRule; fkName; pkName)
| Parameter | Type | Description | |
| cursor_ID | Longint | Connection Identifier | |
| pkTableTarget | String | Name of the primary key table target | |
| fkTableTarget | String | Name of the foreign key table target | |
| pkTableQualifier | String | Name of 4D array | |
| pkTableOwner | String | Name of 4D array | |
| pkTableName | String | Name of 4D array | |
| pkColumnName | String | Name of 4D array | |
| fkTableQualifier | String | Name of 4D array | |
| fkTableOwner | String | Name of 4D array | |
| fkTableName | String | Name of 4D array | |
| fkColumnName | String | Name of 4D array | |
| keySeq | String | Name of 4D array | |
| updateRule | String | Name of 4D array | |
| deleteRule | String | Name of 4D array | |
| fkName | String | Name of 4D array | |
| pkName | String | Name of 4D array |
Description
The command OC GET FOREIGN KEY LIST returns a list of foreign keys in the specified table that refer to primary keys in other tables or a list of foreign keys in other tables that refer to the primary key in the specified table.
If pkTableTarget contains a table name, OC GET FOREIGN KEY LIST returns a result set containing the primary key of the specified table and all the foreign keys that refer to it.
If fkTableTarget contains a table name, OC GET FOREIGN KEY LIST returns a result set containing all the foreign keys in the specified table and the primary keys in other tables to which they refer.
If both pkTableTarget and fkTableTarget contain a table name, OC GET FOREIGN KEY LIST returns the foreign keys in the table specified in fkTableTarget that refer to the primary key of the table specified in pkTableTarget. This should be one key at most.
cursor_ID must be a valid cursor.
pkTableTarget is a table containing the primary key.
fkTableTarget is a table containing the foreign key.
pkTableQualifier is the primary key table qualifier identifier. An empty string is returned if not applicable to the data source.
pkTableOwner is the primary key table owner identifier. An empty string is returned if not applicable to the data source.
pkTableName is the primary key table identifier.
pkColumnName is the primary key column identifier.
fkTableQualifier is the foreign key table qualifier identifier. An empty string is returned if not applicable to the data source.
fkTableOwner is the foreign key table owner identifier. An empty string is returned if not applicable to the data source.
fkTableName is the foreign key table identifier.
fkColumnName is the foreign key column identifier.
keySeq is the column sequence number in the key (starting with 1).
updateRule is the action to be applied to the foreign key when the SQL operation is UPDATE:
| 0 -> SQL_CASCADE | |
| 1 -> SQL_RESTRICT | |
| 2 -> SQL_SET_NULL |
An empty string is returned if not applicable to the data source.
deleteRule is the action to be applied to the foreign key when the SQL operation is DELETE:
| 0 -> SQL_CASCADE | |
| 1 -> SQL_RESTRICT | |
| 2 -> SQL_SET_NULL |
An empty string is returned if not applicable to the data source.
fkName is the foreign key identifier. An empty string is returned if not applicable to the data source.
pkName is the primary key identifier. An empty string is returned if not applicable to the data source.
Example
`Declare the needed arrays
ARRAY STRING(15;apkTableQualifier;0)
ARRAY STRING(15;apkTableOwner;0)
ARRAY STRING(15;apkTableName;0)
ARRAY STRING(15;apkColumnName;0)
ARRAY STRING(15;afkTableQualifier;0)
ARRAY STRING(15;afkTableOwner;0)
ARRAY STRING(15;afkTableName;0)
ARRAY STRING(15;afkColumnName;0)
ARRAY STRING(15;aKeySeq;0)
ARRAY STRING(15;aUpdateRule;0)
ARRAY STRING(15;aDeleteRule;0)
ARRAY STRING(15;afkName;0)
ARRAY STRING(15;apkName;0)
loginID:=OC Login ("sa";"";"MSSQL65")
cursor:=OC Create cursor (loginID)
OC GET FOREIGN KEY LIST(cursor;"titres";"titreauteur";"apkTableQualifier";"apkTableOwner";
"apkTableName";"apkColumnName";"afkTableQualifier";"afkTableOwner";"afkTableName";
"afkColumnName";"aKeySeq";"aUpdateRule";"aDeleteRule";"afkName";"apkName")
OC DROP CURSOR (cursor)
OC LOGOUT (loginID)
See Also