mes*_*lds 1 sql oracle plsql if-statement cursor
我有一个名为Oracle的Oracle DB myC.在这张表中,我有几行,其中两行被称为myCheight, myCwidth.
我需要读取这些值并比较它们 IF myCheight > myCwidth DO switch the values.
我试图从一行读取值,但没有让它工作.我使用Oracles Oracle SQL Developer.
这是我到目前为止提出的:
set serveroutput on;
DECLARE
cursor h is select * from MyC;
type htype is table of h%rowtype index by number;
stage_tab htype;
master_tab htype;
BEGIN
open h;
loop
fetch h bulk collect into stage_tab limit 500;
for i in 1 .. stage_tab.count loop
master_tab(stage_tab(i).id) := stage_tabe(i);
end loop;
exit when h%notfound;
end loop;
close h;
end;
Run Code Online (Sandbox Code Playgroud)
Joe*_*lli 10
你不能这样做吗?
UPDATE myC
SET myCheight = myCwidth,
myCwidth = myCheight
WHERE myCheight > myCwidth
Run Code Online (Sandbox Code Playgroud)