Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 71d40963b505df4524269198e237b3e3 > files > 882

virtuoso-opensource-doc-6.1.4-2.fc14.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head profile="http://internetalchemy.org/2003/02/profile">
  <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" />
  <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />
  <meta name="dc.title" content="9. SQL Procedure Language Guide" />
  <meta name="dc.subject" content="9. SQL Procedure Language Guide" />
  <meta name="dc.creator" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" />
  <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="parent" href="sqlprocedures.html" title="Chapter Contents" />
  <link rel="prev" href="SCOPEOFDECLARATION.html" title="Scope of Declarations" />
  <link rel="next" href="RESULTSETS.html" title="Handling Result Sets" />
  <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" type="text/css" href="doc.css" />
  <link rel="stylesheet" type="text/css" href="/doc/translation.css" />
  <title>9. SQL Procedure Language Guide</title>
  <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
  <meta name="author" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="copyright" content="OpenLink Software, 1999 - 2009" />
  <meta name="keywords" content="" />
  <meta name="GENERATOR" content="OpenLink XSLT Team" />
 </head>
 <body>
  <div id="header">
    <a name="sqlplDATATYPES" />
    <img src="../images/misc/logo.jpg" alt="" />
    <h1>9. SQL Procedure Language Guide</h1>
  </div>
  <div id="navbartop">
   <div>
      <a class="link" href="sqlprocedures.html">Chapter Contents</a> | <a class="link" href="SCOPEOFDECLARATION.html" title="Scope of Declarations">Prev</a> | <a class="link" href="RESULTSETS.html" title="Handling Result Sets">Next</a>
   </div>
  </div>
  <div id="currenttoc">
   <form method="post" action="/doc/adv_search.vspx">
    <div class="search">Keyword Search: <br />
        <input type="text" name="q" /> <input type="submit" name="go" value="Go" />
    </div>
   </form>
   <div>
      <a href="http://www.openlinksw.com/">www.openlinksw.com</a>
   </div>
   <div>
      <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a>
   </div>
    <br />
   <div>
      <a href="index.html">Book Home</a>
   </div>
    <br />
   <div>
      <a href="contents.html">Contents</a>
   </div>
   <div>
      <a href="preface.html">Preface</a>
   </div>
    <br />
   <div class="selected">
      <a href="sqlprocedures.html">SQL Procedure Language Guide</a>
   </div>
    <br />
   <div>
      <a href="GENERALPRINCIPLES.html">General Principles</a>
   </div>
   <div>
      <a href="SCOPEOFDECLARATION.html">Scope of Declarations</a>
   </div>
   <div class="selected">
      <a href="sqlplDATATYPES.html">Data Types</a>
   </div>
   <div>
      <a href="RESULTSETS.html">Handling Result Sets</a>
   </div>
   <div>
      <a href="ARRAYS.html">Result Sets and Array Parameters</a>
   </div>
   <div>
      <a href="EXCEPTIONS.html">Exception Semantics</a>
   </div>
   <div>
      <a href="PLREF.html">Virtuoso/PL Syntax</a>
   </div>
   <div>
      <a href="EXECSQLPROCSELECT.html">Execute Stored Procedures via SELECT statement</a>
   </div>
   <div>
      <a href="EXECSQLPROCFORK.html">Execute Stored Procedures In Background</a>
   </div>
   <div>
      <a href="createassembly.html">CREATE ASSEMBLY Syntax - External Libraries</a>
   </div>
   <div>
      <a href="createexthostproc.html">CREATE PROCEDURE Syntax - External hosted procedures</a>
   </div>
   <div>
      <a href="ASYNCEXECMULTITHREAD.html">Asynchronous Execution and Multithreading in Virtuoso/PL</a>
   </div>
   <div>
      <a href="PERFTIPS.html">Performance Tips</a>
   </div>
   <div>
      <a href="PROCEDURES_TRANSACTIONS.html">Procedures and Transactions</a>
   </div>
   <div>
      <a href="twopcimplementation.html">Distributed Transaction &amp; Two Phase Commit</a>
   </div>
   <div>
      <a href="TRIGGERS.html">Triggers</a>
   </div>
   <div>
      <a href="charescaping.html">Character Escaping</a>
   </div>
   <div>
      <a href="PLSCROLLCRSRS.html">Virtuoso/PL Scrollable Cursors</a>
   </div>
   <div>
      <a href="plmodules.html">Virtuoso PL Modules</a>
   </div>
   <div>
      <a href="handlingplcondit.html">Handling Conditions In Virtuoso/PL Procedures</a>
   </div>
   <div>
      <a href="pldebugger.html">Procedure Language Debugger</a>
   </div>
   <div>
      <a href="rowlevelsecurity.html">Row Level Security</a>
   </div>
    <br />
  </div>
  <div id="text">
		<a name="sqlplDATATYPES" />
    <h2>9.3. Data Types</h2>
		<p>
Virtuoso/PL supports the regular SQL scalar data types as well as user-defined-types
(UDTs).   UDTs and structures can be composed of data types or classes made from
any hosted language such C# or Java.
Local temporary tables are not supported by the present
Virtuoso but may be added in the future.
</p>
		<p>
