441 lines
27 KiB
HTML
441 lines
27 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html lang="en-us" xml:lang="en-us">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="security" content="public" />
|
|
<meta name="Robots" content="index,follow" />
|
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
|
<meta name="DC.Type" content="reference" />
|
|
<meta name="DC.Title" content="SQLForeignKeys - Get the list of foreign key columns" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzadphdapi.htm" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 1999, 2006" />
|
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1999, 2006" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="rzadpfnfkey" />
|
|
<meta name="DC.Language" content="en-us" />
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
|
<title>SQLForeignKeys</title>
|
|
</head>
|
|
<body id="rzadpfnfkey"><a name="rzadpfnfkey"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">SQLForeignKeys - Get the list of foreign key columns</h1>
|
|
<div><div class="section"><h4 class="sectiontitle">Purpose</h4> <p><samp class="codeph">SQLForeignKeys()</samp> returns
|
|
information about foreign keys for the specified table. The information is
|
|
returned in an SQL result set which can be processed using the same functions
|
|
that are used to retrieve a result that is generated by a query.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Syntax</h4><pre>SQLRETURN SQLForeignKeys (SQLHSTMT StatementHandle,
|
|
SQLCHAR *PKCatalogName,
|
|
SQLSMALLINT NameLength1,
|
|
SQLCHAR *PKSchemaName,
|
|
SQLSMALLINT NameLength2,
|
|
SQLCHAR *PKTableName,
|
|
SQLSMALLINT NameLength3,
|
|
SQLCHAR *FKCatalogName,
|
|
SQLSMALLINT NameLength4,
|
|
SQLCHAR *FKSchemaName,
|
|
SQLSMALLINT NameLength5,
|
|
SQLCHAR *FKTableName,
|
|
SQLSMALLINT NameLength6);</pre>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Function arguments</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="hsides" border="1" rules="all"><caption>Table 1. SQLForeignKeys arguments</caption><thead align="left"><tr><th align="left" valign="bottom" width="17.59259259259259%" id="d0e47">Data type</th>
|
|
<th align="left" valign="bottom" width="23.51851851851852%" id="d0e49">Argument </th>
|
|
<th align="left" valign="bottom" width="11.851851851851853%" id="d0e51">Use </th>
|
|
<th align="left" valign="bottom" width="47.03703703703704%" id="d0e53">Description </th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e47 ">SQLCHAR *</td>
|
|
<td align="left" valign="top" width="23.51851851851852%" headers="d0e49 "><em>FKCatalogName</em> </td>
|
|
<td align="left" valign="top" width="11.851851851851853%" headers="d0e51 ">Input </td>
|
|
<td align="left" valign="top" width="47.03703703703704%" headers="d0e53 ">Catalog qualifier of the table containing
|
|
the foreign key. This must be a NULL pointer or a zero length string.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e47 ">SQLCHAR *</td>
|
|
<td align="left" valign="top" width="23.51851851851852%" headers="d0e49 "><em>FKSchemaName</em> </td>
|
|
<td align="left" valign="top" width="11.851851851851853%" headers="d0e51 ">Input </td>
|
|
<td align="left" valign="top" width="47.03703703703704%" headers="d0e53 ">Schema qualifier of the table containing
|
|
the foreign key.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e47 ">SQLCHAR *</td>
|
|
<td align="left" valign="top" width="23.51851851851852%" headers="d0e49 "><em>FKTableName</em></td>
|
|
<td align="left" valign="top" width="11.851851851851853%" headers="d0e51 ">Input </td>
|
|
<td align="left" valign="top" width="47.03703703703704%" headers="d0e53 ">Name of the table containing the foreign
|
|
key.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e47 ">SQLCHAR *</td>
|
|
<td align="left" valign="top" width="23.51851851851852%" headers="d0e49 "><em>PKCatalogName</em> </td>
|
|
<td align="left" valign="top" width="11.851851851851853%" headers="d0e51 ">Input </td>
|
|
<td align="left" valign="top" width="47.03703703703704%" headers="d0e53 ">Catalog qualifier of the primary key table.
|
|
This must be a NULL pointer or a zero length string.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e47 ">SQLCHAR *</td>
|
|
<td align="left" valign="top" width="23.51851851851852%" headers="d0e49 "><em>PKSchemaName</em> </td>
|
|
<td align="left" valign="top" width="11.851851851851853%" headers="d0e51 ">Input </td>
|
|
<td align="left" valign="top" width="47.03703703703704%" headers="d0e53 ">Schema qualifier of the primary key table.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e47 ">SQLCHAR *</td>
|
|
<td align="left" valign="top" width="23.51851851851852%" headers="d0e49 "><em>PKTableName</em> </td>
|
|
<td align="left" valign="top" width="11.851851851851853%" headers="d0e51 ">Input </td>
|
|
<td align="left" valign="top" width="47.03703703703704%" headers="d0e53 ">Name of the table name containing the primary
|
|
key.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e47 ">SQLHSTMT </td>
|
|
<td align="left" valign="top" width="23.51851851851852%" headers="d0e49 "><em>StatementHandle</em> </td>
|
|
<td align="left" valign="top" width="11.851851851851853%" headers="d0e51 ">Input </td>
|
|
<td align="left" valign="top" width="47.03703703703704%" headers="d0e53 ">Statement handle.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e47 ">SQLSMALLINT </td>
|
|
<td align="left" valign="top" width="23.51851851851852%" headers="d0e49 "><em>NameLength2</em> </td>
|
|
<td align="left" valign="top" width="11.851851851851853%" headers="d0e51 ">Input </td>
|
|
<td align="left" valign="top" width="47.03703703703704%" headers="d0e53 ">Length of <span class="synph"><span class="var">PKSchemaName</span></span>.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e47 ">SQLSMALLINT </td>
|
|
<td align="left" valign="top" width="23.51851851851852%" headers="d0e49 ">NameLength3 </td>
|
|
<td align="left" valign="top" width="11.851851851851853%" headers="d0e51 ">Input </td>
|
|
<td align="left" valign="top" width="47.03703703703704%" headers="d0e53 ">Length of <span class="synph"><span class="var">PKTableName</span></span>.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e47 ">SQLSMALLINT </td>
|
|
<td align="left" valign="top" width="23.51851851851852%" headers="d0e49 "><em>NameLength6</em> </td>
|
|
<td align="left" valign="top" width="11.851851851851853%" headers="d0e51 ">Input </td>
|
|
<td align="left" valign="top" width="47.03703703703704%" headers="d0e53 ">Length of <span class="synph"><span class="var">FKTableName</span></span>.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e47 ">SQLSMALLINT</td>
|
|
<td align="left" valign="top" width="23.51851851851852%" headers="d0e49 "><em>NameLength1</em> </td>
|
|
<td align="left" valign="top" width="11.851851851851853%" headers="d0e51 ">Input </td>
|
|
<td align="left" valign="top" width="47.03703703703704%" headers="d0e53 ">Length of <span class="synph"><span class="var">PKCatalogName</span></span>.
|
|
This must be set to 0.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e47 ">SQLSMALLINT</td>
|
|
<td align="left" valign="top" width="23.51851851851852%" headers="d0e49 "><em>NameLength4</em> </td>
|
|
<td align="left" valign="top" width="11.851851851851853%" headers="d0e51 ">Input </td>
|
|
<td align="left" valign="top" width="47.03703703703704%" headers="d0e53 ">Length of <span class="synph"><span class="var">FKCatalogName</span></span>.
|
|
This must be set to 0.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e47 ">SQLSMALLINT</td>
|
|
<td align="left" valign="top" width="23.51851851851852%" headers="d0e49 "><em>NameLength5 </em></td>
|
|
<td align="left" valign="top" width="11.851851851851853%" headers="d0e51 ">Input </td>
|
|
<td align="left" valign="top" width="47.03703703703704%" headers="d0e53 ">Length of <span class="synph"><span class="var">FKSchemaName</span></span>.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Usage</h4><p>If <span class="synph"><span class="var">PKTableName</span></span> contains
|
|
a table name, and <span class="synph"><span class="var">FKTableName</span></span> is an empty string, <samp class="codeph">SQLForeignKeys()</samp> returns
|
|
a result set that contains the primary key of the specified table and all
|
|
of the foreign keys (in other tables) that refer to it.</p>
|
|
<p>If <span class="synph"><span class="var">FKTableName</span></span> contains
|
|
a table name, and <span class="synph"><span class="var">PKTableName</span></span> is an empty string, <samp class="codeph">SQLForeignKeys()</samp>
|
|
returns a result set that contains all of the foreign keys in the specified
|
|
table and the primary keys (in other tables) to which they refer.</p>
|
|
<p>If
|
|
both <span class="synph"><span class="var">PKTableName</span></span> and <span class="synph"><span class="var">FKTableName</span></span> contain
|
|
table names, <samp class="codeph">SQLForeignKeys()</samp> returns the foreign keys in
|
|
the table specified in <span class="synph"><span class="var">FKTableName</span></span> that refer to
|
|
the primary key of the table specified in <span class="synph"><span class="var">PKTableName</span></span>.
|
|
This should be one key at the most.</p>
|
|
<p>If the schema qualifier argument
|
|
that is associated with a table name is not specified, then for the schema
|
|
name the default is the one currently in effect for the current connection.</p>
|
|
<p><a href="#rzadpfnfkey__tbfkey">Table 2</a> lists the columns of the result set generated
|
|
by the <samp class="codeph">SQLForeignKeys()</samp> call. If the foreign keys that are
|
|
associated with a primary key are requested, the result set is ordered by
|
|
FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and ORDINAL_POSITION. If the primary
|
|
keys that are associated with a foreign key are requested, the result set
|
|
is ordered by PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME, and ORDINAL_POSITION.</p>
|
|
<p>Although
|
|
new columns might be added and the names of the existing columns might be
|
|
changed in future releases, the position of the current columns does not change.</p>
|
|
|
|
<div class="tablenoborder"><a name="rzadpfnfkey__tbfkey"><!-- --></a><table cellpadding="4" cellspacing="0" summary="" id="rzadpfnfkey__tbfkey" width="100%" frame="hsides" border="1" rules="rows"><caption>Table 2. Columns returned by SQLForeignKeys</caption><thead align="left"><tr><th align="left" valign="bottom" width="22.407407407407405%" id="d0e291">Column number/name</th>
|
|
<th align="left" valign="bottom" width="16.11111111111111%" id="d0e293">Data type</th>
|
|
<th align="left" valign="bottom" width="58.14814814814815%" id="d0e295">Description</th>
|
|
<th valign="top" width="3.3333333333333335%" id="d0e297"> </th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="22.407407407407405%" headers="d0e291 ">1 PKTABLE_CAT</td>
|
|
<td align="left" valign="top" width="16.11111111111111%" headers="d0e293 ">VARCHAR(128) </td>
|
|
<td align="left" valign="top" width="58.14814814814815%" headers="d0e295 ">The current server.</td>
|
|
<td valign="top" width="3.3333333333333335%" headers="d0e297 "> </td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.407407407407405%" headers="d0e291 ">2 PKTABLE_SCHEM</td>
|
|
<td align="left" valign="top" width="16.11111111111111%" headers="d0e293 ">VARCHAR(128) </td>
|
|
<td align="left" valign="top" width="58.14814814814815%" headers="d0e295 ">The name of the schema containing PKTABLE_NAME.</td>
|
|
<td valign="top" width="3.3333333333333335%" headers="d0e297 "> </td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.407407407407405%" headers="d0e291 ">3 PKTABLE_NAME</td>
|
|
<td align="left" valign="top" width="16.11111111111111%" headers="d0e293 ">VARCHAR(128) not NULL</td>
|
|
<td align="left" valign="top" width="58.14814814814815%" headers="d0e295 ">Name of the table containing the primary
|
|
key.</td>
|
|
<td valign="top" width="3.3333333333333335%" headers="d0e297 "> </td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.407407407407405%" headers="d0e291 ">4 PKCOLUMN_NAME</td>
|
|
<td align="left" valign="top" width="16.11111111111111%" headers="d0e293 ">VARCHAR(128) not NULL</td>
|
|
<td align="left" valign="top" width="58.14814814814815%" headers="d0e295 ">Primary key column name.</td>
|
|
<td valign="top" width="3.3333333333333335%" headers="d0e297 "> </td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.407407407407405%" headers="d0e291 ">5 FKTABLE_CAT</td>
|
|
<td align="left" valign="top" width="16.11111111111111%" headers="d0e293 ">VARCHAR(128) </td>
|
|
<td align="left" valign="top" width="58.14814814814815%" headers="d0e295 ">The current server.</td>
|
|
<td valign="top" width="3.3333333333333335%" headers="d0e297 "> </td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.407407407407405%" headers="d0e291 ">6 FKTABLE_SCHEM</td>
|
|
<td align="left" valign="top" width="16.11111111111111%" headers="d0e293 ">VARCHAR(128) </td>
|
|
<td align="left" valign="top" width="58.14814814814815%" headers="d0e295 ">The name of the schema containing FKTABLE_NAME.</td>
|
|
<td valign="top" width="3.3333333333333335%" headers="d0e297 "> </td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.407407407407405%" headers="d0e291 ">7 FKTABLE_NAME</td>
|
|
<td align="left" valign="top" width="16.11111111111111%" headers="d0e293 ">VARCHAR(128) not NULL</td>
|
|
<td align="left" valign="top" width="58.14814814814815%" headers="d0e295 ">The name of the table containing the Foreign
|
|
key.</td>
|
|
<td valign="top" width="3.3333333333333335%" headers="d0e297 "> </td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.407407407407405%" headers="d0e291 ">8 FKCOLUMN_NAME</td>
|
|
<td align="left" valign="top" width="16.11111111111111%" headers="d0e293 ">VARCHAR(128) not NULL</td>
|
|
<td align="left" valign="top" width="58.14814814814815%" headers="d0e295 ">Foreign key column name.</td>
|
|
<td valign="top" width="3.3333333333333335%" headers="d0e297 "> </td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.407407407407405%" headers="d0e291 ">9 ORDINAL_POSITION</td>
|
|
<td align="left" valign="top" width="16.11111111111111%" headers="d0e293 ">SMALLINT not NULL</td>
|
|
<td align="left" valign="top" width="58.14814814814815%" headers="d0e295 ">The ordinal position of the column in the
|
|
key, starting at 1.</td>
|
|
<td valign="top" width="3.3333333333333335%" headers="d0e297 "> </td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.407407407407405%" headers="d0e291 ">10 UPDATE_RULE</td>
|
|
<td align="left" valign="top" width="16.11111111111111%" headers="d0e293 ">SMALLINT </td>
|
|
<td align="left" valign="top" width="58.14814814814815%" headers="d0e295 ">Action to be applied to the foreign key when
|
|
the SQL operation is UPDATE: <ul><li>SQL_RESTRICT</li>
|
|
<li>SQL_NO_ACTION</li>
|
|
</ul>
|
|
<div class="p">The update rule for IBM<sup>®</sup> DB2<sup>®</sup> DBMSs is always either RESTRICT or SQL_NO_ACTION.
|
|
However, ODBC applications might encounter the following UPDATE_RULE values
|
|
when connected to non-IBM RDBMSs: <ul><li>SQL_CASCADE</li>
|
|
<li>SQL_SET_NULL</li>
|
|
</ul>
|
|
</div>
|
|
</td>
|
|
<td valign="top" width="3.3333333333333335%" headers="d0e297 "> </td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.407407407407405%" headers="d0e291 ">11 DELETE_RULE</td>
|
|
<td align="left" valign="top" width="16.11111111111111%" headers="d0e293 ">SMALLINT</td>
|
|
<td align="left" valign="top" width="58.14814814814815%" headers="d0e295 ">Action to be applied to the foreign key when
|
|
the SQL operation is DELETE: <ul><li>SQL_CASCADE</li>
|
|
<li>SQL_NO_ACTION</li>
|
|
<li>SQL_RESTRICT</li>
|
|
<li>SQL_SET_DEFAULT</li>
|
|
<li>SQL_SET_NULL</li>
|
|
</ul>
|
|
</td>
|
|
<td valign="top" width="3.3333333333333335%" headers="d0e297 "> </td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.407407407407405%" headers="d0e291 ">12 FK_NAME</td>
|
|
<td align="left" valign="top" width="16.11111111111111%" headers="d0e293 ">VARCHAR(128) </td>
|
|
<td align="left" valign="top" width="58.14814814814815%" headers="d0e295 ">Foreign key identifier. NULL if not applicable
|
|
to the data source.</td>
|
|
<td valign="top" width="3.3333333333333335%" headers="d0e297 "> </td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="22.407407407407405%" headers="d0e291 ">13 PK_NAME</td>
|
|
<td align="left" valign="top" width="16.11111111111111%" headers="d0e293 ">VARCHAR(128)</td>
|
|
<td align="left" valign="top" width="58.14814814814815%" headers="d0e295 ">Primary key identifier. NULL if not applicable
|
|
to the data source.</td>
|
|
<td valign="top" width="3.3333333333333335%" headers="d0e297 "> </td>
|
|
</tr>
|
|
<tr><td colspan="3" align="left" valign="top" headers="d0e291 d0e293 d0e295 "> <div class="note"><span class="notetitle">Note:</span> The column
|
|
names used by DB2 UDB
|
|
CLI follow the X/Open CLI CAE specification style. The column types, contents
|
|
and order are identical to those defined for the <samp class="codeph">SQLForeignKeys()</samp> result
|
|
set in ODBC.</div>
|
|
</td>
|
|
<td valign="top" width="3.3333333333333335%" headers="d0e297 "> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Return codes</h4><div class="p"> <ul><li>SQL_SUCCESS</li>
|
|
<li>SQL_SUCCESS_WITH_INFO</li>
|
|
<li>SQL_STILL_EXECUTING</li>
|
|
<li>SQL_ERROR</li>
|
|
<li>SQL_INVALID_HANDLE</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Diagnostics</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="hsides" border="1" rules="rows"><caption>Table 3. SQLForeignKeys SQLSTATEs</caption><thead align="left"><tr><th align="left" valign="bottom" width="12.962962962962962%" id="d0e477">SQLSTATE </th>
|
|
<th align="left" valign="bottom" width="29.074074074074076%" id="d0e479">Description </th>
|
|
<th align="left" valign="bottom" width="57.96296296296296%" id="d0e481">Explanation </th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e477 "><strong>24</strong>000 </td>
|
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e479 ">Cursor state that is not valid</td>
|
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e481 ">A cursor is already opened on the statement
|
|
handle.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e477 "><strong>40</strong>003 <strong>08</strong>S01</td>
|
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e479 ">Communication link failure</td>
|
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e481 ">The communication link between the application
|
|
and data source fails before the function is completed.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e477 "><strong>HY</strong>001</td>
|
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e479 ">Memory allocation failure</td>
|
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e481 ">DB2 UDB CLI is unable to allocate memory
|
|
required to support the processing or completion of the function.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e477 "><strong>HY</strong>009 </td>
|
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e479 ">Argument value that is not valid</td>
|
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e481 ">The arguments <span class="synph"><span class="var">PKTableName</span></span> and <span class="synph"><span class="var">FKTableName</span></span> were
|
|
both NULL pointers.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e477 "><strong>HY</strong>010 </td>
|
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e479 ">Function sequence error</td>
|
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e481 "> </td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e477 "><strong>HY</strong>014 </td>
|
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e479 ">No more handles </td>
|
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e481 ">DB2 UDB CLI is unable to allocate a handle
|
|
due to internal resources.</td>
|
|
</tr>
|
|
<tr><td valign="top" width="12.962962962962962%" headers="d0e477 "><strong>HY</strong>021</td>
|
|
<td valign="top" width="29.074074074074076%" headers="d0e479 ">Internal descriptor that is not valid </td>
|
|
<td valign="top" width="57.96296296296296%" headers="d0e481 ">The internal descriptor cannot be addressed or allocated,
|
|
or it contains a value that is not valid.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e477 "><strong>HY</strong>090 </td>
|
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e479 ">String or buffer length that is not valid</td>
|
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e481 ">The value of one of the name length arguments
|
|
is less than 0, but not equal to SQL_NTS. <p>The length of the table or owner
|
|
name is greater than the maximum length supported by the server. Refer to
|
|
<a href="rzadpfnginfo.htm#rzadpfnginfo">SQLGetInfo - Get general information</a>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e477 "><strong>HY</strong>C00 </td>
|
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e479 ">Driver not capable</td>
|
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e481 ">DB2 UDB CLI does not support <span class="synph"><span class="var">catalog</span></span> as
|
|
a qualifier for table name.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e477 "><strong>HY</strong>T00 </td>
|
|
<td align="left" valign="top" width="29.074074074074076%" headers="d0e479 ">Timeout expired</td>
|
|
<td align="left" valign="top" width="57.96296296296296%" headers="d0e481 "> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Restrictions</h4><p>None.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Example</h4></div>
|
|
<div class="example" id="rzadpfnfkey__xmfkey"><a name="rzadpfnfkey__xmfkey"><!-- --></a><div class="p"><div class="note"><span class="notetitle">Note:</span> By using the code examples, you
|
|
agree to the terms of the <a href="codedisclaimer.htm">Code license and disclaimer information</a>.</div>
|
|
<pre>/* From CLI sample browser.c */
|
|
/* ... */
|
|
SQLRETURN list_foreign_keys( SQLHANDLE hstmt,
|
|
SQLCHAR * schema,
|
|
SQLCHAR * tablename
|
|
) {
|
|
|
|
/* ... */
|
|
rc = SQLForeignKeys(hstmt, NULL, 0,
|
|
schema, SQL_NTS, tablename, SQL_NTS,
|
|
NULL, 0,
|
|
NULL, SQL_NTS, NULL, SQL_NTS);
|
|
CHECK_HANDLE( SQL_HANDLE_STMT, hstmt, rc ) ;
|
|
|
|
rc = SQLBindCol(hstmt, 2, SQL_C_CHAR, (SQLPOINTER) pktable_schem.s, 129,
|
|
&pktable_schem.ind);
|
|
CHECK_HANDLE( SQL_HANDLE_STMT, hstmt, rc ) ;
|
|
|
|
rc = SQLBindCol(hstmt, 3, SQL_C_CHAR, (SQLPOINTER) pktable_name.s, 129,
|
|
&pktable_name.ind);
|
|
CHECK_HANDLE( SQL_HANDLE_STMT, hstmt, rc ) ;
|
|
|
|
rc = SQLBindCol(hstmt, 4, SQL_C_CHAR, (SQLPOINTER) pkcolumn_name.s, 129,
|
|
&pkcolumn_name.ind);
|
|
CHECK_HANDLE( SQL_HANDLE_STMT, hstmt, rc ) ;
|
|
|
|
rc = SQLBindCol(hstmt, 6, SQL_C_CHAR, (SQLPOINTER) fktable_schem.s, 129,
|
|
&fktable_schem.ind);
|
|
CHECK_HANDLE( SQL_HANDLE_STMT, hstmt, rc ) ;
|
|
|
|
rc = SQLBindCol(hstmt, 7, SQL_C_CHAR, (SQLPOINTER) fktable_name.s, 129,
|
|
&fktable_name.ind);
|
|
CHECK_HANDLE( SQL_HANDLE_STMT, hstmt, rc ) ;
|
|
|
|
rc = SQLBindCol(hstmt, 8, SQL_C_CHAR, (SQLPOINTER) fkcolumn_name.s, 129,
|
|
&fkcolumn_name.ind);
|
|
CHECK_HANDLE( SQL_HANDLE_STMT, hstmt, rc ) ;
|
|
|
|
rc = SQLBindCol(hstmt, 10, SQL_C_SHORT, (SQLPOINTER) &update_rule,
|
|
0, &update_ind);
|
|
CHECK_HANDLE( SQL_HANDLE_STMT, hstmt, rc ) ;
|
|
|
|
rc = SQLBindCol(hstmt, 11, SQL_C_SHORT, (SQLPOINTER) &delete_rule,
|
|
0, &delete_ind);
|
|
CHECK_HANDLE( SQL_HANDLE_STMT, hstmt, rc ) ;
|
|
|
|
rc = SQLBindCol(hstmt, 12, SQL_C_CHAR, (SQLPOINTER) fkey_name.s, 129,
|
|
&fkey_name.ind);
|
|
CHECK_HANDLE( SQL_HANDLE_STMT, hstmt, rc ) ;
|
|
|
|
rc = SQLBindCol(hstmt, 13, SQL_C_CHAR, (SQLPOINTER) pkey_name.s, 129,
|
|
&pkey_name.ind);
|
|
CHECK_HANDLE( SQL_HANDLE_STMT, hstmt, rc ) ;
|
|
|
|
printf("Primary Key and Foreign Keys for %s.%s\n", schema, tablename);
|
|
/* Fetch each row, and display */
|
|
while ((rc = SQLFetch(hstmt)) == SQL_SUCCESS) {
|
|
printf(" %s %s.%s.%s\n Update Rule ",
|
|
pkcolumn_name.s, fktable_schem.s, fktable_name.s, fkcolumn_name.s);
|
|
if (update_rule == SQL_RESTRICT) {
|
|
printf("RESTRICT "); /* always for IBM DBMSs */
|
|
} else {
|
|
if (update_rule == SQL_CASCADE) {
|
|
printf("CASCADE "); /* non-IBM only */
|
|
} else {
|
|
printf("SET NULL ");
|
|
}
|
|
}
|
|
printf(", Delete Rule: ");
|
|
if (delete_rule== SQL_RESTRICT) {
|
|
printf("RESTRICT "); /* always for IBM DBMSs */
|
|
} else {
|
|
if (delete_rule == SQL_CASCADE) {
|
|
printf("CASCADE "); /* non-IBM only */
|
|
} else {
|
|
if (delete_rule == SQL_NO_ACTION) {
|
|
printf("NO ACTION "); /* non-IBM only */
|
|
} else {
|
|
printf("SET NULL ");
|
|
}
|
|
}
|
|
}
|
|
printf("\n");
|
|
if (pkey_name.ind > 0 ) {
|
|
printf(" Primary Key Name: %s\n", pkey_name.s);
|
|
}
|
|
if (fkey_name.ind > 0 ) {
|
|
printf(" Foreign Key Name: %s\n", fkey_name.s);
|
|
}
|
|
}</pre>
|
|
</div>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">References</h4><div class="p"> <ul><li><a href="rzadpfnpkey.htm#rzadpfnpkey">SQLPrimaryKeys - Get primary key columns of a table</a></li>
|
|
<li><a href="rzadpfnstats.htm#rzadpfnstats">SQLStatistics - Get index and statistics information for a base table</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzadphdapi.htm" title="This topic provides a description of each CLI function.">DB2 UDB CLI functions</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |