⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jb4-1-6-3.htm

📁 JBuilder 5 的中文版帮助文档
💻 HTM
字号:
<!-- saved from url=(0022)http://internet.e-mail -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta name="generator" content="Microsoft FrontPage 4.0">
<title>数据库应用程序开发者的指南:从数据来源检索数据</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link type="text/css" href="../jbdocs.css" rel="stylesheet">
</head>
<body bgcolor="#fefef2" style="FONT-SIZE: 9pt">
<h2><FONT 
color=#0080FF size=3 ><b>存储过程: InterBase, Oracle, 和 Sybase 的特定的信息</b></font></h2>        

<hr>
译者名字: chenjn(JD013) <br>                  
邮件地址:<a href="mailto:chenjn@fulltop.com">chenjn@fulltop.com</a>  
<blockquote class="bsku">
  <p><font color="#FF0000">数据库应用开发是 JBuilder 专业版和企业版的一个特征。<br>分布式的应用开发是 JBuilder 企业版的一个特征。</font></p>        
</blockquote>




<p>这一组话题包括帮助你使用的建议</p>

<ul>
<li>InterBase 存储过程</li>        

<li>Oracle PL/SQL 存储过程</li>        

<li>Sybase 存储过程</li>        
</ul>



<a name="interbase"></a>
<p><font size="3" color="#000080"><b>范例:InterBase 存储过程的使用</b></font></p>        
<!--BNDX="stored procedures:examples;InterBase:stored procedures example"-->
<p>在 InterBase 中, SELECT 操作可以被用来产生一个数据集: <code><font size="2">DataSet</font></code>。在 InterBase 的范例数据库中 <code>employee.gdb</code>,存储过程 ORG_CHART 就是这样的一个操作。为了从JBuilder中调用这个操作,在<code>procedure</code> 属性编辑器中向 Escape 存储过程或者 SQL StatCODEent 域, 或直接在代码中输入下列语法:</p>        

<p><kbd><font size="2">select * from ORG_CHART</font></kbd> 
<br>
</p>

<p>为了一睹更为复杂的 InterBase 存储过程,使用 Database Pilot(数据库飞行员)来浏览这个服务器上的程序。ORG_CHART 是一个有趣的例子。它返回一个整合了多张表的数据的结果集。ORG_CHART 是用InterBase 的过程和触发语言写的,它包括 SQL 的数据处理语句加上 控制结构和异常处理。</p>        

<p>ORG_CHART 的输出参数变成了产生的<code>DataSet</code>的列。</p>        

<p>参看 InterBase Server 的文档以获取更多的信息在编写 InterBase 存储过程的时候或者参看&quot;<a href="prov_procedure_disc.html">手工地为教程创造表格和过程</a>&quot;其中有一个在 InterBas 中编写存储程序的例子。<p>        


<!--***********************************************************************-->


<a name="parameters"></a>        
<h3><b><font color="#000080" size="3">范例:在 Oracle PL/SQL 存储过程中使用参数</font></b></h3>        
<!--BNDX="stored procedures:examples;Oracle PL/SQL stored procedures:example"-->
<p>当前,一个<code>ProcedureDataSet</code>只能被 Oracle PL/SQL 存储过程使用,如果你正在使用 Oracle 的 type-2或type-4 JDBC 驱动程序的话。 那个被调用的存储过程必须是返回值是 CURSOR REF 型的函数。</p>        

<p>遵循这个在JBuilder中使用 Oracle 存储过程的一般概要。</p>        

<ol>
<li>
<p>使用 PL/SQL 定义函数。以下是用 PL/SQL 详细定义一个返回值是 CURSOR REF 型的函数的例子。这个例子假设有一张命名为 MyTable1 的表。</p>        

<pre>
<code><font size="2">create or replace function MyFct1(INP VARCHAR2) RETURN rcMyTable1 as
  type rcMyTable1 is ref cursor return MyTable1%ROWTYPE;
    rc rcMyTable;
begin
  open rc for select * from MyTable1;
  return rc;
end;
</font></code>
</pre>
</li>

<li>
<p>设立一<code><font size="2">ParameterRow</font></code>来过渡到<code><font size="2">ProcedureDescriptor</font></code>。 输入的参数 INP 应该在 <code><font size="2">ParameterRow</font></code>中被指定, 但是CURSOR REF作为特殊的返回类型则不需要。JBuilder将使用输出的返回值来填充<code><font size="2">ProcedureDataSet</font></code>。以下是一个用 <code><font size="2">ParameterRow</font></code>完成以上操作的例子。</p>       

<p><code><font size="2">ParameterRow row = new ParameterRow();        
<br>
 row.addColumn( &quot;INP&quot;, Variant.STRING, ParameterType.IN);        
<br>
 row.setString(&quot;INP&quot;, &quot;Input Value&quot;);        
<br>
 String proc = &quot;{?=call MyFct1(?)}&quot;;        
<br>
</font>
</code></p>
</li>

<li>
<p>在工程面板中选取Frame文件, 然后选取Design标签。</p>        
</li>

<li>
<p>从Data Express 标签放一个<code><font size="2">ProcedureDataSet</font></code> 到主面板。</p>        
</li>

<li>
<p>选取<code><font size="2">procedure</font></code>属性来打开<code><font size="2">ProcedureDescriptor</font></code>对话框。</p>
</li>

<li>
<p>从<code><font size="2">Database</font></code>下拉列表中选取<code><font size="2">database1</font></code>。</p>
</li>

<li>
<p>输入以下退出语法在Escape存储过程或SQL Statement域,或在代码中:</p>        

<pre>
<font size="2">{?=call MyFct1(?)}</font>
</pre>
</li>

<li>
<p>选取对话框的Parameters标签。选取<code>ParameterRow</code>定义成<code>row</code>(行)。</p>
</li>
</ol>

<p>参看你的Oracle服务器文档以获得Oracle PL/SQL语言的信息。</p>        


<!--***********************************************************************-->


<a name="sybase"></a>
<p><font size="3" color="#000080"><b>使用 Sybase 存储过程</b></font></p>        
<!--BNDX="stored procedures:examples;Sybase stored procedures:example"-->
<p>在Sybase服务器上创建的存储过程被创建成一种&quot;连锁的&quot;事务模式。为了使 Sybase 存储过程作为 <code>ProcedureResolver</code>的一部分被调用,程序必须被修改才能在非连锁事务模式下运行。要这样做,就要用Sybase 的系统存储进程 <code>sp_procxmode</code>来改变事务模式为&quot;任何模式&quot;或 &quot;非连锁的&quot;。欲知更多细节,参看Sybase的文档。</p>        

<a name="sample_storedproc"></a>
<p><font size="3" color="#000080"><b>浏览使用存储过程的应用例程</b></font></p>

<p>在你的JBuilder安装目录下的 /samples/DataExpress/ServerSpecificProcedures 中,你能看到一个拥有针对Sybase, InterBase,和 Oracle数据库的代码的应用例程。</p> 


</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -