Plsql 使用一列中的值更新新列
I表中有两列,需要使用a列中的值更新第三列,用于以下所有组合:Plsql 使用一列中的值更新新列,plsql,Plsql,I表中有两列,需要使用a列中的值更新第三列,用于以下所有组合: ColumnA ColumnB newColumn 1 2 1 2 1 1 3 4 3 4 3 3 我想你需要这样的东西 update your_table set column3 = least(column1,column2);
ColumnA ColumnB newColumn
1 2 1
2 1 1
3 4 3
4 3 3
我想你需要这样的东西
update your_table set column3 = least(column1,column2);
我认为“光标的当前位置”将帮助您在这里实现您所需的相同功能。
CREATE TABLE test_1(a INT ,b INT);
INSERT INTO test_1 SELECT LEVEL , NULL FROM dual CONNECT BY LEVEL<10;
SELECT * FROM test_1;
declare
cursor c1 is
select * test_1
for update of b;
BEGIN
FOR rec IN c1
LOOP
update webowner.test_1
set b= rec.a
where current of c1;
END LOOP;
end;
创建表test_1(a INT,b INT);
插入到测试_1中,选择级别,按级别从双连接中选择NULL