错误:ORA-00917:缺少逗号00917. 00000 - “缺少逗号”

时间:2015-11-30 09:06:35

标签: sql oracle sql-insert

我错过了逗号错误,但我错过了逗号?

DELETE FROM user_sdo_geom_metadata WHERE TABLE_NAME = 'VIEW_POINT';
INSERT INTO user_sdo_geom_metadata
(TABLE_NAME,
 COLUMN_NAME,
 DIMINFO,
 SRID)
 VALUES (
'VIEW_POINT',
'GEOMETRY',
 MDSYS.SDO_DIM_ARRAY( -- upper and lower bounds for the view, tolerance
  MDSYS.SDO_DIM_ELEMENT('X', -180, 180, 0.5),
  MDSYS.SDO_DIM_ELEMENT('Y', -90, 90, 0.5)),
  SRID FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME ='AG_POINTS'
)
;
 commit;

2 个答案:

答案 0 :(得分:1)

使用INSERT INTO..SELECT语法

INSERT INTO USER_SDO_GEOM_METADATA
(TABLE_NAME,
 COLUMN_NAME,
 DIMINFO,
 SRID)
 SELECT  
'VIEW_POINT',
'GEOMETRY',
 MDSYS.SDO_DIM_ARRAY( -- upper and lower bounds for the view, tolerance
  MDSYS.SDO_DIM_ELEMENT('X', -180, 180, 0.5),
  MDSYS.SDO_DIM_ELEMENT('Y', -90, 90, 0.5),
  SRID FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME ='AG_POINTS'
)
;

答案 1 :(得分:1)

当插入数据的来源是SELECT语句时,您无法使用values子句:

INSERT INTO user_sdo_geom_metadata
  (table_name, column_name,diminfo, srid)
SELECT 'VIEW_POINT',
       'GEOMETRY',
       mdsys.sdo_dim_array( -- upper and lower bounds for the view, tolerance
         mdsys.sdo_dim_element('X', -180, 180, 0.5),
         mdsys.sdo_dim_element('Y', -90, 90, 0.5)),
       srid 
FROM user_sdo_geom_metadata 
WHERE table_name = 'AG_POINTS'