Examples of Oracle Tour signs

Source: Internet
Author: User

--cursor cursor_name is select_statement--For loop cursors--(1) Defining Cursors--(2) Defining a cursor variable--(3) using the For loop to use this cursorDeclare       --type definition       cursorC_job is       SelectEmpno,ename,job,sal fromEMPwhereJob='MANAGER'; --defines a cursor variable v_cinfo c_emp%rowtype, which is a row of data types in the cursor c_empC_row C_job%RowType;begin        forC_rowinchC_job Loop dbms_output.put_line (C_row.empno||'-'||C_row.ename||'-'||C_row.job||'-'||c_row.sal); EndLoop;End;

Examples of practical work:

Declarev_temp Number;--Defining Variablesv_part_idVARCHAR2( -);--Defining Variables       cursorC_job--Defining Cursors        is       SELECTDept_id,dept_code,dept_type fromPub_depart_infoORDER  bydept_id; C_row C_job%RowType--defines the variable c_row, which is a row of data in the cursor c_jobbegin       OpenC_job;--Open CursorLoop--Start Loop           FetchC_job intoC_row;--reading a row of data           Exit  whenC_job%NotFound--exit when data is empty (that is, when the loop is complete)              ifC_row. Dept_code is NULL  Then   --the method of calling the field data is C_row. Dept_code, where Dept_code is the column name in the database                 IFC_row. Dept_type= 1  Thenv_temp:= 0; Select Max(Dept_code)+1  intov_part_id fromPub_depart_infoWHEREDept_type= '1'; UpdatePub_depart_infoSetDept_code=v_part_idwheredept_id=C_row.                  dept_id; ELSEv_temp:=V_temp+ 1; IFV_temp< Ten  Then                           UpdatePub_depart_infoSetDept_code=(v_part_id|| '0000' ||v_temp)wheredept_id=C_row.                      dept_id; ELSE                           UpdatePub_depart_infoSetDept_code=(v_part_id|| ' the' ||v_temp)wheredept_id=C_row.                      dept_id; END IF; END IF; End if; EndLoop--End Loop      CloseC_job;--Close CursorsEnd;

Examples of Oracle Tour signs

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.