Oracle Small Knowledge

Source: Internet
Author: User

The simplest block:

Begin Dbms_output.put_line ('hello,world');   End;

This occurs when the execution results ( execution succeeds, but the string is not displayed ):

The workaround is to execute this statement before executing the BLOCK: set Serveroutput on (can be understood as a switch to turn the output function on)

It was then successful.

Cursor

A. For loop cursor

The basic steps are: 1. Define a cursor----2. Define a cursor variable----3. Loop cursor

--declaring cursors cursor cursor_name is select_sattement--For loop cursors--(1) to define a cursor--(2) to define a cursor variable--(3Use the For loop to use this cursor DECLARE CURSOR c_job--Defining Cursors is       SelectEmp.empno,emp.ename,emp.job,sal fromEMPwherejob='MANAGER'; --defining a cursor variable c_row c_job%Rowtype;begin forC_rowinchC_job Loop--circular cursor Dbms_output.put_line (c_row.empno||'-'|| c_row.ename| |'-'|| c_row.job| |'-'||c_row.sal);     End Loop;end; 

Two. Fetch cursors

--Fetch Cursors--use must be explicitly turned on and off declare cursor c_job is    SelectEmpno,ename,job,sal fromEMPwherejob!='MANAGER'; C_row C_job%Rowtype;begin Open c_job;      Loop fetch c_job into C_row; Exit when C_job%NotFound; Dbms_output.put_line (C_row.empno||'-'|| c_row.ename| |'-'|| c_row.job| |'-'||c_row.sal);      End Loop;      Close C_job; End;

Oracle Small Knowledge

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.