Oracle使用普通變數獲取遊標資訊
Oracle使用普通變數獲取遊標資訊
(1) 表資料
SQL> select * from scott.dept;
DEPTNO DNAME LOC
---------- ---------- ----------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
(2) 程式編寫
set serverout on;
--宣告遊標變數
declare cursor cu_dept is select deptno, dname, loc from dept;
--宣告三個變數用來臨時儲存查詢結果
--dept.deptno%type表示dept表格中的deptno型別,這是一種動態宣告變數型別的方法
deptno dept.deptno%type;
dname dept.dname%type;
loc dept.loc%type;
begin
open cu_dept;
--取第一行的資料
fetch cu_dept into deptno, dname, loc;
--如果當前資料存在,則迴圈取下一條資料
while cu_dept %found loop
dbms_output.put_line(deptno || ':' || dname || ':' || loc);
fetch cu_dept into deptno, dname, loc;
end loop;
close cu_dept;
end;
/
(3) 執行結果
10:ACCOUNTING:NEW YORK
20:RESEARCH:DALLAS
30:SALES:CHICAGO
40:OPERATIONS:BOSTON
PL/SQL procedure successfully completed.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29485627/viewspace-1246727/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle使用行型別變數獲取遊標資訊Oracle型別變數
- oracle cursor遊標獲取首末元素Oracle
- PL/SQL-遊標和遊標變數的使用SQL變數
- 獲取Oracle隱含引數資訊Oracle
- ORACLE 獲取繫結變數值Oracle變數
- 【筆記】遊標變數筆記變數
- PLSQL 遊標 變數的使用一例SQL變數
- 繫結變數優缺點、使用、繫結變數窺探、 Oracle自適應共享遊標變數Oracle
- v$sql_bind_capture 獲取繫結變數資訊SQLAPT變數
- 【RAC】使用crsctl命令獲取Oracle CRS版本資訊Oracle
- Oracle獲取繫結變數的各種方法Oracle變數
- oracle遊標使用全解Oracle
- Oracle 遊標使用全解Oracle
- [轉]oracle 遊標使用大全Oracle
- Oracle 遊標使用大全(轉)Oracle
- Oracle遊標使用大全(轉)Oracle
- 如何獲取繫結變數變數
- Oracle使用cursor for隱式遊標Oracle
- 反射-通過反射獲取成員變數並使用反射變數
- Oracle 元件資訊獲取途徑整理Oracle元件
- Oracle遊標Oracle
- Oracle 遊標Oracle
- 基於oracle 11.2.0.4如何獲取變更或修改後的所有資料庫引數資訊Oracle資料庫
- 如何獲取變數token的值變數
- 如何獲取變數 token 的值變數
- 獲取Mysql的狀態、變數MySql變數
- XPAGES 中CGI變數的獲取變數
- 如何獲取繫結變數值變數
- Oracle顯示遊標的使用及遊標for迴圈Oracle
- oracle遊標簡單使用小記Oracle
- Oracle 觸發器中使用遊標Oracle觸發器
- oracle 遊標中使用 動態 sqlOracleSQL
- Oracle資料庫遊標使用大全Oracle資料庫
- oracle資料庫獲取繫結變數的各種方法Oracle資料庫變數
- oracle獲取隱含引數Oracle
- 【Python】獲取機器使用資訊Python
- python使用cx_Oracle連線oracle資料庫獲取常用資訊PythonOracle資料庫
- 介面測試的獲取token變數變數