问个oracle数据库赋值语句

来源:百度知道 编辑:UC知道 时间:2024/05/21 10:03:04
我通过select a from table1 where b='1'
我想把这个结果赋给变量b 应该怎么写

declare
bb table1.a%rowtype;
begin
select a into bb from table1 where b='1';
--dbms_output.put_line(bb);

你的查询语句where条件里面有b字段,赋值最好换个变量名,要不要出问题

select a into b from table1 where b='1'

uodate table_name f set f.b=(select g.a from table1 g where g.b='1');

我用f替换你要赋值的变量所在的表,用g替换你查询语句中的table1,以此区别你查询语句中的b。