Memory management is automatic. Parameters, cursors and intermediate
results are automatically allocated and freed.
</p>
		<p>
A parameter or variable can be of any data type a column can. Variables
are however typed at run time, so that the declared type is mostly for
documentation. The declared types also affect how interactive SQL
shows certain values.
</p>
<p>There is a special <span class="computeroutput">vector</span> construct, declared
as type <span class="computeroutput">ANY</span>, that can be used as an array.
Vectors must be instantiated using the <span class="computeroutput">vector()</span> function,
optionally containing initial elements as a comma-separated list, and can
be increased in size using the <span class="computeroutput">vector_concat()</span>.
Elements of a vector are read and changed using the
<a href="fn_aref.html">aref()</a> and
<a href="fn_aset.html">aset()</a> functions
respectively.  A special notation can be used as a short-hand for accessing the
elements of a vector one-level deep only.  The notation is by using the variable
with the index in square brackets.  Hence, <span class="computeroutput">aref(vec, 1)</span> is
the same as <span class="computeroutput">vec[1]</span>.

The following example reveal more:</p>

<a name="ex_vectorcontrol" />
    <div class="example">
      <div class="exampletitle">Using Vectors</div>
<p>Simple excerpt showing how to instantiate a vector.</p>
<div>
        <pre class="programlisting">
declare vec1, vec2, vec3 any;

vec1 := vector();  -- simple empty vector
vec2 := vector(&#39;a&#39;, &#39;b&#39;, 1, 2);  -- vector of mixed types
vec3 := vector(vector(&#39;a&#39;, &#39;b&#39;), vector(1, 2));  -- vector of vectors
</pre>
      </div>

<p>Second-level elements of vec3 cannot be referenced as vec3[1][1].</p>

<p>Here is the code for a simple VSP page that shows how vectors
can be used.</p>

<div>
        <pre class="programlisting">
&lt;html&gt;
 &lt;body&gt;
&lt;?vsp
declare vec1 any;
declare i integer;

vec1 := vector();

http(&#39;loading up the vector using vector_concat...&lt;br&gt;&#39;);
i := 0;
while ( i &lt;= 5 ) {
  vec1 := vector_concat(vec1, vector(i * 5));
  i := i + 1;
}

http(&#39;displaying the contents using aref&lt;br&gt;&#39;);
i := 0;
while ( i &lt;= 5 ) {
  http_value(aref(vec1, i)); http(&#39;&lt;br&gt;&#39;);
  i := i + 1;
}

http(&#39;changing the values using aset&lt;br&gt;&#39;);
i := 0;
while ( i &lt;= 5 ) {
  aset(vec1, i, i * 10);
  i := i + 1;
}

http(&#39;displaying the contents using [] notation&lt;br&gt;&#39;);
i := 0;
while ( i &lt;= 5 ) {
  http_value(vec1[i]); http(&#39;&lt;br&gt;&#39;);
  i := i + 1;
}

http(&#39;changing the values using [] notation&lt;br&gt;&#39;);
i := 0;
while ( i &lt;= 5 ) {
  vec1[i] := i * 15;
  i := i + 1;
}

http(&#39;displaying the contents using [] notation again&lt;br&gt;&#39;);
i := 0;
while ( i &lt;= 5 ) {
  http_value(vec1[i]); http(&#39;&lt;br&gt;&#39;);
  i := i + 1;
}
?&gt;
 &lt;/body&gt;
&lt;/html&gt;
</pre>
      </div>

<p>Which produces the following output:</p>

<div>
        <pre class="screen">
loading up the vector using vector_concat...
displaying the contents using aref
0
5
10
15
20
25
changing the values using aset
displaying the contents using [] notation
0
10
20
30
40
50
changing the values using [] notation
displaying the contents using [] notation again
0
15
30
45
60
75
</pre>
      </div>
</div>

<div class="tip">
      <div class="tiptitle">See Also:</div>
  <p>
        <a href="fn_aref.html">aref()</a>
      </p>
  <p>
        <a href="fn_aset.html">aset()</a>
      </p>
  <p>
        <a href="fn_vector_concat.html">vector_concat()</a>
      </p>
  </div>
	<table border="0" width="90%" id="navbarbottom">
    <tr>
        <td align="left" width="33%">
          <a href="SCOPEOFDECLARATION.html" title="Scope of Declarations">Previous</a>
          <br />Scope of Declarations</td>
     <td align="center" width="34%">
          <a href="sqlprocedures.html">Chapter Contents</a>
     </td>
        <td align="right" width="33%">
          <a href="RESULTSETS.html" title="Handling Result Sets">Next</a>
          <br />Handling Result Sets</td>
    </tr>
    </table>
  </div>
  <div id="footer">
    <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div>
   <div id="validation">
    <a href="http://validator.w3.org/check/referer">
        <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" />
    </a>
    <a href="http://jigsaw.w3.org/css-validator/">
        <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" />
    </a>
   </div>
  </div>
 </body>
</html>