guoyubo1231 2019-04-03 18:44 采纳率: 0%
浏览 451
已结题

oracle用游标将A表的字段和B表3个字段匹配,匹配到就将B表的三个字段和A表的CODE字段输入到一张新表里面

将A表的字段和B表3个字段匹配,匹配到就将B表的三个字段和A表的CODE字段输入到一张新表里面。哪位大神能帮我补充一下我的逻辑,很少写游标这样的SQL。

图片说明

create or replace procedure testProc_guo
as
cursor cur is select keywords,brand_code from TMP_GUOSHOU_dim_test;
keywords varchar(100);
brand_code varchar(100);

cursor cur2 is select vehicle_brand_name,vehicle_series_name,vehicle_model_name from tmp_guoshou_guoyubo;
vehicle_brand_name varchar(100);
vehicle_series_name varchar(100);
vehicle_model_name varchar(100);

Begin

open cur;
fetch cur into keywords;
while cur%found loop
dbms_output.put_line(keywords);
fetch cur into keywords;
end loop;

open cur2; 
fetch cur2 into vehicle_brand_name,vehicle_series_name,vehicle_model_name;

--做一个A表和B表的判断 得到对应的 brand_code

--我想把 这个brand_code 和 名称 牌子 类型 这三个字段一起放到一个新表里面这块不太会写
loop
case when vehicle_brand_name like '%'||keywords||'%' or
vehicle_series_name like '%'||keywords||'%' or
vehicle_model_name like '%'||keywords||'%'
then cur1.brand_code
end
end loop;

insert into nmlz_veh_model_custom_guo (vehicle_brand_name,vehicle_series_name,vehicle_model_name,brand_code)
values (cur2.vehicle_brand_name,cur2vehicle_series_name,cur2vehicle_model_name,cur.brand_code)

close cur;
close cur2;
Exception
When others then
Rollback;
End;

  • 写回答

4条回答 默认 最新

  • devmiao 2019-04-03 19:01
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。