Basic Oracle Learning (2)

Source: Internet
Author: User
Statement of Oracle loop: declarex number: = 5; begin -- X: = 0; loopx: = x + 1;/* If (x = 10) Then exit; end if; */exit when x = 10; dbms_output.put_line ('X = '| X); End loop; dbms_output.put_line ('outer'); end;/define declarex number: = 5; beginwhile x <10 loopx: = x + 1; dbms_output.put_line ('X = '| X); End loop; dbms_output.put_line ('outer'); end; /----------------------------- beginfor X in 2 .. 10 loopdbms_output.put_line ('X = '| X); End loop; end;/------------------------------- declarex number: = 5; begin <
 
  
> -- Mark X: = x + 1; dbms_output.put_line ('X = '| X); If x <10 Then goto label1; end if; end; /------------- Exception Handling exceptionwhen .. then... common system exceptions: dup_val_on_indexno_data_foundtoo_many_rowsvalue_errorzero_dividee.g.: declareva varchar2 (20); beginselect A into VA from ABC where f_nvar = 'abc'; dbms_output.put_line (VA); exceptionwhen no_data_found values ('data not found '); end; ----------------------- declareva varchar2 (20); vi integer; beginselect A into VA from ABC where f_nvar = 'min min wan'; dbms_output.put_line (VA); VI: = 1/0; exceptionwhen no_data_found partition ('data not found '); when others thendbms_output.put_line ('Other questions'); end; ----------------- declareva varchar2 (20); vi integer; e exception; beginselect A into VA from ABC where f_nvar = '文 '; dbms_output.put_line (VA); -- VI: = 1/0; Raise E; predictionwhen no_data_found locate ('unfound data '); when e encode ('problem A'); when others thendbms_output.put_line ('Other questions'); end; ------------------- composite variable: record type type_name is record (variable_name datatype, variable_name datatype ,...); ----------- declare myrec ABC % rowtype; beginselect * into myrec from ABC where a = 'aaa'; dbms_output.put_line (myrec. A | myrec. B | myrec. c); end; ------------------- row_number () function and select row_number () over (order by a) SA, a, B, c, f_nvar from abcselect * from ABC where rownum <10 declare myrec ABC % rowtype; beginselect * into myrec from ABC where a = 'aaa11123 'and rownum <2; dbms_output.put_line (myrec. A | myrec. B | myrec. c | myrec. f_nvar); end; begin a simple stored procedure: Create or replace procedure proc_show_abc_by_a (PA varchar2) ASFA varchar2 (20); beginselect A into fa from spark. ABC where a = PA; dbms_output.put_line (FA); end;/------------------------------------- create or replace public synonym myabc for spark. ABC; ------------------------------------- sequence create sequence myseqstart with 1 increment by 1 ordernocycle;
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.