Get the App
SLTechnology News&Howtos  ›  Database  › 

Detailed explanation of Oracle implicit and explicit cursors

Shulou Source: shulou.com Published: 2022-06-01 04:37:45 09月29日 Update

What is the cursor? It is a temporary storage space opened up in memory.

1.Oracle implicit cursor

Which implicit cursors are commonly used in 1.1Oracle

1.2 Oracle implicit cursor demonstration

-- implicit cursor (the table used is the emp table that comes with Oracle by default)-- sql%rowcount: affect the number of records sql%found: whether there are records that meet the conditions set serveroutput on;declarev_ename axiemp.ename% type begin select ename into v_ename from a_emp where empno=7788;if sql%found then dbms_output.put_line (v_ename); dbms_output.put_line (sql%rowcount); end if;end;/

Therefore, all of our database operations have cursors.

2.Oracle explicit cursor

2.1 explicit cursor syntax

Cursor cursor name is select statement

2.2Oracle explicit Vernier demonstration

-- explicit cursor declare-- create a cursor cursor cursor_a_emp is select empno,ename from aura emptiness;-- other variables v_empno astatemp.empno% type;-- employee number v_ename acuremp.ename% type;-- employee name v_rowcount number;-- number of employees begin-- Open cursor open cursor_a_emp -- calculate the number of records stored in the cursor select count (*) into v_rowcount from emp;-- cycle to fetch the data in the cursor, for i in 1..v_rowcount loop fetch cursor_a_emp into vault empnoscope vault name; dbms_output.put_line (v_empno); dbms_output.put_line (v_ename); dbms_output.put_line ('= ='); end loop -- close the cursor close cursor_a_emp;end;/

A cursor is the equivalent of a temporary table, which is stored in memory and released when it is finished.

2.3 explicit cursor properties

The above is the knowledge of Oracle implicit cursors and explicit cursors introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave a message for me. The editor will reply you in time!

Tags: Cursors employees storage memory that is data presentations number of people variables names finished attributes commonly used databases conditions knowledge space statements syntax Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB macOS Shulou Technology Docker vpn