错误消息:ORA-01841尝试按日期过滤记录
我正在使用Laravel应用程序使用Oracle数据库 我有记录
模型及其数据库表是items_view
它是一个数据库视图,现在我想用'Invh_dt'
column(这是日期类型)等于特定日期,所以我正在使用此错误:
$records = Record::where('INVH_DT', 'to_date(\'22/06/2022\' , \'DD/MM/YYYY\')' )->get();
但是我有一个错误:
错误代码:1841错误消息:ORA -01841 :(完整)年度必须在-4713和+9999之间,并且不是0位置:46语句:从“ tooks_view”中select * select * where“ inveh_dt” where'invh_dt“ where” =: p0> bindings:[to_date('22/06/2022','dd/mm/yyyy']]] 选择 * 从 “ ittem_view” 在哪里 “ Invh_dt” = to_date('22/06/2022','dd/mm/yyyy')
我尝试了此语句elect * epleion * elect * eflect * every_view“ where” wend Oracle SQL开发人员上的'dd/mm/yyyy')
它可以正常运行。 我尝试了其他日期格式,例如'yyyymmdd'
,并且在SQL开发人员中效果很好,同时给出了Laravel相同的错误。
I am using Oracle Database with Laravel application
I have Record
model and its database table is items_view
which is a Database View, now I want to get all records with 'INVH_DT'
column (which is of date type) equals to a specific date so I am using this:
$records = Record::where('INVH_DT', 'to_date(\'22/06/2022\' , \'DD/MM/YYYY\')' )->get();
but I have this error:
Error Code : 1841 Error Message : ORA-01841: (full) year must be between -4713 and +9999, >and not be 0 Position : 46 Statement : select * from "ITEMS_VIEW" where "INVH_DT" = :p0 >Bindings : [to_date('22/06/2022' , 'DD/MM/YYYY')]
select
*
from
"ITEMS_VIEW"
where
"INVH_DT" = to_date('22/06/2022', 'DD/MM/YYYY')
I tried this statement elect * from "ITEMS_VIEW" where "INVH_DT" = to_date('22/06/2022' , 'DD/MM/YYYY')
on Oracle SQL Developer and it works fine.
I tried other date formats like 'YYYYMMDD'
and it works fine on SQL Developer while giving the same error of Laravel.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道Laravel,但是由此产生的SQL命令看起来像这样:
其中
:P0
参数被to_date替换('22/06/2022','dd/mm/yyyy ')
。它不会那样工作。也许尝试一下:
I don't know Laravel, but the resulting SQL command looks like this:
where the
:p0
parameter is replaced withto_date('22/06/2022' , 'DD/MM/YYYY')
. It will not work that way.Maybe try this:
我发现Laravel通过查询构建器的
whereDate
条款其他条款这只是按预期工作:
I figured out that Laravel deals with this issue by Query builder's
whereDate
clause Additional Where Clausesand this just worked as expected: