用oracle SQL 写一个查询结果集后 用结果集循环 并用结果集的列做if条件 满足条件后用结果集的列进行批量插select n1,n2 from t1 where 1=1
for(上面的结果集){
if(n1==x){
insert into t2 value (n2,xx) insert into t2 value (n2,xx1) insert into t2 value (n2,xx2) insert into t2 value (n2,xx3) }
}
大概就是这个意思 只是用SQL表示出来
本人分少 高抬贵手
for(上面的结果集){
if(n1==x){
insert into t2 value (n2,xx) insert into t2 value (n2,xx1) insert into t2 value (n2,xx2) insert into t2 value (n2,xx3) }
}
大概就是这个意思 只是用SQL表示出来
本人分少 高抬贵手
解决方案 »
- 将查询出来的某个字段插入到临时表里,查完临时表要drop掉,sql语句怎么写?
- 9i的isqlplusdba权限问题
- 百万级朝上数据量的表如果允许见多少索引合适
- 求对一个允许重复记录的表做统计,对于重复的记录sum的时候只要算1个,内详!
- 寻求存储过程的调试工具?
- 没有这样revoke update on ANY TABLE from usera的写法?
- 求助:Enterprise Manager 无法继续。最可能的原因是无法检索数据库会话信息, 或 EM 无法处理用户调用的书签。 按“确定”即可继续。
- 问个sql的写法
- oracle有没有文件操作的功能?
- 系统权限和对象权限的关系?
- 关于存储过程中的dblink
- hibernate query.list()没有值
declare
cursor s_cur is
select * from s;
begin
for r in s_cur loop
if r.s_id > 0 then
insert into s3 values (r.s_id, r.S_name);
end if;
end loop;
close s_cur;
commit;
end;
declare
cursor s_cur is
select n1,n2 from t1;
begin
for r in s_cur loop
if r.n1 ='x' then
insert into t2 values (r.n2, 'xx');
end if;
end loop;
commit;
end;
select cp.par_value,
ct.code || '_' || cp.par_value codeValue
from t_card_type ct, t_card_parvalue cp
where ct.card_category_id in (1, 2)
and cp.card_type_id = ct.id
and cp.par_value in (100, 200, 300, 500, 100);
begin
for card in s_card loop
if card.par_value = 100 then
insert into t_card_sysbook values (seq_t_card_sysbook.nextval, 'CARD_STYLE', '福', card.codeValue, 1, '福', sysdate, null, null, null);
insert into t_card_sysbook values (seq_t_card_sysbook.nextval, 'CARD_STYLE', '禄', card.codeValue, 1, '禄', sysdate, null, null, null);
insert into t_card_sysbook values (seq_t_card_sysbook.nextval, 'CARD_STYLE', '寿', card.codeValue, 1, '寿', sysdate, null, null, null);
insert into t_card_sysbook values (seq_t_card_sysbook.nextval, 'CARD_STYLE', '喜', card.codeValue, 1, '喜', sysdate, null, null, null);
end if;
end loop;
close s_card;
commit;
end;违反了t_card_sysbook 的主键唯一约束 在seq_t_card_sysbook.nextval获取序列的时候难道不COMMIT之前都是取的一样的?
把这一句去掉