简体   繁体   中英

oracle.ManageddataAccess throws ORA-00928: missing SELECT keyword while inserting data

I am connecting to a remote Oracle DB and using Oracle.ManageddataAccess.dll to perform update and insert. I am able to update data to it but while I'm trying to insert it throws ORA-00928: missing SELECT keyword exception but I'm just trying to insert into it.

string cmdQuery = string.Format(@"insert into HKSTF087.FUELCHARGES ( [QTM_ID] ,[TITLECODE] ,[FUELCHARGERATE] ,[ISSPECIALRATE] ,[EFFECTIVEFROMDATE] ,[EFFECTIVETHRUDATE] ,[CREATEDBY] ,[CREATEDDATE] ,[UPDATEDBY] ,[UPDATEDDATE]) values ({0}, '{1}', {2}, {3}, TO_DATE('{4:MM/dd/yyyy HH:mm:ss}', 'mm/dd/yyyy hh24:mi:ss'), '{5}', '{6}', TO_DATE('{7:MM/dd/yyyy HH:mm:ss}', 'mm/dd/yyyy hh24:mi:ss'), {8}, {9})", mtcRate.QTM_ID, mtcRate.TITLECODE, newDefaultFuelRate, 0, providedEffectiveFromDate, "2099-12-31 00:00:00.0000000", "system", DateTime.Now, "null", "null");

and it would look like

insert into HKSTF087.FUELCHARGES ( [QTM_ID] ,[TITLECODE] ,[FUELCHARGERATE] ,[ISSPECIALRATE] ,[EFFECTIVEFROMDATE] ,[EFFECTIVETHRUDATE] ,[CREATEDBY] ,[CREATEDDATE] ,[UPDATEDBY] ,[UPDATEDDATE]) values (19874, 'AARC', 19.1, 0, TO_DATE('08/15/2017 00:00:00', 'mm/dd/yyyy hh24:mi:ss'), '2099-12-31 00:00:00.0000000', 'system', TO_DATE('08/30/2017 17:25:05', 'mm/dd/yyyy hh24:mi:ss'), null, null)

and when hits ExecuteNonQuery() it throws the ORA-00928: missing SELECT keyword exception.

here's the query using which I am able to insert the Oracle DB from a Link service using SQL server

INSERT INTO MTCT..HKSTF087.FUELCHARGES
       ([QTM_ID]
       ,[TITLECODE]
       ,[FUELCHARGERATE]
       ,[ISSPECIALRATE]
       ,[EFFECTIVEFROMDATE]
       ,[EFFECTIVETHRUDATE]
       ,[CREATEDBY]
       ,[CREATEDDATE]
       ,[UPDATEDBY]
       ,[UPDATEDDATE])
 VALUES
       (4446
       ,'ABCD'
       ,12
       ,0
       ,getdate()
       ,'2099-12-31 00:00:00.0000000'
       ,'system'
       ,getdate()
       ,null
       ,null)

and it would look like

 insert into HKSTF087.FUELCHARGES 

is different than your full example.

 insert INTO MTCT..HKSTF087.FUELCHARGES 

Also getdate() is not a known function on oracle but this might not be a problem when using linked server. I am not sure about that

And as also mentioned in comments oracle needs "" instead of []

[QTM_ID] ,[TITLECODE] should be "QTM_ID" ,"TITLECODE"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM