Constraints between two or more tables
Dear all,
I have a general question, i searched in Google but i couldn’t find any result.
if i want to add constraints to a table it is easy , but what if in this "Check " part, i also want to consider records from another table? how it is possible?
like this , but it doesn't work actually in oracle 11g :
{code}
ALTER TABLE Country ADD CONSTRAINT "Country_CkHK1"
CHECK (population > ( select sum(ci.population) from city ci where ci.country=code group by code) ) ENABLE;
{code}
thank you in advance.
best,david
Hi,
The only kind of constraint that references 2 tables is a foreign key constraint. All other constraints only refer to 1 table. As Solomon said, you can't do what you want using only constraints.
You can DML create triggers on each table that read the relevant information from the other table, and raise an error if the DML would break your business rules. This would be easiest if you created a view that joined the 2 tables, and created an INSTEAD OF trigger on the view. Do all of the DML through the view, not the actual tables.
For this particular problem (if I understand it correctly), you might consider adding an excess_population column to the country table, that tells how much country.population exceeds the SUM of the related city.populations. This number must always be greater than 0, which you can enforce with a CHECK constraint. The triggers on each table can change excess_population so that it is always up-to-date.
Similar Messages
-
How can I make a server differ between two or more clients?
How can I make a server differ between two or more clients?
The clients can connect and talk to the server fine, but how can I make the server talk to one, two or all clients? i.e. what would be a good way to implement this?
Currently, the server listens for connections like this:
while (listening) {
try {
new ServerThread(this, serverSocket.accept()).start();
I guess one way would be to add the ServerThreads to a Hashtable with the client ID as key, and then get the ServerThread with the proper client ID, but this seems unnecessary complicated. Any ideas?Complicated was perhaps the wrong word, I should have
written something like it doesn't "feel" right. Or is
this a common and good way to solve communication
between a server and multiple clients?Thats pretty much how I do it. I normally use an array or ArrayList of Sockets instead of HashTable, with [0] being the first player etc.... Then you can communicate with exactly who you want. If you want to send bytes to all of them, just send the same thing to each socket individually (or is there a better way to do this?). -
How can I use TopLink for querys that have two and more tables?
I use TopLink today, and I can use one table to query, but how can I use TopLink for querys that have two and more tables?
Thank you for see and answer this question.You can write a custom SQL query and map it to an object as needed. You can also use the Toplink query language "anyOf" or "get" commands to map two tables as long as you map them as one to one (get command) or one to many (anyOf command) in the toplink mapping workbench.
Zev.
check out oracle.toplink.expressions.Expression in the 10.1.3 API -
Error 33172 occurred at Read & Write data transfer between two or more PF2010 controller
Hi,i need to do data transfer between two or more FP2010 controller.e.g. FP2010(A) & FP2010(B).
FP2010(A) need to transfer the measurement (from its I/O module) to FP2010(B) to do the data analysis.These data transfer should be synchronous btw two controller to prevent data lost.
From the vi used in the attachment,i encountered some problems at:
(1) Error 33172 occurred while publishing the data.Can i create and publish data under different item name?
(2) How to synchronies the read & write btw contorller?
All controller are communicating with each other directly without the need of a host computer to link them together
Is there any other method to do fast data transfer betwe
en controller?Hi YongNei,
You were succesful in omiting enough information to make it very difficult to answer!
Please post your example.
Please tell us what version of LV-RT you are using.
Please define what you concider "fast data transfer".
Have you concidered mapping the FP tags of FP2010(A) to FP2010(B) and vise versa?
WHat exactly has to be syncronized?
If you have something that is close to working, share that.
Well, that as far as I can go with the info you have provided. Depending on the details, what you are asking could be anything from trivial to impossible with the currently available technology. I just can't say.
It would probably be a good idea to start over with a fresh question (sorry) because not many people are going to know what a a "
PF2010" is and I can not guarentee that I will be able to get back to you personally until next week-end.
Trying to help you get an answer,
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction -
WHERE clause creating a join for two or more tables
The CS3 Dreamweaver book says that the WHERE clause can
create a join for two or more tables. The join was created, but the
data is repeating. I have searched the web and this forum and have
not found the answer.
My Master page filters the recordset by Style No and when a
customer clicks on a particular style, it sends him to the Detail
page. All the records are showing from all tables on the detail
page from the Dynamic List, except they are showing multiple times
(ex. Size table has 4 sizes and Color table has 2 colors - my Size
Drop Down list is showing 8 options and my Color Drop Down List is
showing 8 options) I have a Master Page with a recordset pointing
to a Detail Page using the same recordset.
Master page works perfectly.
Master Recordset SQL:
SELECT products.itemID, products.category, products.styleno,
products.name, products.description, products.ourprice,
products.imageTH, products.image, coloroption.color,
sizeoption.size
FROM products, coloroption, sizeoption
WHERE category = 'chefcoats' AND
products.styleno=sizeoption.styleno AND
products.styleno=coloroption.styleno
GROUP BY products.styleno
ORDER BY styleno ASC
The Detail Recordset:
SELECT products.itemID, products.category, products.styleno,
products.name, products.description, products.ourprice,
products.imageTH, products.image, sizeoption.size,
coloroption.color
FROM products, sizeoption, coloroption
WHERE itemID=colname AND products.styleno=sizeoption.styleno
AND products.styleno=coloroption.styleno
I tried using the GROUP BY on the detail page, but then it
only showed one size and color from the dynamic drop down list. I
tried changing the field name "styleno" in the other tables to be
unique, however, I was using the table identifer. I tried using the
JOIN command instead of the WHERE clause and that didn't help
either.
On the detail page, the customer is supposed to click on the
Size box and see sizes XSM - 6XL ONLY ONE TIME. and then be able to
click on the Color option and see White, Black, Red ONE TIME.
Is this possible?
Thank you for giving your time to read this.!
EvieDo you have a link we can look at to see what you are trying
to do?
Dave
"EviePhillips" <[email protected]> wrote in
message
news:[email protected]...
> The CS3 Dreamweaver book says that the WHERE clause can
create a join for
two
> or more tables. The join was created, but the data is
repeating. I have
> searched the web and this forum and have not found the
answer.
>
> My Master page filters the recordset by Style No and
when a customer
clicks on
> a particular style, it sends him to the Detail page. All
the records are
> showing from all tables on the detail page from the
Dynamic List, except
they
> are showing multiple times (ex. Size table has 4 sizes
and Color table has
2
> colors - my Size Drop Down list is showing 8 options and
my Color Drop
Down
> List is showing 8 options) I have a Master Page with a
recordset pointing
to a
> Detail Page using the same recordset.
>
> Master page works perfectly.
> Master Recordset SQL:
> SELECT products.itemID, products.category,
products.styleno,
products.name,
> products.description, products.ourprice,
products.imageTH, products.image,
> coloroption.color, sizeoption.size
> FROM products, coloroption, sizeoption
> WHERE category = 'chefcoats' AND
products.styleno=sizeoption.styleno AND
> products.styleno=coloroption.styleno
> GROUP BY products.styleno
> ORDER BY styleno ASC
>
> The Detail Recordset:
> SELECT products.itemID, products.category,
products.styleno,
products.name,
> products.description, products.ourprice,
products.imageTH, products.image,
> sizeoption.size, coloroption.color
> FROM products, sizeoption, coloroption
> WHERE itemID=colname AND
products.styleno=sizeoption.styleno AND
> products.styleno=coloroption.styleno
>
> I tried using the GROUP BY on the detail page, but then
it only showed
one
> size and color from the dynamic drop down list. I tried
changing the
field
> name "styleno" in the other tables to be unique,
however, I was using the
table
> identifer. I tried using the JOIN command instead of the
WHERE clause and
that
> didn't help either.
>
> On the detail page, the customer is supposed to click on
the Size box and
see
> sizes XSM - 6XL ONLY ONE TIME. and then be able to click
on the Color
option
> and see White, Black, Red ONE TIME.
>
> Is this possible?
>
> Thank you for giving your time to read this.!
> Evie
>
> -
How two or more table used in smartforms
Sir,
Like to know how can i perform calculation in smartfrom if the fields is numeric and use two table, and also know about it is useful to use inner join or any other method in smartform for working with two or more tables simultaneously.
plz, expalin with examplehi
you can use more than one table in smartform for that first you mention all the tables in the form interfaces and you have to mention the variables that you want to caliculate in the global definitions.
For caliculation right click on ant text and in that we have flow logic option in that we can select which type of code you want to write and you have to create those inbetween two text fields where the values are there and the other one is where you want to display the result.
in that code in input parameters we have to mention the variables which you want to use for caliculation and in output parameters mention the variables in which you want to store the result. And then we have to write the logic what ever we want.
I hope this information will help you
regards,
Sreelatha Gullapalli -
Working with two or more tables in Numbers
Working with two or more tables in Numbers
It is possible to write numbers or names in Table 1 B-2, B-3, B-4, B-5, B-6 etc. and automatically copy in Table 2 only B-2, B-4, B-9, B23 etc.
What do I need to do???
Thanks for the helpThe table on the left is named "Source" and on the right "Destination":
In the table "Destination" on the right:
B2=Source :: B2
select B2 and fill down -
Polling Two or More Tables using DB Adapter
Hi,
Is it possible to poll two or more tables using a db adapter at a time?Hi,
Is it possible to poll two or more tables using a db adapter at a time? -
Set a relation between two or more images
Is it possible to create a relation between two or more images?
For example: We have an image in three versions (rgb, cmyk, gray). If I find one of these, I would like to klick on a button like "show correspondend images". So I can see all versions of this images we ever saved.
Any idea?
Best regards!
RomanI don't think Lightroom handles cmyk images.
For rgb and gray, you can stack the images, or make the gray from a virtual copy of the rgb. In this way, simply unstacking the images results in your requested "show corresponding images". -
How to share the data between two or more frames
How to share the data between two or more frames based on the database relationship in JDeveloper?
You can pass data between frames by passing it as parameters.
That is when you are invoking another frame, pass your data as arguments through the constructor to that frame .
You can also achieve this through static or public methods, but static variables as we know is not suggested which might occupy more memory space.
Regards,
Srinivasan AShwath
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by [email protected]:
How to share the data between two or more frames based on the database relationship in JDeveloper? <HR></BLOCKQUOTE>
null -
Find gap between two dates from table
Hello All,
I want to find gap between two dates ,if there is no gap between two dates then it should return min(eff_dt) and max(end_dt) value
suppose below data in my item table
item_id eff_dt end_dt
10 20-jun-2012 25-jun-2012
10 26-jun-2012 28-jun-2012 There is no gap between two rows for item 10 then it should return rows like
item_id eff_dt end_dt
10 20-jun-2012 28-jun-2012
item_id eff_dt end_dt
12 20-jun-2012 25-jun-2012
12 27-jun-2012 28-jun-2012 There is gap between two rows for item 12 then it should return like
item_id eff_dt end_dt
12 20-jun-2012 25-jun-2012
12 27-jun-2012 28-jun-2012
I hv tried using below query but it giv null value for last row
SELECT item_id, eff_dt, end_dt, end_dt + 1 AS newd,
LEAD (eff_dt) OVER (PARTITION BY ctry_code, co_code, item_id ORDER BY ctry_code,
co_code, item_id) AS LEAD,
(CASE
WHEN (end_dt + 1) =
LEAD (eff_dt) OVER (PARTITION BY ctry_code, co_code, item_id ORDER BY ctry_code,
co_code, item_id, eff_dt)
THEN '1'
ELSE '2'
END
) AS new_num
FROM item
WHERE TRIM (item_id) = '802'
ORDER BY ctry_code, co_code, item_id, eff_dtI m using oracle 10g.
please any help is appreciate.
Thanks.Use start of group method:
with sample_table as (
select 10 item_id,date '2012-6-20' start_dt,date '2012-6-25' end_dt from dual union all
select 10,date '2012-6-26',date '2012-6-26' from dual
select item_id,
min(start_dt) start_dt,
max(end_dt) end_dt
from (
select item_id,
start_dt,
end_dt,
sum(start_of_group) over(partition by item_id order by start_dt) grp
from (
select item_id,
start_dt,
end_dt,
case lag(end_dt) over(partition by item_id order by start_dt)
when start_dt - 1 then 0
else 1
end start_of_group
from sample_table
group by item_id,
grp
order by item_id,
grp
ITEM_ID START_DT END_DT
10 20-JUN-12 26-JUN-12
SQL> SY. -
How does one simultaneously view two or more tables?
When viewing a table, a tab is created. How does one create a second tab with which to view a second table?
A related question - how does one enter and run two or more SQL statements to be viewed side-by-side (as in the above example with straight tables)?1) For table click the thumb tack an pin it. Then the next one will open in a new window.
2) When you have 2 worksheets open drag the title bar to be on the left/right/top/bottom of that section. Then you'll have side-by-side worksheets.
-kris -
Two or more table based forms on a single page
Hi,
Is it possible to have two or more forms fetching their respective tables on the same page ? I mean , to have two Automated fetching processes . I tried to change each page item source from ('DB Column' ... column_name) into ('DB Column' ... "TABLE".column_name) but is not working.
Any idea ?
Thanks.Actually I am trying to give you a solution but not 100% sure what you exactly you want?
According to your subject, i understood that you have a page based on two more tables so if it is then
create a view on these tables and create a page on view and then create a trigger (Instead of triggers)
for insert /update into the columns related tables.
hope it work!
Regards -
Directions between two or more points on the map
Anyone knows of an app for OSX and iOS where one can get directions between two or three or more points. (not a point and current location). In particular an app where one could create a multi-stop trip on OSX and then push it on to an iOS device where it would work as a map and as a navigator?
Tip: Apple Maps apps can't do this. They only allows one pin on the map and directions form current location to the map. Which is utterly useless for trip planning. And yes I know I can use Google Maps for that. But I want to stay away from Google.
Thank you all for your input.you can get directions between two points neither of which is your location on the current ipad app. steps:
launch the app
drop a pin on one of the points
click on the right side of the baloon that opens over the pin
select directions to or from the location
a pane opens on the left side of the app
click into the start or end field that has "current location"
type in your desired start/end point and select the correct location from the drop down list that populates as you type
click on "route"
your route options will appear between the two points -
How do i compare the similarities between two or more text files?
The subject says it all. I am familiar with a number of the diff tools that are available, but I have yet to find a tool or app that will find the similarities between two text files. Any suggestions?
From http://hints.macworld.com/article.php?story=20030217061153119
"FileMerge highlights the sections that differ in each file..."
I need to find similarities. I was thinking something along the lines of the similarity-tester package in Ubuntu:
http://unix.stackexchange.com/questions/1079/output-the-common-lines-similaritie s-of-two-text-files-the-opposite-of-diff/94532#94532
Preferably a GUI tool, but command line is OK if I can figure out the proper syntax.
Maybe you are looking for
-
Logic Crashing - Please help me if you can!
Hi guys First time posted; Long time browser.. Alright So I have Logic Pro with various AU instruments etc Its been going great for some time (months) and last two days Ive hit a bump. We tracked it down to being nexus; (au instrument) however even d
-
Hi all, im facing a doubt. i have a sender soap interface but the customer give to me the wsdl.so what can i do? i allways define de WSDL in PI for sender SOAP. but in this case i already have the wsdl. so what can i do? Thanks Rodrigo
-
Terminating PPPoE Session in a 7206vxr Router
Hi We are running a 7206vxr Router as an ISG. We have an Ethernet LAN , the clients are using a static IP assigned to their LAN Card. The clients are logging into the network using a Broadhop AAA Server ( SME ) using a Portal ( L4Redirect ). But we a
-
Undo a Batch Resize??
Help Please! I accidentally resized a batch process to an unusable size! Is there any way to undo this? Thank you!!
-
Hi, We have had this dilemma for a while and looking for suggestions/recommendations. Typically our orders are Net 30 in which a PO is issued. However, many times we cannot use Net 30 and end up ordering using credit card. The problem is that credit