文档详情

sql循环、游标、异常(国外英文资料).doc

发布:2017-06-07约8.37千字共19页下载文档
文本预览下载声明
sql循环、游标、异常(国外英文资料) - if judgment declare V_b Boolean: = true; The begin If v_b then Dbms_output.put_line ( ok ); End the if; The end; - if the else declare V_b Boolean: = false; The begin If v_b then Dbms_output.put_line ( ok ); The else Dbms_output.put_line ( false ); End the if; The end; - if elsif else declare V_name varchar2 (20) : = sx; The begin If v_name = 0701 then Dbms_output. Put_line ( 0701 ); Elsif v_name = sx then Dbms_output. Put_line (v_name); - dbms_output.put_line ( v_name ); The else Dbms_output.put_line ( false ); End the if; The end; The loop loop, notice that exiting exit is exiting the loop, not exiting the entire block Binary_Integer and Pls_Integer are integer types. Binary_Integer type variable value calculation is performed by the Oracle, there will be no overflow, but performs slower, because it is by the simulation of Oracle - line. Pls_Integer execution is run by the hardware, which is run directly by the CPU, and thus overflows, but the execution speed is much faster than the former. declare V_i binary_integer: = 0; The begin loop If v_i 10 then The exit; End the if; V_i: = v_i + 1; -- dbms_output. Put (v_i); Dbms_output. Put_line (v_i); End loop; Dbms_output.put_line ( over ); The end; Simpler way of writing it declare V_i binary_integer: = 0; The begin loop Exit the when v_i 30; V_i: = v_i + 1; Dbms_output.put_line ( Hello ); End loop; Dbms_output.put_line ( over ); The end; - the while loop declare V_i binary_integer: = 0; The begin While v_i 30 loop Dbms_output. Put_line ( hello + v_i); V_i: = v_i + 1; End loop; Dbms_output.put_line ( over ); The end; -- for loops, note that you dont need to declare variables The begin For v_i in 0. 30 loop Dbms_outout.put_line ( hello | v_i); End loop; Dbms_output.put_line ( over ); The end; Exercise: new student table (id integer, -- name varchar2, - age integer --) use the loop to insert 30 records into the student Request: id 0, 1, 2... The name is st0, st1, st2... Age is 11, 12, 13... (2) f
显示全部
相似文档