當前位置:首頁 > 資訊 > 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號
广东25选5开奖结果