260 lines
15 KiB
HTML
260 lines
15 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="SQLColumnPrivileges - Get privileges associated with the columns of 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="rzadpfncolnpriv" />
|
|
<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>SQLColumnPrivileges - Get privileges associated with the columns of
|
|
a table</title>
|
|
</head>
|
|
<body id="rzadpfncolnpriv"><a name="rzadpfncolnpriv"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">SQLColumnPrivileges - Get privileges associated with the columns of
|
|
a table</h1>
|
|
<div><div class="section"></div>
|
|
<div class="section"><h4 class="sectiontitle">Purpose</h4> <p><samp class="codeph">SQLColumnPrivileges()</samp> returns
|
|
a list of columns and associated privileges for the specified 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 from a query.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Syntax</h4><pre>SQLRETURN SQLColumnPrivileges (
|
|
SQLHSTMT StatementHandle,
|
|
SQLCHAR *CatalogName,
|
|
SQLSMALLINT NameLength1,
|
|
SQLCHAR *SchemaName,
|
|
SQLSMALLINT NameLength2,
|
|
SQLCHAR *TableName
|
|
SQLSMALLINT NameLength3,
|
|
SQLCHAR *ColumnName,
|
|
SQLSMALLINT NameLength4); </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. SQLColumnPrivileges arguments</caption><thead align="left"><tr><th align="left" valign="bottom" width="20%" id="d0e46">Data type</th>
|
|
<th align="left" valign="bottom" width="20%" id="d0e48">Argument</th>
|
|
<th align="left" valign="bottom" width="20%" id="d0e50">Use</th>
|
|
<th align="left" valign="bottom" width="40%" id="d0e52">Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="20%" headers="d0e46 ">SQLHSTMT</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e48 "><em>Statement Handle</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e50 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e52 ">Statement handle.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e46 ">SQLCHAR *</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e48 "><em>CatalogName</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e50 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e52 ">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="d0e46 ">SQLSMALLINT</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e48 "><em>NameLength1</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e50 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e52 ">Length of <em>CatalogName</em>. This must be
|
|
set to 0.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e46 ">SQLCHAR *</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e48 "><em>SchemaName</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e50 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e52 ">Schema qualifier of table name.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e46 ">SQLSMALLINT</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e48 "><em>NameLength2</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e50 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e52 ">Length of <em>SchemaName</em>.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e46 ">SQLCHAR *</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e48 "><em>TableName</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e50 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e52 ">Table Name.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e46 ">SQLSMALLINT</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e48 "><em>NameLength3</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e50 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e52 ">Length of <em>TableName.</em></td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e46 ">SQLCHAR *</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e48 "><em>ColumnName</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e50 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e52 ">Buffer that can contain a <em>pattern-value</em> to
|
|
qualify the result set by column name.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="20%" headers="d0e46 ">SQLSMALLINT</td>
|
|
<td align="left" valign="top" width="20%" headers="d0e48 "><em>NameLength4</em></td>
|
|
<td align="left" valign="top" width="20%" headers="d0e50 ">Input</td>
|
|
<td align="left" valign="top" width="40%" headers="d0e52 ">Length of <em>ColumnName.</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 <a href="#rzadpfncolnpriv__tbcolpriv">Table 2</a>.
|
|
The result set is ordered by TABLE_CAT, TABLE_SCHEM, TABLE_NAME, COLUMN_NAME,
|
|
and PRIVILEGE. If multiple privileges are associated with any given column,
|
|
each privilege is returned as a separate row. A typical application might
|
|
want to call this function after a call to <samp class="codeph">SQLColumns()</samp> to
|
|
determine column privilege information. The application should use the character
|
|
strings returned in the TABLE_SCHEM, TABLE_NAME, COLUMN_NAME columns of the <samp class="codeph">SQLColumns()</samp> result
|
|
set as input arguments to this function</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
|
|
the 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 Database Management
|
|
System (DBMS). The SQL_MAX_SCHEMA_NAME_LEN value determines the actual length
|
|
of the TABLE_SCHEM supported by the connected 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>Note that the <em>ColumnName</em> argument
|
|
accepts a search pattern.</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="rzadpfncolnpriv__tbcolpriv"><!-- --></a><table cellpadding="4" cellspacing="0" summary="" id="rzadpfncolnpriv__tbcolpriv" width="100%" frame="hsides" border="1" rules="all"><caption>Table 2. Columns returned by SQLColumnPrivileges</caption><thead align="left"><tr><th align="left" valign="top" width="27.59259259259259%" id="d0e204">Column number/name</th>
|
|
<th align="left" valign="top" width="25.555555555555554%" id="d0e206">Data type</th>
|
|
<th align="left" valign="top" width="46.85185185185185%" id="d0e208">Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="27.59259259259259%" headers="d0e204 ">COLUMN_NAME</td>
|
|
<td align="left" valign="top" width="25.555555555555554%" headers="d0e206 ">VARCHAR(128) not NULL</td>
|
|
<td align="left" valign="top" width="46.85185185185185%" headers="d0e208 ">Name of the column of the specified table
|
|
or view.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="27.59259259259259%" headers="d0e204 ">GRANTEE</td>
|
|
<td align="left" valign="top" width="25.555555555555554%" headers="d0e206 ">VARCHAR(128)</td>
|
|
<td align="left" valign="top" width="46.85185185185185%" headers="d0e208 ">Authorization ID of the user to whom the
|
|
privilege is granted.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="27.59259259259259%" headers="d0e204 ">GRANTOR</td>
|
|
<td align="left" valign="top" width="25.555555555555554%" headers="d0e206 ">VARCHAR(128)</td>
|
|
<td align="left" valign="top" width="46.85185185185185%" headers="d0e208 ">Authorization ID of the user who granted
|
|
the privilege.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="27.59259259259259%" headers="d0e204 ">IS_GRANTABLE</td>
|
|
<td align="left" valign="top" width="25.555555555555554%" headers="d0e206 ">VARCHAR(3)</td>
|
|
<td align="left" valign="top" width="46.85185185185185%" headers="d0e208 "> <p>Indicates whether the grantee is permitted
|
|
to grant the privilege to other users.</p>
|
|
<p>Either YES or NO.</p>
|
|
</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="27.59259259259259%" headers="d0e204 ">PRIVILEGE</td>
|
|
<td align="left" valign="top" width="25.555555555555554%" headers="d0e206 ">VARCHAR(128)</td>
|
|
<td align="left" valign="top" width="46.85185185185185%" headers="d0e208 ">The column privilege. This can be: <ul><li>INSERT</li>
|
|
<li>REFERENCES</li>
|
|
<li>SELECT</li>
|
|
<li>UPDATE</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="27.59259259259259%" headers="d0e204 ">TABLE_CAT</td>
|
|
<td align="left" valign="top" width="25.555555555555554%" headers="d0e206 ">VARCHAR(128)</td>
|
|
<td align="left" valign="top" width="46.85185185185185%" headers="d0e208 ">This is always NULL.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="27.59259259259259%" headers="d0e204 ">TABLE_NAME</td>
|
|
<td align="left" valign="top" width="25.555555555555554%" headers="d0e206 ">VARCHAR(128) not NULL</td>
|
|
<td align="left" valign="top" width="46.85185185185185%" headers="d0e208 ">Name of the table or view.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="27.59259259259259%" headers="d0e204 ">TABLE_SCHEM</td>
|
|
<td align="left" valign="top" width="25.555555555555554%" headers="d0e206 ">VARCHAR(128)</td>
|
|
<td align="left" valign="top" width="46.85185185185185%" headers="d0e208 ">The name of the schema containing TABLE_NAME.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="note"><span class="notetitle">Note:</span> 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">SQLColumnPrivileges()</samp> result set in ODBC.</div>
|
|
<p>If
|
|
there is more than one privilege associated with a column, then each privilege
|
|
is returned as a separate row in the result set.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Return codes</h4><ul><li>SQL_SUCCESS</li>
|
|
<li>SQL_SUCCESS_WITH_INFO</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. SQLColumnPrivileges SQLSTATEs</caption><thead align="left"><tr><th align="left" valign="top" id="d0e317">SQLSTATE</th>
|
|
<th align="left" valign="top" id="d0e319">Description</th>
|
|
<th align="left" valign="top" id="d0e321">Explanation</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" headers="d0e317 "><strong>HY</strong>001</td>
|
|
<td align="left" valign="top" headers="d0e319 ">Memory allocation failure</td>
|
|
<td align="left" valign="top" headers="d0e321 ">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" headers="d0e317 "><strong>HY</strong>009</td>
|
|
<td align="left" valign="top" headers="d0e319 ">String or buffer length that is not valid</td>
|
|
<td align="left" valign="top" headers="d0e321 ">The value of one of the name length arguments
|
|
is less than 0, but not equal to SQL_NTS.</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" headers="d0e317 "><strong>HY</strong>010</td>
|
|
<td align="left" valign="top" headers="d0e319 ">Function sequence error</td>
|
|
<td align="left" valign="top" headers="d0e321 ">There is an open cursor for this statement
|
|
handle, or there is no connection for this statement handle. </td>
|
|
</tr>
|
|
<tr><td valign="top" headers="d0e317 "><strong>HY</strong>021</td>
|
|
<td valign="top" headers="d0e319 ">Internal descriptor that is not valid</td>
|
|
<td valign="top" headers="d0e321 ">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 SQLColumnPrivileges */
|
|
printf("\n Call SQLColumnPrivileges for:\n");
|
|
printf(" tbSchema = %s\n", tbSchema);
|
|
printf(" tbName = %s\n", tbName);
|
|
sqlrc = SQLColumnPrivileges( hstmt, NULL, 0,
|
|
tbSchema, SQL_NTS,
|
|
tbName, SQL_NTS,
|
|
colNamePattern, SQL_NTS);</pre>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">References</h4><ul><li><a href="rzadpfncoln.htm#rzadpfncoln">SQLColumns - Get column information for a table</a></li>
|
|
<li><a href="rzadpfntabls.htm#rzadpfntabls">SQLTables - Get table information</a></li>
|
|
</ul>
|
|
</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> |