当前位置:首页 > 资讯 > info6 > 正文

存储过程程序编写总结

发表于: 2007-05-18   作者:cheayu   来源:转载   浏览:
摘要: 夜里快一点了,听着爱情转移,做出下列正对ORACLE数据储存程序总结:  一使用步骤:                 1       Delare                --------------定义变量                  2    begin                   exception                    ---------------异

夜里快一点了,听着爱情转移,做出下列正对ORACLE数据储存程序总结:

   一使用步骤:

                  1        Delare                 --------------定义变量

                   2     begin

                    exception                    ---------------异常处理句断

                          end;                      ---------------执行程序体

                   给出一个实例吧:

                 declare

                   maxrecords  constant int:=100;

                       i:=1;

                  begin 

                 for i    in 1..maxrecords  loop

                insert  into  yuxin.testtable(recordnumber,currentdate)  value( i,sysdate);

             end  loop;

                dbmp_output.put_line("欢迎使用余新专栏项目实例");

       end;

这样,就能插出100条记录

二属性定义记录类型:

格式:

                        Declare

                                      mydate   yuxin.testtable.currentdate%  type;

                       begin

                          end;

三结构化记录类型:

                      declare  

                    type  myrecord is    record(

                       myrecordnumber     int,

                      mycurrentdate           date

                         );

                 srrecord                myrecord;

                     begin  

                        select   *  into   srrecord   form   yuxin.testtable   where   recordnumber=68;

                         dbms_output.put_line(srrecord.mycurrentdate);

                      end;

四:利用行格式记录类型:

                            declare  

                          mytable   yuxin.testtable%rowtype;

                               begin

                             select  *   into   mytable   form                yuxin.testtable  where    recordnumber=88;

                                dbms_output.put_line(mytable.currenttable);

                             end;

五 使用一维表类型变量

                      Delcare

                                              type  tabletype1  is  table  of  varchar2(4)  index   by   binary_integer;

                                            type  tabletype2   is      table  of  yuxin.testtable.recordnumber%type  index  by  binary_integer;

                                       table1   tabletype1;

                                      table2   tabletype2;

                      begin

                                         table1(1)="欢迎进入";

                                          table1(2)="希望有所收获";

                                         table2(1)="余新";

                                        table2(2)="专栏";

                               dbms_output.put_line(table1||table2(1)||table1(2)||table1(2));

                                     end;

就先写到这里了,因为爱情转移已经唱完了,我先去米个好听的.

                     

      

                                                  

        

                                 

存储过程程序编写总结

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号