[英]Getting oci_execute(): ORA-01843: not a valid month invalid in php while inserting record?
I am getting oci_execute(): ORA-01843: not a valid month invalid. 我正在获得oci_execute():ORA-01843:有效月份无效。 Why it is giving it?
为什么给它?
INSERT INTO DETAIL (PPD_ID, PPD_ID,PPD_ENTRY_DATE, PPD_IGM_ID, PPD_DFM_ID, PPD_DRM_ID, PPD_HEIGHT, PPD_UOM_ID, PPD_FTM_ID, PPD_FRQ_ID, PPD_START_DATE_TIME, PPD_END_DATE_TIME, PPD_STATUS, PPD_STM_ID)
VALUES ('WS00318229',2440900,'29-12-2015',350,1,1,50,46,1,1,'29-12-2015','29-12-2015','PRESCRIBED',6)
When i am using the above query from php to insert record in to oracle database it is giving following error. 当我从php使用以上查询将记录插入到oracle数据库时,出现以下错误。
oci_execute(): ORA-01843: not a valid month invalid
But when i use the following query it is not giving any error and it is inserting record.How to solve this? 但是当我使用以下查询时,它没有给出任何错误,并且正在插入记录。如何解决这个问题? This error was already is there but i am not clear about the answers.Any ideas why it is like this.
这个错误已经存在,但是我对答案还不清楚。
INSERT INTO DETAIL (PPD_ID, PPD_ID,PPD_ENTRY_DATE, PPD_IGM_ID, PPD_DFM_ID, PPD_DRM_ID, PPD_HEIGHT, PPD_UOM_ID, PPD_FTM_ID, PPD_FRQ_ID, PPD_START_DATE_TIME, PPD_END_DATE_TIME, PPD_STATUS, PPD_STM_ID)
VALUES ('WS00318229',2440900,'29-DEC-2015',350,1,1,50,46,1,1,'29-DEC-2015','29-DEC-2015','PRESCRIBED',6)
You are inserting strings into DATE
columns. 您正在将字符串插入
DATE
列。 When you do that, oracle performs implicit conversion based on your NLS settings, specifically, nls_date_format
. 在执行此操作时,oracle将根据您的NLS设置(特别是
nls_date_format
执行隐式转换。 Evidently when you connect from php script and from some client you use (SQL*Plus, SQL Developer, what have you), your NLS settings differ. 显然,当您从php脚本和您使用的某些客户端(SQL * Plus,SQL Developer,您拥有的)连接时,您的NLS设置会有所不同。
You can check session parameters using following query. 您可以使用以下查询检查会话参数。
SELECT * FROM nls_session_parameters;
For date presented in format '29-DEC-2015'
nls_date_format
should be 'DD-MON-YYYY'
. 对于以格式
'29-DEC-2015'
表示的日期, nls_date_format
应该为'DD-MON-YYYY'
。 If it has some other value, you can change it using following query. 如果它具有其他值,则可以使用以下查询对其进行更改。
alter session set nls_date_format='DD-MON-YYYY'
Or you can explicitly convert string to date using TO_DATE
function and passing format as second parameter, but this will require your application code to be consistent in using only specified date format. 或者,您可以使用
TO_DATE
函数并将格式作为第二个参数传递,将字符串显式转换为日期,但这将要求您的应用程序代码在仅使用指定的日期格式时保持一致。
TO_DATE('29-DEC-2015', 'DD-MON-YYYY')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.