I'm a newbie in oracle 10g - I was hoping if some one could walk me through writing a trigger function for this particular problem:
the scenario:
" ... the practice is called backdating because an executive manages to move the date of a stock option back in time, presumably to when the stock price was lower. Stock options grant the recipient the right to buy shares at the stated price after a certain period of time has gone by. If the market price is higher than the so-called strike price, the employee makes money. Find a way to lower the price of the grant - by moving back the grant date during a rising market, for example - and the option is worth even more."
the policy has to be:
The exercise date cannot be more than 3 days either before or after the grant date. Write a database trigger that does not allow entering a new grant record or modifying an existing one that violates this policy.
So I've written: -
create or replace trigger date_violation
-
before insert or update on option_grants
-
for each row
-
-
declare
-
-
date_diff number;
-
-
begin
-
-
date_diff := exercise_date - grant_date;
-
if (abs(date_diff) >= 3)
-
-
then
-
-
raise_application_error(-20003, 'Check date. Date cannot be more than 3 days after or before the grant date.');
-
-
end if;
-
-
end;
-
/
-
--but I'm getting this error: -
LINE/COL ERROR
-
-------- -----------------------------------------------------------------
-
7/1 PL/SQL: Statement ignored
-
7/14 PLS-00201: identifier 'EXERCISE_DATE' must be declared
-
------------------------------------------
I'm not sure what to define.
Here's what my table looks like: -
-
create table option_grants
-
(grant# varchar2(4),
-
grant_date date,
-
exercise_date date,
-
emp_id number(9),
-
stock_symbol char(3),
-
strike_price number(5,2));
-
-
insert into option_grants
-
values ('A234', '25-Jan-04', '23-Jan-04', 123456789, 'XYZ', '12.54');
-
insert into option_grants
-
values ('A345', '23-Mar-05', '23-Mar-05', 666555444, 'XYZ', '18.22');
-
insert into option_grants
-
values ('B456', '15-Apr-06', '15-Apr-06', 123456790, 'XYZ', '13.79');
-
insert into option_grants
-
values ('C956', '24-Dec-06', '23-Dec-06', 666555444, 'XYZ', '9.75');
-
I know that this is alot ... I really appreaciate the help.
Thank you and please have an outstanding day.
2 2181
Hey - To whom it concerns... I figured out my issue... I'm an idiot -
create or replace trigger date_violation
-
before insert or update on option_grants
-
for each row
-
-
declare
-
-
date_diff number;
-
-
begin
-
-
date_diff := :new.exercise_date - :old.grant_date;
-
-
if (abs(date_diff) >= 3)
-
-
then
-
-
raise_application_error(-20003, 'Check date. Date cannot be more than 3 days after or before the grant date.');
-
-
end if;
-
-
end;
-
/
-
i like ur post. this example help me to improve my trigger :) i'm new in oracle
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ryan |
last post by:
Hello,
I am pretty much a newbie with SQL server. I have what is probably a
pretty stupid question. In SQL Enterprise manager, is there a way to
easily see all triggers, or, even better, all tables and there
associated triggers? I suppose at the least in a way similar to
viewing all saved functions or views.
Thanks,
Ryan
|
by: support |
last post by:
Do you need to monitor websites for changes?
iSpySiteWatch (http://www.ispysitewatch.com) is an Automated WebSite
Monitoring system that can track changes on most websites.
We've tested it to work with the major online Auction sites (for tracking
online bids), like eBay.com,
uBid.com, OnSale.com, lastminute.com auctions, Yahoo! Auctions, qxl.com,
gutterbids.com - and it
may work with many more!
|
by: anjana sisodia via SQLMonster.com |
last post by:
I have an area on our website where users can customize what data fields they
want to see displayed from a list of about 50 different fields. I have a
query that has about 50 subqueries to pull all this info and it has just got
to be extemely slow...sometimes even times out. I need to pull alot of data
from different tables and the only solution i can think of is to create
triggers on the different tables that i want to pull and store...
|
by: santiago538 |
last post by:
Hi,
Is there any way to specify which monitor a Window.open() will launch a
new browser window in on systems with more than one display. It would
only need to work with Mozilla browsers, and not IE. Thanks!
|
by: Henry |
last post by:
I am not really sure what news group this should be posted to. It has to
do
with a visual studio install project for a c# application.
We have noticed that if any of the files installed by the installer are
moved or deleted that this automatically triggers the installer the next
time the application is started.
While this would appropriate if the file in question were an executable, the
files are actually report files. Clients want to...
| |
by: Bruce |
last post by:
I have several user defined functions which are referenced in triggers
and views. For software upgrades, I need to be able to drop the
triggers and views which reference these user defined functions, then
drop and recreate the user defined functions, then recreate all the
views and triggers. I don't imiagine I'm the first person who needed
to do this, and I don't have a lot of db2 experience, so I wanted to
see if there is a common or...
|
by: sushi |
last post by:
Hello,
I have to monitor a remote server for functions such as CPU
Utilization etc. I am using System.Management namespace for the same.
But when I try to execute the following code, it gives
System.UnauthorizedAccessException though the user which I have provided is a
valid domain user having administratice rights on that computer.
|
by: mafaisal |
last post by:
Hi experts
I am Using Sql Server 2005
Hw to Create & call of triggers in sqlserver
I have Table salesMast,salesdet,stock
When after insertion in salesdet stock is minus & when cancel sales stock plus
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |