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

📄 oracle pl-sql 过程调试的输出方法 - 数据库 - whatiswhat.htm

📁 sql初学者不错的教程
💻 HTM
📖 第 1 页 / 共 2 页
字号:
    <TD colSpan=4>
      <TABLE style="BORDER-COLLAPSE: collapse" borderColor=#111111 cellSpacing=0 
      cellPadding=0 width=980 border=0>
        <TBODY>
        <TR>
          <TD></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<SCRIPT language=javascript>function $(s){return document.getElementById(s);}function ShowHideDiv(divid,iImg){if($(divid).style.display == "none"){iImg.src="../../templates/newgreen/images/dot2.gif";$(divid).style.display = "block";iImg.title="收起";}else{iImg.src="../../templates/newgreen/images/dot4.gif";$(divid).style.display = "none";iImg.title="展开";}}navHover();</SCRIPT>

<TABLE style="BORDER-COLLAPSE: collapse" borderColor=#111111 cellSpacing=0 
cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD height=3></TD></TR></TBODY></TABLE><BR>
<TABLE style="BORDER-COLLAPSE: collapse" borderColor=#111111 cellSpacing=0 
cellPadding=0 width="90%" align=center border=0>
  <TBODY>
  <TR>
    <TD width=18 height=28><IMG alt="" 
      src="Oracle PL-SQL 过程调试的输出方法 - 数据库 - whatiswhat.files/bg_art_left_top.gif" 
      border=0></TD>
    <TD 
    background="Oracle PL-SQL 过程调试的输出方法 - 数据库 - whatiswhat.files/bg_art_top.gif">
      <P style="MARGIN: 5px; LINE-HEIGHT: 150%"></P></TD>
    <TD width=18 height=28><IMG alt="" 
      src="Oracle PL-SQL 过程调试的输出方法 - 数据库 - whatiswhat.files/bg_art_right_top.gif" 
      border=0></TD></TR>
  <TR>
    <TD width=18 
    background="Oracle PL-SQL 过程调试的输出方法 - 数据库 - whatiswhat.files/bg_art_left.gif"></TD>
    <TD align=middle bgColor=#f5fdee><BR><FONT style="FONT-SIZE: 14pt" 
      color=#295200><B>Oracle PL/SQL 过程调试的输出方法</B></FONT> 
      <TABLE style="BORDER-COLLAPSE: collapse" borderColor=#a5bd6b cellSpacing=1 
      cellPadding=0 width="100%" border=1>
        <TBODY>
        <TR>
          <TD align=middle>
            <TABLE style="BORDER-COLLAPSE: collapse; WORD-WRAP: break-word" 
            cellSpacing=0 cellPadding=0 width="100%" border=0>
              <TBODY>
              <TR>
                <TD align=middle>
                  <TABLE 
                  style="BORDER-COLLAPSE: collapse; WORD-WRAP: break-word" 
                  cellSpacing=0 cellPadding=0 width="100%" border=0>
                    <TBODY>
                    <TR>
                      <TD>
                        <DIV id=art 
                        style="MARGIN: 15px">1.最基本的DBMS_OUTPUT.PUT_LINE()方法。<BR>&nbsp;&nbsp;&nbsp;&nbsp;随便在什么地方,只要是BEGIN和END之间,就可以使用DBMS_OUTPUT.PUT_LINE(output);<BR>&nbsp;&nbsp;&nbsp;&nbsp;然而这会有一个问题,就是使用该函数一次最多只可以显示255个字符,否则缓冲区会溢出。<BR>&nbsp;&nbsp;&nbsp;&nbsp;此外,函数DBMS_OUTPUT.ENABLE(20000)这种函数,仅仅是设置整个过程的全部输出缓冲区大小,而非DBMS_OUTPUT.PUT_LINE()的缓冲区大小。<BR>&nbsp;&nbsp;&nbsp;&nbsp;对于超过255个字符的变量,使用DBMS_OUTPUT.PUT_LINE()方法是没有效的。据说在Oracle10中,解除了这个限制,可以输出任意大小的字符串。<BR>declare<BR>&nbsp;&nbsp;&nbsp;&nbsp;output 
                        varchar2(200);<BR>begin<BR>&nbsp;&nbsp;&nbsp;&nbsp;output:='...';&nbsp;&nbsp; 
                        //赋值<BR>&nbsp;&nbsp;&nbsp;&nbsp;DBMS_OUTPUT.PUT_LINE(output);<BR>end;<BR><BR>2.使用表的方法。<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
                        首先建立一张表,然后在PL/SQL中将要输出的内容插到表中。然后再从表中查看内容。对于这种方法一次可以输出几千个字符。<BR>(1) 
                        create table 
                        my_output{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id 
                        number(4),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;txt 
                        varchar2(4000)&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;);<BR><BR>(2) 
                        declare<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;output 
                        varchar2(4000);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strSql 
                        varchar2(4500);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;count 
                        number(4):=0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;begin<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strSql:='delete 
                        * from 
                        my_output';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EXECUTE 
                        IMMEDIATE 
                        strSql;<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;output:='...'; 
                        //赋值<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;count:=count+1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strSql:='Insert 
                        into my_output value 
                        (count,'''||output||''')';<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--''在单引号中相当于字符'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EXECUTE 
                        IMMEDIATE 
                        strSql;<BR>&nbsp;&nbsp;&nbsp;&nbsp;end;<BR>3.使用输出文件的方法。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;如果变量非常大,以致连使用表都没有办法插入时,只有使用文件方式了。<BR>(1) 
                        create or replace directory TMP as 
                        'd:\testtmp';<BR>&nbsp;&nbsp;&nbsp;&nbsp;--建立一个文件夹路径<BR>(2) 
                        declare<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file_handle 
                        UTL_FILE.FILE_TYPE;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;output 
                        varchar2(30000);<BR>&nbsp;&nbsp;&nbsp;&nbsp;begin<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;output:="....";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file_handle 
                        := UTL_FILE.FOPEN('TMP', 'output.txt', 
                        'w',[1-32767]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--四个参数:目录,文件名,打开方式,最大行数(默认为2000)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UTL_FILE.PUT_LINE(file_handle, 
                        output);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UTL_FILE.FCLOSE(file_handle);<BR>&nbsp;&nbsp;&nbsp;&nbsp;exception<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHEN 
                        utl_file.invalid_path 
                        THEN<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;raise_application_error(-20000, 
                        'ERROR: Invalid path for file or path not in 
                        INIT.ORA.');<BR>&nbsp;&nbsp;&nbsp;&nbsp;end; 
                    </DIV></TD></TR></TBODY></TABLE>
                  <P style="MARGIN: 5px; LINE-HEIGHT: 150%"></P></TD></TR>
              <TR>
                <TD align=middle height=25><FONT color=#295200>发表于: 2008-04-14 
                  ,修改于: 2008-04-14 13:38,已浏览71次,有评论0条</FONT> <A id=star 
                  title=推荐这篇文章 onclick="NewWindows(this.href);return false;" 
                  href="http://blog.chinaunix.net/u2/star.php?blogid=44734&amp;artid=530684">推荐</A> 
                  <A id=complaint title=投诉这篇文章 
                  onclick="NewWindows(this.href);return false;" 
                  href="http://blog.chinaunix.net/u2/complaint.php?blogid=44734&amp;artid=530684">投诉</A> 
                </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD>
    <TD width=18 
    background="Oracle PL-SQL 过程调试的输出方法 - 数据库 - whatiswhat.files/bg_art_right.gif"></TD></TR>
  <TR>
    <TD width=18 height=28><IMG alt="" 
      src="Oracle PL-SQL 过程调试的输出方法 - 数据库 - whatiswhat.files/bg_art_left_bottom.gif" 
      border=0></TD>
    <TD 
    background="Oracle PL-SQL 过程调试的输出方法 - 数据库 - whatiswhat.files/bg_art_bottom.gif">
      <P style="MARGIN: 5px; LINE-HEIGHT: 150%"></P></TD>
    <TD width=18 height=28><IMG alt="" 
      src="Oracle PL-SQL 过程调试的输出方法 - 数据库 - whatiswhat.files/bg_art_right_bottom.gif" 
      border=0></TD></TR></TBODY></TABLE><BR>
<TABLE style="BORDER-COLLAPSE: collapse" borderColor=#a5bd6b cellSpacing=1 
cellPadding=0 width="90%" align=center border=1>
  <TBODY>
  <TR>
    <TD style="COLOR: #295200" bgColor=#eff7de height=25><B>网友评论</B></TD></TR>
  <TR>
    <TD bgColor=#ffffff height=1></TD></TR>
  <TR>
    <TD align=middle bgColor=#f9f5e7>
      <TABLE 
      style="COLOR: #295200; BORDER-COLLAPSE: collapse; WORD-WRAP: break-word" 
      cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
        <TBODY></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE style="BORDER-COLLAPSE: collapse" borderColor=#a5bd6b cellSpacing=1 
cellPadding=0 width="90%" align=center border=1>
  <TBODY>
  <TR>
    <TD style="COLOR: #295200" bgColor=#eff7de height=25><B>发表评论</B></TD></TR>
  <TR>
    <TD bgColor=#ffffff height=1></TD></TR>
  <TR>
    <TD align=middle bgColor=#f9f5e7><IFRAME name=comment 
      src="Oracle PL-SQL 过程调试的输出方法 - 数据库 - whatiswhat.files/comment.htm" 
      frameBorder=0 width="100%" 
height=160></IFRAME></TD></TR></TBODY></TABLE></BODY></HTML>

⌨️ 快捷键说明

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