请告知我为什么我在qracle插入qqery beow是查询
时收到错误insert into RT_INVOICE (VERSION, PART_ID_BROKER, EMAIL_ID, ATTACHMENT_ID, INITIAL_AMOUNT, CURRENT_AMOUNT, GROSS_AMOUNT,
RECEIVED_DATE, COMMITTED_DATE, CREATEDDATE, UPDATEDDATE, SETTLEMENT_DATE, CURR_ISO_CODE, WQTY_CODE_CURRENT,
BROKER_REFERENCE, CREATED_BY, ENTITY, PRODUCT, BROKER_INV_REF, ASSIGNEE, RECEIPT_DATE, TRADE_COUNT, GST_PCT,
IS_GST_APPLIED, SOURCE_SYSTEM, DISCOUNT, MANUAL_INDICATOR, MANUAL_REFERENCE, PAYMENT_REFERENCE, QUERY_ASSIGNMENT,
Remarks, PARENT_INVO_ID, INVOICE_MONTH, ID) values (0, 40158334066, 0, 0, 22.0, 22.0, 22.0, '10 October 2016',
null, '2016-10-10 03:51:15', '2016-10-10 03:51:15', null, 'HKD', 'BrokerageManualReconciliationWFQueue',
'IRDOCT169694', 'bro_admin', 'PLC LONDON', 'IRD', 'wwwqqsd', '', '10 October 2016', 0, 0.0, 'false', 'GDS', 0.0,
'true', null, null, null, null, null, '2016-10', 13093090)
我得到的错误是
Error report: SQL Error: ORA-01843: not a valid month 01843. 00000 - "not a valid month" *Cause: *Action:
仅供参考,表的结构是
Name Null Type ID NOT NULL NUMBER(32) VERSION NOT NULL NUMBER(20) PART_ID_BROKER NOT NULL NUMBER(32) INITIAL_AMOUNT NOT NULL NUMBER(25,5) CURR_ISO_CODE VARCHAR2(20) CURRENT_AMOUNT NOT NULL NUMBER(25,5) SETT_ID NUMBER(32) RECEIVED_DATE NOT NULL DATE COMMITTED_DATE DATE SETTLEMENT_DATE DATE CREATEDDATE NOT NULL TIMESTAMP(6) UPDATEDDATE TIMESTAMP(6) WQTY_CODE_CURRENT NOT NULL VARCHAR2(100) BROKER_REFERENCE VARCHAR2(100) CREATED_BY NOT NULL VARCHAR2(30) SOURCE_SYSTEM NOT NULL VARCHAR2(20) INVOICE_MONTH VARCHAR2(30) ENTITY NOT NULL VARCHAR2(50) PRODUCT NOT NULL VARCHAR2(50) BROKER_INV_REF VARCHAR2(50) ASSIGNEE VARCHAR2(50) RECEIPT_DATE TIMESTAMP(6) TRADE_COUNT NUMBER GST_PCT NUMBER(25,5) IS_GST_APPLIED CHAR(1) PARENT_INVO_ID NUMBER(32) DISCOUNT NUMBER(25,5) MANUAL_INDICATOR CHAR(1) MANUAL_REFERENCE VARCHAR2(100) PAYMENT_REFERENCE VARCHAR2(100) QUERY_ASSIGNMENT VARCHAR2(100) REMARKS VARCHAR2(500) ATTACHMENT_ID NUMBER(32) EMAIL_ID NUMBER(32) GROSS_AMOUNT NOT NULL NUMBER(25,5)
答案 0 :(得分:1)
要将字符串转换为日期,请尝试使用to_date函数:
insert into RT_INVOICE (VERSION, PART_ID_BROKER, EMAIL_ID, ATTACHMENT_ID, INITIAL_AMOUNT, CURRENT_AMOUNT, GROSS_AMOUNT,
RECEIVED_DATE, COMMITTED_DATE, CREATEDDATE, UPDATEDDATE, SETTLEMENT_DATE, CURR_ISO_CODE, WQTY_CODE_CURRENT,
BROKER_REFERENCE, CREATED_BY, ENTITY, PRODUCT, BROKER_INV_REF, ASSIGNEE, RECEIPT_DATE, TRADE_COUNT, GST_PCT,
IS_GST_APPLIED, SOURCE_SYSTEM, DISCOUNT, MANUAL_INDICATOR, MANUAL_REFERENCE, PAYMENT_REFERENCE, QUERY_ASSIGNMENT,
Remarks, PARENT_INVO_ID, INVOICE_MONTH, ID) values (0, 40158334066, 0, 0, 22.0, 22.0, 22.0, to_date('10 October 2016', 'dd month yyyy', 'nls_date_language = american') ,
null, to_date('2016-10-10 03:51:15', 'yyyy-mm-dd hh24:mi:ss'), to_date('2016-10-10 03:51:15', 'yyyy-mm-dd hh24:mi:ss'), null, 'HKD', 'BrokerageManualReconciliationWFQueue',
'IRDOCT169694', 'bro_admin', 'PLC LONDON', 'IRD', 'wwwqqsd', '', to_date('10 October 2016', 'dd month yyyy', 'nls_date_language = american'), 0, 0.0, 'false', 'GDS', 0.0,
'true', null, null, null, null, null, '2016-10', 13093090)
答案 1 :(得分:0)
'10 October 2016'
,'2016-10-10 03:51:15'
和'2016-10-10 03:51:15'
是字符串。由于您的列是日期时间,因此它们应该是,Oracle需要转换您的字符串并尽可能地根据您当前的设置进行尝试。无论Oracle是否理解您的格式,这或多或少都是运气问题。
使用ANSI日期时间文字:
date '2016-10-10', null, timestamp '2016-10-10 03:51:15', timestamp '2016-10-10 03:51:15'