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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I use an SQL query in a column/table constraint

Status
Not open for further replies.

sin1965

Programmer
Nov 6, 2005
46
GB
hi all
is it possible to use an SQL query in a column or table constraint. I haven't been able to find any info for this. It seems that only logical evaluation of simple expressions is allowed.
If that is so, then I assume that I will need to use a stored procedure acting on updates inserts and deletes.
any help will be most appreciated
steve
 
sin,

no you can't, and you shouldn't attempt it.

See Tom Kyte's web site for details of function based indexes, which are fairly clever, and may do some of what you want.

Your surmise is correct, you can only use Oracle's built in functions such as upper, instr, substr, is not null etc. in constraints.

If you need to use stored procedures to handle your data integrity, this is usually a sign that the tables are inadequately normalised. If you boil the design down to lots of simple tables, then often lots of simple constraints will do what you need.

Obviously genuinely complex business logic can only be done by stored procedures, but this should not be mistaken for data integrity. The two overlap, but are not the same.

If you have specific requirements, post, and I'll be glad to help.

Regards

Tharg

Grinding away at things Oracular
 
Sin said:
I will need to use a stored procedure acting on updates inserts and deletes.
I presume (and hope) that by "stored procedure" you mean a database trigger, right?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Hi
My initial enquiry was just to confirm that queries cannot be used in constraints. you have answered my ?
Thank you for you replies.
steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top