SunQuest
           Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old April 14th, 2004, 12:20 PM
JasonBracy JasonBracy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 3 JasonBracy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Oracle Trigger help NEEDED!!!

I was hoping that someone in this forum might be able to assit me. I have for the life of me been tring how to create this trigger:

CREATE OR REPLACE TRIGGER prop_sold
AFTER INSERT ON Sale
FOR EACH ROW
BEGIN
IF PROP_ID := Property.PROP_ID THEN
UPDATE Property
Set Property.Sold = 'Y'
WHERE Sale.PROP_ID == Property.PROP_ID
ENDIF;
END;
/


When I insert a row into one table I want to update a column in the another with a Y. It seems simple enough but I can't figure it out for the life of me.

The following is what my two tables look like:

SALE

Name Null? Type
----------------------------------------- -------- ----------------------------
SALE_ID NOT NULL VARCHAR2(6)
SALES_AGENT NOT NULL VARCHAR2(6)
SALE_PRICE NOT NULL NUMBER
CUST_ID NOT NULL VARCHAR2(6)
PROPERTY_ID NOT NULL VARCHAR2(6)
DATE_CREATED NOT NULL TIMESTAMP(6)
DATE_MODIFIED NOT NULL TIMESTAMP(6)

PROPERTY

Name Null? Type
----------------------------------------- -------- ----------------------------
PROPERTY_ID NOT NULL VARCHAR2(6)
LISTING_AGENT NOT NULL VARCHAR2(6)
RESIDENCE_TYPE NOT NULL VARCHAR2(2)
NEW_PROPERTY NOT NULL CHAR(1)
EXISTING_PROPERTY NOT NULL CHAR(1)
LISTING_PRICE NOT NULL NUMBER(38)
NUM_BEDROOMS NUMBER
NUM_BATHROOMS NUMBER
SQ_FT NUMBER
ADDR_ID NOT NULL VARCHAR2(6)
DATE_CREATED NOT NULL TIMESTAMP(6)
DATE_MODIFIED NOT NULL TIMESTAMP(6)
SOLD CHAR(1)

Last edited by JasonBracy : April 14th, 2004 at 12:25 PM.

Reply With Quote
  #2  
Old April 14th, 2004, 01:57 PM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
Are you using Oracle? It does not seem that it is written in Oracle PL/SQL. Try to check out this code:

CREATE OR REPLACE TRIGGER prop_sold
AFTER INSERT ON Sale
FOR EACH ROW
BEGIN

UPDATE Property
Set SOLD = 'Y'
WHERE Property.PROPERTY_ID = new.PROPERTY_ID;

END;
/

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Oracle Trigger help NEEDED!!!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway