1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
project.
Copyright (C) 1998-2018 OpenLink Software
This project is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; only version 2 of the License, dated June 1991.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-->
<refentry id="fn_exec_metadata">
<refmeta>
<refentrytitle>exec_metadata</refentrytitle>
<refmiscinfo>sql</refmiscinfo>
</refmeta>
<refnamediv>
<refname>exec_metadata</refname>
<refpurpose>Compiles a SQL statement and returns the metadata</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis id="fsyn_exec_metadata">
<funcprototype id="fproto_exec_metadata">
<funcdef><function>exec_metadata</function></funcdef>
<paramdef>in <parameter>str</parameter> varchar</paramdef>
<paramdef>out <parameter>state</parameter> varchar</paramdef>
<paramdef>out <parameter>message</parameter> varchar</paramdef>
<paramdef>out <parameter>metadata</parameter> vector</paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1 id="desc_exec_metadata">
<title>Description</title>
<para>This function provides dynamic SQL capabilities in Virtuoso PL.
The first argument is an arbitrary SQL statement, which may contain
parameter placeholders. The function returns as output parameters a
SQL state, error message, column metadata if the statement is a select.</para>
</refsect1>
<refsect1 id="params_exec_metadata">
<title>Parameters</title>
<refsect2><title><parameter>str</parameter></title>
<para>A <type>varchar</type> containing arbitrary SQL using ?'s for parameter markers.</para>
</refsect2>
<refsect2><title>state</title>
<para>An output parameter of type <type>varchar</type> set to the 5 character SQL state if the exec resulted an error. Not set if an error is not present.</para>
</refsect2>
<refsect2><title>message</title>
<para>An output parameter of type <type>varchar</type> set to SQL error message associated with the error. Not set if an error is not present.</para>
</refsect2>
<refsect2><title>metadata</title>
<para>An output parameter of type <type>vector</type> returning the metadata of the statement and its result.</para>
<table><title>The stmt_meta array</title>
<tgroup cols="3">
<thead><row><entry>Element</entry><entry>Name</entry><entry>Description</entry></row></thead>
<tbody>
<row>
<entry>0</entry>
<entry>COLS</entry>
<entry>An array containing description of each column in the result
set (see table below for contents)</entry>
</row>
<row>
<entry>1</entry>
<entry>STMT_SELECT</entry>
<entry>An <type>integer</type> 1 indicates that the statement is a
select, otherwise it is a DML statement.</entry>
</row>
<row>
<entry>2..</entry>
<entry>N/A</entry>
<entry>Trailing elements may appear, but they should not be used</entry>
</row>
</tbody>
</tgroup>
</table>
<table><title>Columns array of metadata</title>
<tgroup cols="3">
<thead><row><entry>Element</entry><entry>Name</entry><entry>Description</entry></row></thead>
<tbody>
<row>
<entry>0</entry><entry>name</entry><entry>Column name</entry>
</row>
<row>
<entry>1</entry>
<entry>type</entry>
<entry>Column type as an internal type code corresponding,
but not equal to ODBC SQL type codes.</entry>
</row>
<row>
<entry>2</entry>
<entry>scale</entry>
<entry>column scale</entry>
</row>
<row>
<entry>3</entry>
<entry>precision</entry>
<entry>column precision</entry>
</row>
<row>
<entry>4</entry>
<entry>nullable</entry>
<entry>indicates nullable column</entry>
</row>
<row>
<entry>5</entry>
<entry>updatable</entry>
<entry>indicates updatable column</entry>
</row>
<row>
<entry>6</entry>
<entry>searchable</entry>
<entry>indicates searchable column</entry>
</row>
</tbody>
</tgroup>
</table>
</refsect2>
</refsect1>
<refsect1 id="errors_exec_metadata">
<title>Errors</title>
<!-- In case of non-function-specific errors, i.e. only common
parameter errors are signalled, comment out the table below
otherwise add the unique error values as individual errorcodes -->
<para>
The function will generate a SQL 22023 error value if a supplied parameter is not of the type expected.
</para>
<tip>
<title>See Also:</title>
<para>
<link linkend="errors">List of SQL 22023 errors.</link>
</para>
</tip>
</refsect1>
<refsect1 id="examples_exec_metadata">
<title>Examples</title>
<example id="ex_exec_metadata"><title>Simple Use</title>
<screen><![CDATA[
create procedure get_meta (in str varchar)
{
declare state, message, mdta any;
state := '00000';
exec_metadata (str, state, message, mdta);
if (state <> '00000')
signal (state, message);
return mdta;
}
]]>
</screen>
</example>
</refsect1>
<refsect1 id="seealso_exec_metadata">
<title>See Also</title>
<para><link linkend="fn_exec"><function>exec()</function></link></para>
<para><link linkend="fn_exec_next"><function>exec_next()</function></link></para>
<para><link linkend="fn_exec_close"><function>exec_close()</function></link></para>
</refsect1>
</refentry>
|