473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Creating A Trigger

2
Hallo,
I am new on this forum but I have an urgent problem. How can I

1. Create a trigger which has the following characteristics:
• It should be named reorder.
• It should fire after an update of the qty column on the stock table, if the new
value of qty is <= 5.
• New should be referenced as n.
• The triggered action should insert the values n.itemno and current timestamp
into the reorder table,
whereby when an inventory item in the STOCK table falls below a quantity of 6, the REORDER table will have a row inserted.

Any kind of help is very much appreciated.
Jan 6 '07 #1
1 1591
jai80
30
Hallo,
I am new on this forum but I have an urgent problem. How can I

1. Create a trigger which has the following characteristics:
• It should be named reorder.
• It should fire after an update of the qty column on the stock table, if the new
value of qty is <= 5.
• New should be referenced as n.
• The triggered action should insert the values n.itemno and current timestamp
into the reorder table,
whereby when an inventory item in the STOCK table falls below a quantity of 6, the REORDER table will have a row inserted.

Any kind of help is very much appreciated.
hi jkag,

Check out the Trigger i have developed in sqlserver 2000.

sample tables used:
create table stock
(
itemid int identity(1,1) primary key,
prdname varchar(100),
qty int,
)

create table reorder
(
reoid int identity(1,1) primary key,
itemid int,
prdname varchar(100),
qty int,
currdate timestamp
)

create Trigger ReorderTrigg
on stock
for update
as
begin
insert into reorder(itemid,prdname,qty) select itemid,prdname,qty from stock where qty<=5
end
go

Go through the trigger and do let me know if it has solved ur query. If not also, pm me your problem. I shall try it. Gud Luck!

cheers,
jai
Jan 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: moklet | last post by:
i've been trying to create an insert/update trigger on v_$session but with no success. following is my code: 1 create or replace trigger trg_module 2 instead of insert or update on t_$session...
7
by: Justin | last post by:
I am extremely new at SQL Server2000 and t-sql and I'm looking to create a simple trigger. For explanation sake, let's say I have 3 columns in one table ... Col_1, Col_2 and Col_3. The data type...
1
by: efinney | last post by:
Hi, I'm a newbie to sql server and this may be a really dumb question for some you. I'm trying to find some examples of sql server triggers that will set columns (e.g. the created and modified...
24
by: jonathon | last post by:
Hi all, I have a web app with a popup window for entering data. I don't want to access the web every time this window is opened, as most of the app is AJAX. But I can't figure out how to open...
3
by: gimme_this_gimme_that | last post by:
Hi, Start up db2 8.2 as "db2 -td@" and execute the following command : CREATE OR REPLACE TRIGGER "BZ".ALERT_CREATED_DATE BEFORE INSERT ON TS_ALERTS REFERENCING OLD AS OLD NEW AS NEW FOR...
5
by: Peter Erickson | last post by:
I am running postgresql 7.4.2 and having problems creating a trigger function properly. I keep getting the following error: ERROR: OLD used in query that is not in rule I have a table called...
2
by: Scott Cain | last post by:
Hello, I am trying to create audit tables for all of the tables in my database. The function, table and trigger create statements are below. Apparently, I am not doing it quite right, because I...
6
by: | last post by:
Here's the scenario. This is going to live in SharePoint, but it's an ASP/HTML issue I think. I need to be able to host an existing portlet in a sharepoint window. The trick is that I need to...
3
by: ramesh1210 | last post by:
please help me, I had created a table, CREATE TABLE THETABLE ( id_num int IDENTITY(1,1), DT datetime, NM varchar(30) )
2
by: popprem | last post by:
Hi, I have to feed database A from database B which are in different machines but in the same network when a insert/update occurs on database B. I decided to use trigger for this and was trying...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.