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