由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - database triggers
相关主题
trigger vs. log ?how to include record deleted date into trigger?
SQL Server Trigger on System Base Table or Catalog ViewTrigger questions
扳机问题求助面试问题How would you improve table insert performance? (give five or more ideas)
oracle help?why this Trigger hang the Process *** thanks thanks
In MySQL, 如何在procedure里create trigger?谢谢了?德州招SQL Developer
PL/SQL, stored p, trigger etc..求教:Oracle trigger 中生成的数据如何送到stored procedure中?
oracle trigger question请教关于CREATE TRIGGER -愿意贡献伪币
MySQL Server 2k Question again!Create的时候有没有简单的方法?(oracle 8)
相关话题的讨论汇总
话题: trigger话题: oracle话题: date话题: table话题: database
进入Database版参与讨论
1 (共1页)
b****e
发帖数: 1275
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
s***l
发帖数: 9
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

b****e
发帖数: 1275
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.

s***l
发帖数: 9
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 :(
s*k
发帖数: 144
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.

b****e
发帖数: 1275
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?

1 (共1页)
进入Database版参与讨论
相关主题
Create的时候有没有简单的方法?(oracle 8)In MySQL, 如何在procedure里create trigger?谢谢了?
How to handle inserting value to Identity column in sql server 2005PL/SQL, stored p, trigger etc..
question: copy first N rows from table B to table A (DB2)oracle trigger question
SQL Server stupid questionsMySQL Server 2k Question again!
trigger vs. log ?how to include record deleted date into trigger?
SQL Server Trigger on System Base Table or Catalog ViewTrigger questions
扳机问题求助面试问题How would you improve table insert performance? (give five or more ideas)
oracle help?why this Trigger hang the Process *** thanks thanks
相关话题的讨论汇总
话题: trigger话题: oracle话题: date话题: table话题: database