-
--使用記錄型變量 declare info_row account_info%rowtype; begin select * into info_row from account_info a where a.member_id = 30989; dbms_output.put_line(info_row.member_id||'的余額是'||info_row.account_fee); end; /查看全部
-
說明部分(續) 記錄型變量(代表表中的一行,理解成數組) 例:emp_rec emp%routype; emp_rec.ename := 'ADAMS';查看全部
-
賦值2種方式 := 和 into關鍵字 set serveroutput on declare memberId account_info.member_id%type; accountFee account_info.account_fee%type; begin select a.member_id,a.account_fee into memberId,accountFee from account_info a where a.member_id = 30989; dbms_output.put_line(memberId||'的余額是'||accountFee); end; /查看全部
-
說明部分(續) 引用型變量 例: my_name emp.ename%type; 變量名稱 變量類型 (引用emp表ename列的類型作為my_name的類型)查看全部
-
PL/SQL的程序結構 declare 說明部分 (變量說明,光標說明,例外說明) 定義基本變量(名字再前面,類型再后面) 類型:char,varchar2,date,number,boolean,long 舉例:var1 char(15); married boolean := true; (賦值使用 :=) psal number(7,2) begin 語句序列(DML語句) exception 例外處理語句 end; /查看全部
-
PL/SQL (Procedure Language/SQL)過程語言的SQL; PL/SQL是Oracle對sql語言的過程化擴展; --指在SQL命令語言中增加了過程處理語句(如分支、循環等),使SQL語言具有過程處理能力 PL/SQL是面向過程的語言。查看全部
-
Value_error (算術或轉換錯誤)查看全部
-
--系統例外:被0除 zero_divide set serveroutput on declare --定義一個基本變量 pnum number; begin pnum:=1/0; exception when zero_divide then dbms_output.put_line('1:0不能做除數'); dbms_output.put_line('2:0不能做除數'); when others then dbms_output.put_line('其他例外'); end; / 注:then 后相當于有一個大括號。查看全部
-
系統例外:too_many_rows查看全部
-
自定義例外 定義變量,類型是exception 使用raise拋出自定義例外查看全部
-
產生例外可以通過exception來捕獲 exception when 錯誤類型 tnen dbms_output.put_line('錯誤類型'); when others then dbms_output.put_line('其他例外');查看全部
-
declare --說明部分(變量,光標或者例外) begin --程序體 dbms_output.put_line('hello world'); end; / --結束執行 set serveroutput on 打開輸出開關查看全部
-
exception when no_data_found then dbms_output.put_line('沒有找到該員工'); when others then dbms_output.put_line('其他例外'); //通過others捕獲所有的例外查看全部
-
在oracle中錯誤被叫做例外:分為系統例外和自定義例外。 1、系統例外 No_data_found 沒有找到數據 Too_many_rows select..into語句匹配多個行 Zero_Divide 被零除 Value_error 算數或轉換錯誤,算術錯誤比如說負數開平方 Timeout_on_resource 在等待資源時發生超時查看全部
-
1、光標的屬性: %found,%notfound,%isopen(判斷光標是否打開),%rowcount(影響的行數) 比如說光標這個結果集共有100條記錄,通過光標取了10條記錄,那么受影響的行數就是10. 2、光標數的限制:默認情況下,oracle數據庫只允許在同一個會話中打開300個光標。 如何驗證這點?首先切換用戶至SYS,connect sys/[email protected]:1521/orcl as sysdba; 然后顯示參數show parameter cursor,就可以看到open_cursors的值是300. 注意一下這里的show parameter cursor做的是模糊查詢,也就是%cursor% 3、修改光標數的限制: 例:alter system set open_cursors=400 scope=both; alter system set :用來修改系統參數,除了光標數對于其他參數的修改同樣適用。 注:scope的取值:both,memory,spfile,其中memory表示這條修改語句只更改當前實例不更改參數文件;spfile表示這條修改語句只更改參數文件不更改當前實例,如果取值是spfile數據庫需要重啟查看全部
舉報
0/150
提交
取消