Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger Help

Status
Not open for further replies.

kilabru

Programmer
Oct 15, 2002
26
0
0
US
I have two tables, A & B.

In table A & B there is a column called location. In column B, there is also a column called status. In the application, I am entering a location from Table A. When I do this, I want to lookup the corresponding location in table B and return a null value if the status in table B is 'CLOSED'. In ACCESS, this would be done via DLOOKUP. I hope this makes since. I am assuming I will be using a trigger for this?

I hope someone can help?

Thanks
 

You don't need a trigger to do this, just a simple Select SQL statement like;

SELECT DECODE(b.status, 'CLOSED', NULL, b.status)
FROM tableA a, tableB b
WHERE a.location = b.location;

This will list all rows that exist in both tables.

But if you only want to lookup the status from table B, then, you only need to use table B but pass a location variable to get your desired status.

SELECT DECODE(b.status, 'CLOSED', NULL, b.status)
INTO var_status
FROM tableB b
WHERE b.location = var_location;


Robbie

"The rule is, not to besiege walled cities if it can possibly be avoided" -- Art of War
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top