avatar
database triggers# Database - 数据库
b*e
1
here's a problem i have.. a stupid software vendor P stores
their date format in unix epoch (seconds from 1/1/1970) and
all other applications we have can only handle standard
oracle dates (MM/DD/YYYY). so in order to make them talk to
each other i have to add a column (oracle_date) to the table
used by software P. and every time that software does an
insert or update i want to make sure my additional column
gets updated as well..
so i wanted to use a database trigger on this table..
CREATE TRIG
avatar
s*l
2

Use INSTEAD OF Trigger and try it. Then I think it will be
OK.

【在 b****e 的大作中提到】
: here's a problem i have.. a stupid software vendor P stores
: their date format in unix epoch (seconds from 1/1/1970) and
: all other applications we have can only handle standard
: oracle dates (MM/DD/YYYY). so in order to make them talk to
: each other i have to add a column (oracle_date) to the table
: used by software P. and every time that software does an
: insert or update i want to make sure my additional column
: gets updated as well..
: so i wanted to use a database trigger on this table..
: CREATE TRIG

avatar
b*e
3
i changed BEFORE to instead of.. still same error :(

【在 s***l 的大作中提到】
:
: Use INSTEAD OF Trigger and try it. Then I think it will be
: OK.

avatar
s*l
4
CREATE TRIGGER tt_trigger AFTER INSERT OR UPDATE OF
unix_date
ON tt_test
FOR EACH ROW
BEGIN
update tt_test set oracle_date =
unix_to_ora(:new.unix_date);
END;
Maybe (update tt_test set oracle_date =
unix_to_ora(:new.unix_date);) is enough.
See if this works. The original trigger will cause infinite
trigger events in theory, so maybe that is why it cause
error.
This one will not cause infinite trigger events.
And also, BEFORE is surely not what you want. The PL/SQL
statements

【在 b****e 的大作中提到】
: i changed BEFORE to instead of.. still same error :(
avatar
s*k
5
I think whatever you change before into after or instead of,
you will
get an ora--mutating table error for trigger should refer to
the same
row that you just fired trigger. If you really need using
trigger to
work around your problem, why not create a table to store
the primary
key in your table of P and oracle date corresponding to the
unix time?
You can populate it by create ... select.... into...

【在 s***l 的大作中提到】
: CREATE TRIGGER tt_trigger AFTER INSERT OR UPDATE OF
: unix_date
: ON tt_test
: FOR EACH ROW
: BEGIN
: update tt_test set oracle_date =
: unix_to_ora(:new.unix_date);
: END;
: Maybe (update tt_test set oracle_date =
: unix_to_ora(:new.unix_date);) is enough.

avatar
b*e
6
i was hoping to avoid that extra table and extra join in my
program..
but i guess until oracle comes out with column-level-trigger
that's
the only thing i can do now..
whoever works for oracle.. consider this an enhancement
request :)

【在 s*k 的大作中提到】
: I think whatever you change before into after or instead of,
: you will
: get an ora--mutating table error for trigger should refer to
: the same
: row that you just fired trigger. If you really need using
: trigger to
: work around your problem, why not create a table to store
: the primary
: key in your table of P and oracle date corresponding to the
: unix time?

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。