现在的位置: 首页 > 综合 > 正文

select into

2013年07月03日 ⁄ 综合 ⁄ 共 412字 ⁄ 字号 评论关闭

select into .. from 可以塞到column變數或是row變數, 但是where條件只能抓出一筆, 不然會產生錯誤,dbms_output.put_line可以輸出到畫面,以下指令執行完點sql視窗"output"可以看到結果.

declare 
T_aTable  aTable%rowtype; --row type
v_col1 aTable.col1%TYPE; --column type
begin
select col1
into v_col1
from aTable where v_col1 = 'XX' -- -塞到v_col1 這變數
;
select *
into T_aTable
from aTable where v_col1 = 'XX' --塞到T_aTable 這row
;
dbms_output.put_line(v_col1); --output v_col1
dbms_output.put_line(T_aTable); --output T_aTable
end;

抱歉!评论已关闭.