[英]Get exactly inserted date_from and date_to
I am working in an application in which I need to filter policy by date. 我在一个需要按日期过滤策略的应用程序中工作。 For example if user enter
date_from:'21-jul-2017'
and date_to:'21-jul-2019'
it should display all policies which were created in this period. 例如,如果用户输入
date_from:'21-jul-2017'
和date_to:'21-jul-2019'
,则应显示在此期间创建的所有策略。
So far what I did: 到目前为止,我做了什么:
cursor o1 is
select substr(tarifa,1,2), count(*)
from pol p, uvod u, doppov d
WHERE (izdavanje >=:prebacivanje.od) AND (izdavanje<=:prebacivanje.do)
and izdavanje>='01-jul-07'
and p.orgjed = u.sorgz (+)
and DATUM_PREKIDA is not null
and p.polica=d.polica and d.pov_dopl='P'
and d.status='F'
and cisti_ao(p.polica)!=0
group by substr(tarifa,1,2);
:prebacivanje.od
and :prebacivanje.do
are date_from
and date_to
. :prebacivanje.od
和:prebacivanje.do
是date_from
和date_to
。 Both are DATE fields in the database. 两者都是数据库中的DATE字段。
So I need to modify this query to return inserted date_from
and date_to
depending of what user entered. 因此,我需要修改此查询以根据用户输入的内容返回插入的
date_from
和date_to
。
As this is a cursor which exists somewhere in a form, that code should probably be executed somehow . 由于这是一个存在于表单中某处的游标,因此该代码可能应该以某种方式执行。 Is it when you push a button, or what?
按下按钮时是什么?
Anyway: although you never said what the problem is (do you get an error? If so, which one? ORA-xxxxx, FRM-xxxxx?) (my guess is that query doesn't return anything), it seems that parameters bother you. 无论如何:尽管您从未说过问题出在哪里(是否出错?如果是,是哪个错误?ORA-xxxxx,FRM-xxxxx?)(我猜是查询什么都不会返回),但似乎参数很麻烦您。
Query - as is - is correctly written. 查询-按原样-正确编写。 Those columns' datatype is
DATE
- that's what items' datatype should be as well. 这些列的数据类型为
DATE
这也应该是项目的数据类型。 If it is not (but a CHAR
), you'll have to convert it to DATE
using TO_DATE
, eg 如果不是(而是
CHAR
),则必须使用TO_DATE
将其转换为DATE
,例如
WHERE izdavanje >= to_date(:prebacivanje.od, 'dd-mon-yy')
AND izdavanje <= to_date(:prebacivanje.do, 'dd-mon-yy')
AND izdavanje >= to_date('01-jul-07' , 'dd-mon-yy')
In order to make sure which format mask to use, display items' values at the beginning of that PL/SQL procedure, using the MESSAGE
built-in: 为了确保使用哪种格式掩码,请使用内置的
MESSAGE
在该PL / SQL过程的开头显示项目的值:
declare
cursor o1 is ...
begin
message('od = ' || :prebacivanje.od);
message('do = ' || :prebacivanje.do);
... the rest of your code goes here
end;
Generally speaking, your best option is to make sure that datatypes match; 一般来说,最好的选择是确保数据类型匹配。 otherwise, you have to take care about conversion or (worse) rely on implicit conversion Oracle will try to perform;
否则,您必须注意转换,否则(更糟糕)依赖于Oracle将尝试执行的隐式转换; sometimes it'll succeed, sometimes not.
有时会成功,有时却不会。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.