夜裏快一點了,聽着愛情轉移,做出下列正對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;
就先寫到這裏了,因爲愛情轉移已經唱完了,我先去米個好聽的.