out引數以及使用游標問題

2021-07-07 02:57:03 字數 1278 閱讀 5422

/*

查詢某個員工的姓名 月薪 職位

*/ create or replace procedure queryempinfo(eno in number,

pename out varchar2,

psal out number,

pjob out varchar2)

as begin

select ename,sal,empjob into pename,psal,pjob from emp where empno=eno;

end;

/–游標: 使用游標查詢員工姓名和工資,並列印

/* 游標的屬性:

**%isopen 是否被開啟

%rowcount 行數

%notfound 是否有值**

*/set serveroutput on

declare

–游標

cursor cemp is select ename,sal from emp;

pename emp.ename%type;

psal emp.sal%type;

begin

open cemp;

loop

–從集合中取值

fetch cemp into pename,psal;

–**exit when cemp%notfound;

dbms_output.put_line(pename||'的薪水是'||psal);
end loop;

close cemp;

end;

/查詢某個部門中所有員工的所有資訊

create or replace

package mypackage as

type empcursor is ref cursor;

procedure queryemplist(dno in number,emplist out empcursor);

create or replace

package body mypackage as

procedure queryemplist(dno in number,emplist out empcursor) as

begin

open emplist for select * from emp where deptno=dno;
end queryemplist;

end mypackage;

使用游標 引數游標

參游標是指帶有引數的游標。在定義了引數游標之後,當使用不同引數值多次開啟游標時,可以生成不同的結果集。定義引數游標的語法如下 cursor cursor name parameter name datetype is select statement 注意,當定義引數游標時,游標引數只能指定資料型別...

gcc g 引數以及使用

c原始檔到可執行一共需要經歷4個階段。使用gcc編譯程式要經過預處理 編譯 彙編 鏈結。預處理 編譯器主要載入標頭檔案 條件編譯 巨集替換,使用 gcc e main.c main.i,編譯 編譯過程中,編譯器主要做語法檢查和詞法分析,沒有問題之後將會翻譯成彙編 或者中間 gcc s main.i ...

MySQL 使用游標迴圈中斷的問題

原文戳我 剛剛,使用儲存過程的時候遇到了乙個問題,我在儲存過程內使用游標去遍歷 擁有角色的使用者,然後去生成根據使用者id生成每日統計記錄。1 2 declarecurcursorfor selectv user idfromv user rolewherev role id role id 查詢角...