trigger codes:
create or replace trigger limitinsertbefor
before insert on student
for each row
when((sysdate-old.birthday)/365<18)
begin
insert into trigger_table values('update',:old.studentid,:new.studentid,sysdate,'student');
end limittinsertbefor;
// Table student structure
Name Type Nullable Default Comments
----------- ------------ -------- ------- --------
STUDENTID VARCHAR2(8)
STUDENTNAME VARCHAR2(8)
BIRTHDAY DATE Y
CLASSID VARCHAR2(12) Y
execution statement;
insert into student values('20053822','lanlan',to_date('19860825','yyyyhhdd'),'201001');
ERROR CODE:
ORA-00932: inconsistent datatypes: expected NUMBER got DATE
But if i get rid of this condition:when((sysdate-old.birthday)/365<18) this execution statement will run succeed.
Maybe this condition which when((sysdate-old.birthday)/365<18) doesn't work. but i can't find reason about this issue .
feel free pls help me ! thans
i very sorry that i don't have enough score with me so that i can't prove more score for this question.
SORRY!!!
问题补充:谢谢你的答案,很满意。
But:
select sysdate-to_date('19861103','yyyymmdd') from dual;
SYSDATE-TO_DATE('19861103','YY
------------------------------
8544.41739583333
上面是一个日期型-日期型,但是结果不是数字型吗.
thanks .
问题补充:suziwen 写道
这样写
create or replace trigger limitinsertbefor
before insert on student
for each row
when((to_number(sysdate-new.birthday))/365<18)
begin
insert into trigger_table values('update',:old.studentid,:new.studentid,sysdate,'student');
end limittinsertbefor;
insert into student values('20052422','lanlan',to_date('19960825','yyyyMMdd'),'201001');
日期相减后还是日期型,不能直接跟数字操作,得先转换成数字型
你代码里的when((sysdate-old.birthday)/365<18)
old.birthday应该是new.birthday
因为是插入的数据,没有老数据
insert into student values('20053822','lanlan',to_date('19860825','yyyyhhdd'),'201001');
里的yyyyhhdd应该为yyyyMMdd
谢谢你的答案,很满意。
But:
select sysdate-to_date('19861103','yyyymmdd') from dual;
SYSDATE-TO_DATE('19861103','YY
------------------------------
8544.41739583333
上面是一个日期型-日期型,但是结果不是数字型吗.
thanks .
相关推荐
4. **触发器(Trigger)**:在特定数据库事件发生时自动执行的PL/SQL代码。 5. **存储过程(Stored Procedure)**:预编译的PL/SQL代码块,可以封装复杂的业务逻辑并多次调用。 接下来,我们会学习如何使用SQL语句...
JIRA触发插件 该插件通过。 请考虑为该项目加注星标以显示您的 :red_heart: 和支持。特征 将注释添加到JIRA时触发构建 在JIRA中更新问题时触发构建 将JIRA Webhook POST数据转换为Jenkins参数 将JIRA标准自定义字段...
- Fixed issue #401: OnNodeClick event doesn't trigger in some case, coFixed set for a column - Modified #316 (concerning r498). The fix for #316 will only be applied in case toMultiSelect is set. If ...
Contents Overview 1 Lesson 1: Concepts – Locks and Lock Manager 3 Lesson 2: Concepts – Batch and Transaction 31 Lesson 3: Concepts – Locks and Applications 51 Lesson 4: Information Collection and ...
SP-6675, SP-6851 : Fixed out of memory exception that could trigger when processing table hints. SP-6707 : Rule ST002 no longer detects issue on column_alias=expression syntax. SP-6847 : Added support...
3. Fix the crash issue while user Ctrl + double click on an empty document. 4. Fix crash bug on loading dropbox settings. 5. Show progress window instead of a static window during FindInFiles and ...
- **JIRA Trigger Plugin** - **JiraTestResultReporter plugin** 其中,仅需安装基础的JIRA和JIRA Pipeline Steps插件,即可实现Jenkins向Jira同步comment信息。 2. **系统管理员配置** 管理员需在Jenkins的...
on : issue_comment jobs : deploy : steps : - uses : alexjurkiewicz/pr-comment-github-deployment@master env : GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} 参量 参数 需要 描述 trigger_phrase 可选的...
Running the motor in the negative direction on STM32F0 based designs with 1 shunt and Hall sensor configuration may trigger an overcurrent error. Fixed an issue found on ESC G4 and F3 inverter boards...
Build Systems: Renamed "keyfile" to "keyfiles", now accepting a list of files that can trigger the build system (e.g., ["Makefile", "makefile"]) Improved change detection for files that disappear and ...
This may cause some extra overhead depending upon what you are trying to do but it should be negligable since during the execution of a script there isn't anything going on that will trigger repeated...
3. **放入议程**:如果要表示某事被提上日程,可以使用"be put on the agenda",而"trigger"、"spark"、"arouse"等动词则表示引起或启动了某种讨论或行动。 4. **广泛的关注**:"arouse people’s wide concern"或...
20. cause的替换词有give rise to、lead to、result in或trigger,如:"Air pollution gives rise to respiratory problems." 21. 解释原因时,"There are several reasons behind sth" 可以替代 "reasons for sth...
This choice ensures flexibility for future upgrades or issue resolution, considering Python's open-source nature. Moreover, the backend management adopts a client-server (B/S) architecture, allowing ...
However, due to differences in power systems and electrical systems compared to conventional cars, ensuring safety during practical training is a crucial issue. 1. Hazards in New Energy Automotive ...
Fixed issue where memory blocks would get cut of before the page end Fixed some memory leaks Fixed some graphical issues in the addresslist Fixed rightclick on r8 and r9 in memoryview Fixed ...
To solve the automatic WiFi connection problem in Android 10, we need to use the new `WifiNetworkSpecifier.Builder` class to build a `WifiNetworkSpecifier` object, which can be used to trigger a ...