473,387 Members | 1,942 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,387 software developers and data experts.

PL/SQL Trigger Restrictions

129 100+
I'm trying to use PL/SQL to create a trigger that will stop double booking entries. Based on a duration field and a start time.
Expand|Select|Wrap|Line Numbers
  1.  
  2. Create or Replace Trigger LeaseChk
  3. Before insert on Lease
  4.  
  5. Begin
  6.  
  7. IF :NEW.StartDate and :NEW.Duration >= :OLD.StartDate and NEW.Duration (Some sort of Between Date Function i think) 
  8. Where :NEW.PropertyID and :NEW.RoomID = :OLD.PropertyID and :OLD.RoomID
  9. Then
  10. RAISE_APPLICATION_ERROR (-20500, 'There is already a Lease created for this Property and Room for this time');
  11. End IF;
  12. END;
  13. /
  14.  
Any help would greatly be appreciated!
Mar 28 '08 #1
3 3680
debasisdas
8,127 Expert 4TB
What do u mean by double booking entries

write the syntax correctly.

check for some sample in the how to section of the forum.
Mar 29 '08 #2
Constantine AI
129 100+
I have 3 criterias that need checking against; PropertyID, RoomID and StartDate with a calculated Duration. In terms of having a Lease on a Property, for example

TenantID PropertyID RoomID StartDate Duration(Weeks) EndDate
1 1 1 29/04/2008 10 08/07/2008
2 1 1 06/05/2008 12 29/07/2008

I would like a stored procedure / trigger to check the input of TenantID 2 before insertion and bringing up a message that the PropertyID and RoomID are booked out for their chosen Dates. I need it to calculate the date duration and see that the previous booking has already taken those date periods so therefore the insertion should not complete until they have chosen a different time frame or a different Property or Room. I have thought of Date_Between and using the :OLD and :NEW row syntax. But i can't figure out how to structure the BEGIN statement other than what my previous exaple looks like. Hope this explains my situation better! Thanks again.
Mar 29 '08 #3
amitpatel66
2,367 Expert 2GB
Your trigger is syntatically incorrect. You need to first correct all the syntax errors and check if your trigger functions correctly!!
Mar 29 '08 #4

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

Similar topics

6
by: Scott CM | last post by:
I have a multi-part question regarding trigger performance. First of all, is there performance gain from issuing the following within a trigger: SELECT PrimaryKeyColumn FROM INSERTED opposed...
3
by: robert.waters | last post by:
Hi, I would like to execute code when the body's onload event is triggered. No problem to include a one-line script (such as onload="alert()") but require more complexity. I cannot include this...
2
by: Shailendra Batham | last post by:
Hello Gurus, I want to put some restrictions on my attribute tag in my XML Schema, anyone out there have any idea how to do that. here is my XML and the XML Schema <?xml version="1.0"...
6
by: Mary | last post by:
We are developing a DB2 V7 z/OS application which uses a "trigger" table containing numerous triggers - each of which is activated by an UPDATE to a different column of this "trigger" table. When...
9
by: Raquel | last post by:
Following is a simple trigger definition: CREATE TRIGGER TRIG_EMPLOYEE_1 AFTER UPDATE OF SALARY ON DB2ADMIN.EMPLOYEE FOR EACH STATEMENT MODE DB2SQL CALL DB2ADMIN.SQLSP10( ) This gives an...
0
by: JohnO | last post by:
Thanks to Serge and MarkB for recent tips and suggestions. Ive rolled together a few stored procedures to assist with creating audit triggers automagically. Hope someone finds this as useful as...
9
by: Ots | last post by:
I'm using SQL 2000, which is integrated with a VB.NET 2003 app. I have an Audit trigger that logs changes to tables. I want to apply this trigger to many different tables. It's the same trigger,...
1
by: Paul van Brouwershaven | last post by:
Hi All, I'm struggling with the WDSL restrictions in PHP/SOAP for a while know. I would like to create some simple restrictions in my WDSL file. The script are running both on the same server...
11
by: tracy | last post by:
Hi, I really need help. I run this script and error message appeal as below: drop trigger log_errors_trig; drop trigger log_errors_trig ERROR at line 1: ORA04080: trigger 'LOG_ERRORS-TRIG'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.