Oracle, insert multirows from subquery with more than one row

狂风中的少年 提交于 2019-12-06 07:27:10

Think you got to choose between

insert into table (a, b, c) VALUES(1, 2, 3)

and

insert into table (a, b, c) 
(SELECT x, y, z from table2)

You can have VALUES and SELECT mixed only (as pointed by an anomyous horse) when your select query returns only one column and one row !

By the way, use JOIN... to Join your tables (use of the WHERE clauses to join tables is rather a bad habit) :

INSERT INTO sed_reporte_generico 
(srg_usuario, 
srg_nombres,
srg_ape_paterno,
srg_ape_materno,
srg_objetivo,
srg_peso_ob,
srg_calf_ob)

(select us.su_st_usuario, us.su_st_nombres, us.su_st_ap_paterno, us.su_st_ap_materno,     ob.soc_st_descripcion, ob.soc_nr_peso,ob.soc_nr_calificacion 
FROM sed_objetivo ob 
JOIN sed_evaluacion ev  ON ob.se_evaluacion_pk = ev.se_evaluacion_pk
JOIN sed_usuarios us on  ev.su_colaborador_fk =     us.su_usuarios_pk)
);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!