insert into 子查询问题

wxkang123 2010-01-13 02:21:25
大家有没有遇到这种情况,insert into加子查询插入数据时。子查询数据正确,但是插入表汇中后,表中某字段出现问题。
我出现的问题是表中某字段只插入了一个值,而且是所有行都插入了该值。
...全文
479 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
wxkang123 2010-01-13
  • 打赏
  • 举报
回复
会不会是表关联过多,我现在正试着字段分开插入
wxkang123 2010-01-13
  • 打赏
  • 举报
回复
忘了了 改语法了 见谅
wxkang123 2010-01-13
  • 打赏
  • 举报
回复
好吧
老板莫怪我
l_sql_stmt :=
INSERT INTO WXK_TEMP_TERM_DATA
(
GROUP_TERM_ID,
PARAMETER_ID,
TYPE_DISTRICT,
TYPE_NAME,
VALUE
)
select c.id GROUP_TERM_ID,
d.id PARAMETER_ID,
e.id TYPE_DISTRICT,
trim(concat(trim(a.term_type),trim(a.term_code))) TYPE_NAME,
round(f.value,2)
from CM_bill_TERM_SALE_DETAIL a,
CM_BILL_TERM_SALE_IDNO b,
cm_bill_term_agent c,
cm_stat_parameter d,
cm_bill_district e,
CM_TEMP_IDNOINFO f,
dm_dcustmsg_200912 g
where a.bill_cycle_id=200912
and c.bill_cycle_id=a.bill_cycle_id
and e.bill_cycle_id=a.bill_cycle_id
and b.bill_cycle_id=a.bill_cycle_id
and trim(f.id_no)=trim(b.id_no)
and trim(b.id_no)=trim(g.id_no)
and trim(a.mobile_no)=trim(b.phone_no)
and trim(a.group_id)=trim(c.group_id)
and d.code=decode(nvl(g.sm_code,null),'dn','3872','qq',
'3873','3871')
and trim(a.district_name)=trim(e.name)
and (months_between(to_date('200912','yyyymm'),
to_date(to_char(a.IMPORTED_TIME,'yyyymm'),'yyyymm'))+1)<=36;
EXECUTE IMMEDIATE l_sql_stmt
USING
l_bill_cycle_id,
l_bill_cycle_str;
iqlife 2010-01-13
  • 打赏
  • 举报
回复
插入语句贴出来
suiziguo 2010-01-13
  • 打赏
  • 举报
回复
OH,你确定一定以及肯定?
难道该表上有触发器不成?
zhengzeng 2010-01-13
  • 打赏
  • 举报
回复
路过
wxkang123 2010-01-13
  • 打赏
  • 举报
回复
情况是这样 表 a (假如表a中为子查询结果)
a 1
b 2
c 3
我把它插入表b后
a 1
b 1
c 1
语法都没问题,就是很奇怪啊
suiziguo 2010-01-13
  • 打赏
  • 举报
回复
而且是所有行都插入了该值

1 select列表里是否包含该字段?
2 该表该列上是否有缺省值(即默认值)?

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