summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/ecpg-sql-get-descriptor.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 13:44:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 13:44:03 +0000
commit293913568e6a7a86fd1479e1cff8e2ecb58d6568 (patch)
treefc3b469a3ec5ab71b36ea97cc7aaddb838423a0c /doc/src/sgml/html/ecpg-sql-get-descriptor.html
parentInitial commit. (diff)
downloadpostgresql-16-293913568e6a7a86fd1479e1cff8e2ecb58d6568.tar.xz
postgresql-16-293913568e6a7a86fd1479e1cff8e2ecb58d6568.zip
Adding upstream version 16.2.upstream/16.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'doc/src/sgml/html/ecpg-sql-get-descriptor.html')
-rw-r--r--doc/src/sgml/html/ecpg-sql-get-descriptor.html104
1 files changed, 104 insertions, 0 deletions
diff --git a/doc/src/sgml/html/ecpg-sql-get-descriptor.html b/doc/src/sgml/html/ecpg-sql-get-descriptor.html
new file mode 100644
index 0000000..8c5f60a
--- /dev/null
+++ b/doc/src/sgml/html/ecpg-sql-get-descriptor.html
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>GET DESCRIPTOR</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="ecpg-sql-execute-immediate.html" title="EXECUTE IMMEDIATE" /><link rel="next" href="ecpg-sql-open.html" title="OPEN" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">GET DESCRIPTOR</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="ecpg-sql-execute-immediate.html" title="EXECUTE IMMEDIATE">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="ecpg-sql-commands.html" title="36.14. Embedded SQL Commands">Up</a></td><th width="60%" align="center">36.14. Embedded SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.2 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="ecpg-sql-open.html" title="OPEN">Next</a></td></tr></table><hr /></div><div class="refentry" id="ECPG-SQL-GET-DESCRIPTOR"><div class="titlepage"></div><div class="refnamediv"><h2>GET DESCRIPTOR</h2><p>GET DESCRIPTOR — get information from an SQL descriptor area</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
+GET DESCRIPTOR <em class="replaceable"><code>descriptor_name</code></em> <em class="replaceable"><code>:cvariable</code></em> = <em class="replaceable"><code>descriptor_header_item</code></em> [, ... ]
+GET DESCRIPTOR <em class="replaceable"><code>descriptor_name</code></em> VALUE <em class="replaceable"><code>column_number</code></em> <em class="replaceable"><code>:cvariable</code></em> = <em class="replaceable"><code>descriptor_item</code></em> [, ... ]
+</pre></div><div class="refsect1" id="id-1.7.5.20.11.3"><h2>Description</h2><p>
+ <code class="command">GET DESCRIPTOR</code> retrieves information about a
+ query result set from an SQL descriptor area and stores it into
+ host variables. A descriptor area is typically populated
+ using <code class="command">FETCH</code> or <code class="command">SELECT</code>
+ before using this command to transfer the information into host
+ language variables.
+ </p><p>
+ This command has two forms: The first form retrieves
+ descriptor <span class="quote">“<span class="quote">header</span>”</span> items, which apply to the result
+ set in its entirety. One example is the row count. The second
+ form, which requires the column number as additional parameter,
+ retrieves information about a particular column. Examples are
+ the column name and the actual column value.
+ </p></div><div class="refsect1" id="id-1.7.5.20.11.4"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt id="ECPG-SQL-GET-DESCRIPTOR-DESCRIPTOR-NAME"><span class="term"><em class="replaceable"><code>descriptor_name</code></em></span> <a href="#ECPG-SQL-GET-DESCRIPTOR-DESCRIPTOR-NAME" class="id_link">#</a></dt><dd><p>
+ A descriptor name.
+ </p></dd><dt id="ECPG-SQL-GET-DESCRIPTOR-DESCRIPTOR-HEADER-ITEM"><span class="term"><em class="replaceable"><code>descriptor_header_item</code></em></span> <a href="#ECPG-SQL-GET-DESCRIPTOR-DESCRIPTOR-HEADER-ITEM" class="id_link">#</a></dt><dd><p>
+ A token identifying which header information item to retrieve.
+ Only <code class="literal">COUNT</code>, to get the number of columns in the
+ result set, is currently supported.
+ </p></dd><dt id="ECPG-SQL-GET-DESCRIPTOR-COLUMN-NUMBER"><span class="term"><em class="replaceable"><code>column_number</code></em></span> <a href="#ECPG-SQL-GET-DESCRIPTOR-COLUMN-NUMBER" class="id_link">#</a></dt><dd><p>
+ The number of the column about which information is to be
+ retrieved. The count starts at 1.
+ </p></dd><dt id="ECPG-SQL-GET-DESCRIPTOR-DESCRIPTOR-ITEM"><span class="term"><em class="replaceable"><code>descriptor_item</code></em></span> <a href="#ECPG-SQL-GET-DESCRIPTOR-DESCRIPTOR-ITEM" class="id_link">#</a></dt><dd><p>
+ A token identifying which item of information about a column
+ to retrieve. See <a class="xref" href="ecpg-descriptors.html#ECPG-NAMED-DESCRIPTORS" title="36.7.1. Named SQL Descriptor Areas">Section 36.7.1</a> for
+ a list of supported items.
+ </p></dd><dt id="ECPG-SQL-GET-DESCRIPTOR-CVARIABLE"><span class="term"><em class="replaceable"><code>cvariable</code></em></span> <a href="#ECPG-SQL-GET-DESCRIPTOR-CVARIABLE" class="id_link">#</a></dt><dd><p>
+ A host variable that will receive the data retrieved from the
+ descriptor area.
+ </p></dd></dl></div></div><div class="refsect1" id="id-1.7.5.20.11.5"><h2>Examples</h2><p>
+ An example to retrieve the number of columns in a result set:
+</p><pre class="programlisting">
+EXEC SQL GET DESCRIPTOR d :d_count = COUNT;
+</pre><p>
+ </p><p>
+ An example to retrieve a data length in the first column:
+</p><pre class="programlisting">
+EXEC SQL GET DESCRIPTOR d VALUE 1 :d_returned_octet_length = RETURNED_OCTET_LENGTH;
+</pre><p>
+ </p><p>
+ An example to retrieve the data body of the second column as a
+ string:
+</p><pre class="programlisting">
+EXEC SQL GET DESCRIPTOR d VALUE 2 :d_data = DATA;
+</pre><p>
+ </p><p>
+ Here is an example for a whole procedure of
+ executing <code class="literal">SELECT current_database();</code> and showing the number of
+ columns, the column data length, and the column data:
+</p><pre class="programlisting">
+int
+main(void)
+{
+EXEC SQL BEGIN DECLARE SECTION;
+ int d_count;
+ char d_data[1024];
+ int d_returned_octet_length;
+EXEC SQL END DECLARE SECTION;
+
+ EXEC SQL CONNECT TO testdb AS con1 USER testuser;
+ EXEC SQL SELECT pg_catalog.set_config('search_path', '', false); EXEC SQL COMMIT;
+ EXEC SQL ALLOCATE DESCRIPTOR d;
+
+ /* Declare, open a cursor, and assign a descriptor to the cursor */
+ EXEC SQL DECLARE cur CURSOR FOR SELECT current_database();
+ EXEC SQL OPEN cur;
+ EXEC SQL FETCH NEXT FROM cur INTO SQL DESCRIPTOR d;
+
+ /* Get a number of total columns */
+ EXEC SQL GET DESCRIPTOR d :d_count = COUNT;
+ printf("d_count = %d\n", d_count);
+
+ /* Get length of a returned column */
+ EXEC SQL GET DESCRIPTOR d VALUE 1 :d_returned_octet_length = RETURNED_OCTET_LENGTH;
+ printf("d_returned_octet_length = %d\n", d_returned_octet_length);
+
+ /* Fetch the returned column as a string */
+ EXEC SQL GET DESCRIPTOR d VALUE 1 :d_data = DATA;
+ printf("d_data = %s\n", d_data);
+
+ /* Closing */
+ EXEC SQL CLOSE cur;
+ EXEC SQL COMMIT;
+
+ EXEC SQL DEALLOCATE DESCRIPTOR d;
+ EXEC SQL DISCONNECT ALL;
+
+ return 0;
+}
+</pre><p>
+ When the example is executed, the result will look like this:
+</p><pre class="screen">
+d_count = 1
+d_returned_octet_length = 6
+d_data = testdb
+</pre><p>
+ </p></div><div class="refsect1" id="id-1.7.5.20.11.6"><h2>Compatibility</h2><p>
+ <code class="command">GET DESCRIPTOR</code> is specified in the SQL standard.
+ </p></div><div class="refsect1" id="id-1.7.5.20.11.7"><h2>See Also</h2><span class="simplelist"><a class="xref" href="ecpg-sql-allocate-descriptor.html" title="ALLOCATE DESCRIPTOR">ALLOCATE DESCRIPTOR</a>, <a class="xref" href="ecpg-sql-set-descriptor.html" title="SET DESCRIPTOR">SET DESCRIPTOR</a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ecpg-sql-execute-immediate.html" title="EXECUTE IMMEDIATE">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ecpg-sql-commands.html" title="36.14. Embedded SQL Commands">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ecpg-sql-open.html" title="OPEN">Next</a></td></tr><tr><td width="40%" align="left" valign="top">EXECUTE IMMEDIATE </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.2 Documentation">Home</a></td><td width="40%" align="right" valign="top"> OPEN</td></tr></table></div></body></html> \ No newline at end of file