If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > using trigger to update one table from other table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-13-11, 21:36
marcos_Brz marcos_Brz is offline
Registered User
 
Join Date: Aug 2011
Posts: 3
using trigger to update one table from other table

Hi guys,

I'm thinking of how could solve this problem with trigger. I'm working on this two tables

CREATE TABLE book_rooms
(Idbookroom int AUTO_INCREMENT not null,
IdHost int not null,
IdAccommododation int not null,
booking_date Date not null,
InitialDate Date not null,
EndDate not null,
Status varchar(10) not null check (Estado in (‘active’, ‘Cancelled’)),
PRIMARY KEY (Idbookroom),
FOREIGN KEY (IdHost) REFERENCES Hosts(IdHost),
FOREIGN KEY (IdAccommododation) REFERENCES Accommodations(IdAccommododation),
UNIQUE(IdHost, IdAccommododation, booking_date))


TABLE Accommodations
(IdAccommododation int AUTO_INCREMENT not null,
name varchar(20) not null,
high_season_price not null numeric (5,2),
low_season_price not null numeric (5,2),
Status varchar(12) not null ((status = 'occupied') or (estado = 'available')
or (estado = 'maintenance')),
PRIMARY KEY (IdAccommododation),
UNIQUE(name)),


I'm trying to use trigger to do the following,

cancel the booking of an accommodation, since the customer do the host (status = "Cancelled"). Changing the state of accommodation to "occupied".


no success till now.
Reply With Quote
  #2 (permalink)  
Old 09-14-11, 05:50
arvindps arvindps is offline
Registered User
 
Join Date: Aug 2011
Posts: 27
pls. post your question with a sample data, as to what is the input data and where is the effect ?

BTW : triggers are well established concept, the only question here is the langauge although pl/sql is popular, still many algorithms are also developed in C language

Postgresql supports both c and pl/sql
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On