242 lines
14 KiB
HTML
242 lines
14 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="SQLTablePrivileges – Get privileges associated with a table" />
|
||
<meta name="DC.subject" content="SQLTablePrivileges, function, description, Get privileges associated with a table" />
|
||
<meta name="keywords" content="SQLTablePrivileges, function, description, Get privileges associated with a table" />
|
||
<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="rzadpfntablpriv" />
|
||
<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>SQLTablePrivileges</title>
|
||
</head>
|
||
<body id="rzadpfntablpriv"><a name="rzadpfntablpriv"><!-- --></a>
|
||
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
<h1 class="topictitle1">SQLTablePrivileges – Get privileges associated with a table</h1>
|
||
<div><div class="section"></div>
|
||
<div class="section"><h4 class="sectiontitle">Purpose</h4> <p><samp class="codeph">SQLTablePrivileges()</samp> returns
|
||
a list of tables and associated privileges for each table. The information
|
||
is returned in an SQL result set, which can be retrieved using the same functions
|
||
that are used to process a result set generated by a query.</p>
|
||
</div>
|
||
<div class="section"><h4 class="sectiontitle">Syntax</h4><pre>SQLRETURN SQLTablePrivileges (SQLHSTMT StatementHandle,
|
||
SQLCHAR *CatalogName,
|
||
SQLSMALLINT NameLength1,
|
||
SQLCHAR *SchemaName,
|
||
SQLSMALLINT NameLength2,
|
||
SQLCHAR *TableName,
|
||
SQLSMALLINT NameLength3);</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. SQLTablePrivileges arguments</caption><thead align="left"><tr><th align="left" valign="top" width="20%" id="d0e55">Data type</th>
|
||
<th align="left" valign="top" width="22.037037037037038%" id="d0e57">Argument</th>
|
||
<th align="left" valign="top" width="17.962962962962965%" id="d0e59">Use</th>
|
||
<th align="left" valign="top" width="40%" id="d0e61">Description</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody><tr><td align="left" valign="top" width="20%" headers="d0e55 ">SQLCHAR *</td>
|
||
<td align="left" valign="top" width="22.037037037037038%" headers="d0e57 "><em>SchemaName</em></td>
|
||
<td align="left" valign="top" width="17.962962962962965%" headers="d0e59 ">Input</td>
|
||
<td align="left" valign="top" width="40%" headers="d0e61 ">Buffer that might contain a <em>pattern-value</em> to
|
||
qualify the result set by schema name.</td>
|
||
</tr>
|
||
<tr><td align="left" valign="top" width="20%" headers="d0e55 ">SQLCHAR *</td>
|
||
<td align="left" valign="top" width="22.037037037037038%" headers="d0e57 "><em>szTableQualifier</em></td>
|
||
<td align="left" valign="top" width="17.962962962962965%" headers="d0e59 ">Input</td>
|
||
<td align="left" valign="top" width="40%" headers="d0e61 ">Catalog qualifier of a 3 part table name.
|
||
This must be a null pointer or a zero length string.</td>
|
||
</tr>
|
||
<tr><td align="left" valign="top" width="20%" headers="d0e55 ">SQLCHAR *</td>
|
||
<td align="left" valign="top" width="22.037037037037038%" headers="d0e57 "><em>TableName</em></td>
|
||
<td align="left" valign="top" width="17.962962962962965%" headers="d0e59 ">Input</td>
|
||
<td align="left" valign="top" width="40%" headers="d0e61 ">Buffer that might contain a <em>pattern-value</em> to
|
||
qualify the result set by table name.</td>
|
||
</tr>
|
||
<tr><td align="left" valign="top" width="20%" headers="d0e55 ">SQLHSTMT</td>
|
||
<td align="left" valign="top" width="22.037037037037038%" headers="d0e57 "><em>StatementHandle</em></td>
|
||
<td align="left" valign="top" width="17.962962962962965%" headers="d0e59 ">Input</td>
|
||
<td align="left" valign="top" width="40%" headers="d0e61 ">Statement handle.</td>
|
||
</tr>
|
||
<tr><td align="left" valign="top" width="20%" headers="d0e55 ">SQLSMALLINT</td>
|
||
<td align="left" valign="top" width="22.037037037037038%" headers="d0e57 "><em>cbTableQualifier</em></td>
|
||
<td align="left" valign="top" width="17.962962962962965%" headers="d0e59 ">Input</td>
|
||
<td align="left" valign="top" width="40%" headers="d0e61 ">Length of <em>CatalogName.</em> This must be
|
||
set to 0.</td>
|
||
</tr>
|
||
<tr><td align="left" valign="top" width="20%" headers="d0e55 ">SQLSMALLINT</td>
|
||
<td align="left" valign="top" width="22.037037037037038%" headers="d0e57 "><em>NameLength2</em></td>
|
||
<td align="left" valign="top" width="17.962962962962965%" headers="d0e59 ">Input</td>
|
||
<td align="left" valign="top" width="40%" headers="d0e61 ">Length of <em>SchemaName.</em></td>
|
||
</tr>
|
||
<tr><td align="left" valign="top" width="20%" headers="d0e55 ">SQLSMALLINT</td>
|
||
<td align="left" valign="top" width="22.037037037037038%" headers="d0e57 "><em>NameLength3</em></td>
|
||
<td align="left" valign="top" width="17.962962962962965%" headers="d0e59 ">Input</td>
|
||
<td align="left" valign="top" width="40%" headers="d0e61 ">Length of <em>TableName.</em></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<div class="section"><h4 class="sectiontitle">Usage</h4><p>The results are returned as a standard result
|
||
set containing the columns listed in the following table. The result set is
|
||
ordered by TABLE_CAT, TABLE_SCHEM, TABLE_NAME, and PRIVILEGE. If multiple
|
||
privileges are associated with any given table, each privilege is returned
|
||
as a separate row.</p>
|
||
<p>The granularity of each privilege reported here might
|
||
or might not apply at the column level; for example, for some data sources,
|
||
if a table can be updated, every column in that table can also be updated.
|
||
For other data sources, the application must call <samp class="codeph">SQLColumnPrivileges()</samp> to
|
||
discover if the individual columns have the same table privileges.</p>
|
||
<p>Because
|
||
calls to <samp class="codeph">SQLColumnPrivileges()</samp> in many cases map to a complex
|
||
and thus expensive query against the system catalog, they should be used sparingly,
|
||
and the results saved rather than repeating calls.</p>
|
||
<p>The
|
||
VARCHAR columns of the catalog functions result set have been declared with
|
||
a maximum length attribute of 128 to be consistent with SQL92 limits. Because DB2<sup>®</sup> names
|
||
are less than 128, the application can choose to always set aside 128 characters
|
||
(plus the null-terminator) for the output buffer, or alternatively, call <samp class="codeph">SQLGetInfo()</samp> with
|
||
SQL_MAX_CATALOG_NAME_LEN, SQL_MAX_SCHEMA_NAME_LEN, SQL_MAX_TABLE_NAME_LEN,
|
||
and SQL_MAX_COLUMN_NAME_LEN. The SQL_MAX_CATALOG_NAME_LEN value determines
|
||
the actual length of the TABLE_CAT supported by the connected DBMS. The SQL_MAX_SCHEMA_NAME_LEN
|
||
value determines the actual length of the TABLE_SCHEM supported by the connected
|
||
Database Management System (DBMS). The SQL_MAX_TABLE_NAME_LEN value determines
|
||
the actual length of the TABLE_NAME supported by the connected DBMS. The SQL_MAX_COLUMN_NAME_LEN
|
||
value determines the actual length of the COLUMN_NAME supported
|
||
by the connected DBMS.</p>
|
||
<p>Although new columns can be added and the names
|
||
of the existing columns changed in future releases, the position of the current
|
||
columns does not change.</p>
|
||
<div class="p">
|
||
<div class="tablenoborder"><a name="rzadpfntablpriv__rstablpriv"><!-- --></a><table cellpadding="4" cellspacing="0" summary="" id="rzadpfntablpriv__rstablpriv" width="100%" frame="hsides" border="1" rules="all"><caption>Table 2. Columns returned by SQLTablePrivileges</caption><thead align="left"><tr><th align="left" valign="top" width="25%" id="d0e184">Column name</th>
|
||
<th align="left" valign="top" width="25%" id="d0e186">Data type</th>
|
||
<th align="left" valign="top" width="50%" id="d0e188">Description</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody><tr><td align="left" valign="top" width="25%" headers="d0e184 ">GRANTEE</td>
|
||
<td align="left" valign="top" width="25%" headers="d0e186 ">VARCHAR(128)</td>
|
||
<td align="left" valign="top" width="50%" headers="d0e188 ">Authorization ID of the user to whom the
|
||
privilege is granted.</td>
|
||
</tr>
|
||
<tr><td align="left" valign="top" width="25%" headers="d0e184 ">GRANTOR</td>
|
||
<td align="left" valign="top" width="25%" headers="d0e186 ">VARCHAR(128)</td>
|
||
<td align="left" valign="top" width="50%" headers="d0e188 ">Authorization ID of the user who granted
|
||
the privilege.</td>
|
||
</tr>
|
||
<tr><td align="left" valign="top" width="25%" headers="d0e184 ">IS_GRANTABLE</td>
|
||
<td align="left" valign="top" width="25%" headers="d0e186 ">VARCHAR(3)</td>
|
||
<td align="left" valign="top" width="50%" headers="d0e188 "> <p>Indicates whether the grantee is permitted
|
||
to grant the privilege to other users.</p>
|
||
<p>This can be "YES", "NO" or "NULL".</p>
|
||
</td>
|
||
</tr>
|
||
<tr><td align="left" valign="top" width="25%" headers="d0e184 ">PRIVILEGE</td>
|
||
<td align="left" valign="top" width="25%" headers="d0e186 ">VARCHAR(128)</td>
|
||
<td align="left" valign="top" width="50%" headers="d0e188 ">The table privilege. This can be one of the
|
||
following strings: <ul><li>ALTER</li>
|
||
<li>CONTROL</li>
|
||
<li>INDEX</li>
|
||
<li>DELETE</li>
|
||
<li>INSERT</li>
|
||
<li>REFERENCES</li>
|
||
<li>SELECT</li>
|
||
<li>UPDATE</li>
|
||
</ul>
|
||
</td>
|
||
</tr>
|
||
<tr><td align="left" valign="top" width="25%" headers="d0e184 ">TABLE_CAT</td>
|
||
<td align="left" valign="top" width="25%" headers="d0e186 ">VARCHAR(128)</td>
|
||
<td align="left" valign="top" width="50%" headers="d0e188 ">This is always null.</td>
|
||
</tr>
|
||
<tr><td align="left" valign="top" width="25%" headers="d0e184 ">TABLE_NAME</td>
|
||
<td align="left" valign="top" width="25%" headers="d0e186 ">VARCHAR(128) not NULL</td>
|
||
<td align="left" valign="top" width="50%" headers="d0e188 ">The name of the table.</td>
|
||
</tr>
|
||
<tr><td align="left" valign="top" width="25%" headers="d0e184 ">TABLE_SCHEM</td>
|
||
<td align="left" valign="top" width="25%" headers="d0e186 ">VARCHAR(128)</td>
|
||
<td align="left" valign="top" width="50%" headers="d0e188 ">The name of the schema containing TABLE_NAME.</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<p>Note: The column names used by DB2 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">SQLProcedures()</samp> result set in ODBC.</p>
|
||
</div>
|
||
<div class="section"><h4 class="sectiontitle">Return codes</h4><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 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. SQLTablePrivileges SQLSTATEs</caption><thead align="left"><tr><th align="left" valign="top" width="25%" id="d0e298">SQLSTATE</th>
|
||
<th align="left" valign="top" width="25%" id="d0e300">Description</th>
|
||
<th align="left" valign="top" width="50%" id="d0e302">Explanation</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody><tr><td align="left" valign="top" width="25%" headers="d0e298 "><strong>HY</strong>001</td>
|
||
<td align="left" valign="top" width="25%" headers="d0e300 ">Memory allocation failure</td>
|
||
<td align="left" valign="top" width="50%" headers="d0e302 ">The driver is unable to allocate memory required
|
||
to support the processing or completion of the function.</td>
|
||
</tr>
|
||
<tr><td align="left" valign="top" width="25%" headers="d0e298 "><strong>HY</strong>009</td>
|
||
<td align="left" valign="top" width="25%" headers="d0e300 ">String or buffer length that is not valid</td>
|
||
<td align="left" valign="top" width="50%" headers="d0e302 ">The value of one of the name length arguments
|
||
is less than 0, but not equal SQL_NTS.</td>
|
||
</tr>
|
||
<tr><td align="left" valign="top" width="25%" headers="d0e298 "><strong>HY</strong>010</td>
|
||
<td align="left" valign="top" width="25%" headers="d0e300 ">Function sequence error</td>
|
||
<td align="left" valign="top" width="50%" headers="d0e302 ">There is an open cursor for this statement
|
||
handle, or there is no connection for this statement handle. </td>
|
||
</tr>
|
||
<tr><td valign="top" width="25%" headers="d0e298 "><strong>HY</strong>021</td>
|
||
<td valign="top" width="25%" headers="d0e300 ">Internal descriptor that is not valid </td>
|
||
<td valign="top" width="50%" headers="d0e302 ">The internal descriptor cannot be addressed or allocated,
|
||
or it contains a value that is not valid.</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"><pre>/* From the CLI sample TBINFO.C */
|
||
/* ... */
|
||
|
||
/* call SQLTablePrivileges */
|
||
printf("\n Call SQLTablePrivileges for:\n");
|
||
printf(" tbSchemaPattern = %s\n", tbSchemaPattern);
|
||
printf(" tbNamePattern = %s\n", tbNamePattern);
|
||
sqlrc = SQLTablePrivileges( hstmt, NULL, 0,
|
||
tbSchemaPattern, SQL_NTS,
|
||
tbNamePattern, SQL_NTS);
|
||
STMT_HANDLE_CHECK( hstmt, sqlrc);</pre>
|
||
</div>
|
||
<div class="section"><h4 class="sectiontitle">References</h4> </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> |