我遇到了问题,我在SQL中创建了一些表
CREATE TABLE customers (ID not null,
name varchar (20),
salary int,
PRIMARY KEY (ID)
);
现在我想把来自SQL的所有工资从PL / SQL脚本放到表中,但我想逐行放入它,我不知道怎么做,我想在for循环中抛出一些东西,是否有可能?
我想以这种方式做到这一点:
DECLARE
type salaries is table of integers;
tab salaries:= salaries();
BEGIN
for i in 1.. (here for example numbers of IDs)
/* and here make just tab(i):= customers(i).salary;
I know that it looks like in C++ or so but i don't know how to
implement it in sql.*/
答案 0 :(得分:0)
例如:
begin
for x in (select * from customers)
loop
if x.id > 30 or upper(x.name) like '%BOSS%' then
insert into custom_table (column1, column2, column3, column4)
values x.id, upper(x.name), x.salary, x.salary * 1.2;
end if;
end loop;
end;
答案 1 :(得分:0)
做这样的事情 click here to see