<!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 ; " /> <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="PLSCROLLCRSRS.html" title="Virtuoso/PL Scrollable Cursors" /> <link rel="next" href="handlingplcondit.html" title="Handling Conditions In Virtuoso/PL Procedures" /> <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 ; " /> <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="plmodules" /> <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="PLSCROLLCRSRS.html" title="Virtuoso/PL Scrollable Cursors">Prev</a> | <a class="link" href="handlingplcondit.html" title="Handling Conditions In Virtuoso/PL Procedures">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> <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 & 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 class="selected"> <a href="plmodules.html">Virtuoso PL Modules</a> <div> <a href="#plmodsyntax" title="Syntax">Syntax</a> <a href="#plmodsecurity" title="Security">Security</a> </div> </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="plmodules" /> <h2>9.19. Virtuoso PL Modules</h2> <p> Modules are packages of procedures which compile together. Procedure names in module definitions are not fully qualified names, but consist only of a single identifier that it is appended to the name of the module (which is a 3-part name) to make the 4-part module procedure name. </p> <p> Module procedures do not appear in SQLProcedures output. Module names are in the same domain as the procedure names, so it is not possible to have a procedure with the same name as an existing module. </p> <a name="plmodsyntax" /> <h3>9.19.1. Syntax</h3> <div> <pre class="programlisting"> CREATE MODULE m_name { [PROCEDURE|FUNCTION] p_name1 (...) { ...}; [PROCEDURE|FUNCTION] p_name2 (...) { ...}; ... [PROCEDURE|FUNCTION] p_nameN (...) { ...}; } </pre> </div> <div> <pre class="programlisting"> DROP MODULE m_name; </pre> </div> <br /> <a name="ex_plmod2" /> <div class="example"> <div class="exampletitle">Procedure Modules</div> <div> <pre class="programlisting"> create module DB.DBA.MOD { function MOD1 () returns varchar { return ('MOD1'); }; procedure MOD2 () { return concat (MOD1(), 'MOD2'); }; }; </pre> </div> <p> This example creates a module, MOD, with 2 procedures: MOD1 & MOD2. Their fully-qualified names are DB.DBA.MOD.MOD1 and DB.DBA.MOD.MOD2. </p> <p> Note the call to MOD1 in MOD2 - it is not fully qualified, but it resolves to the module procedure MOD1, instead of any procedure external to the module. </p> </div> <p> A single part procedure name in a call inside a module is first matched against procedures defined in the module. If the above example were executed by DBA (in the DB qualifier), then the below statements are equivalent: </p> <div> <pre class="programlisting"> select DB.DBA.MOD.MOD1() select DB..MOD.MOD1() </pre> </div> <p> The statement: </p> <div> <pre class="programlisting"> select MOD.MOD1() </pre> </div> <p> will result in calling the DB.DBA.MOD.MOD1() only if a function DB.MOD.MOD1 does not exist. If it exists, it will be preferred over DB.DBA.MOD.MOD1 when using this notation. </p> <a name="plmodsecurity" /> <h3>9.19.2. Security</h3> <p> Module procedures can be granted to users. Modules can also be granted to users. Granting execute to a module is equivalent to granting execute for all of the module's procedures.</p> <br /> <table border="0" width="90%" id="navbarbottom"> <tr> <td align="left" width="33%"> <a href="PLSCROLLCRSRS.html" title="Virtuoso/PL Scrollable Cursors">Previous</a> <br />Virtuoso/PL Scrollable Cursors</td> <td align="center" width="34%"> <a href="sqlprocedures.html">Chapter Contents</a> </td> <td align="right" width="33%"> <a href="handlingplcondit.html" title="Handling Conditions In Virtuoso/PL Procedures">Next</a> <br />Handling Conditions In Virtuoso/PL Procedures</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>