referential integrity with a view to the parent table
Is it possible to create a foreign key that uses a view as the parent table?CREATE TABLE one
+ (id NUMBER CONSTRAINT a_pk PRIMARY KEY, +)
name VARCHAR2 (32));
CREATE TABLE b
+ (name of the b_pk VARCHAR2 (32) CONSTRAINT PRIMARY KEY, +)
address VARCHAR2 (32));
CREATE VIEW b_view AS SELECT * FROM b;
ALTER VIEW b_view ADD CONSTRAINT b_view_pk PRIMARY KEY (name) DISABLE NOVALIDATE;
ALTER TABLE an ADD CONSTRAINT a_fk
B_view (name) REFERENCES of FOREIGN KEY (name);
"After issuing the last alter statement I get the error: ' ORA-02270: no unique or primary key corresponding to this list of columns.
If I use just the table b of referential integrity, everything works. Is this just a limitation of the use of the view with a PK defined as disable novalidate? Is there a workaround to use the view?
Thank you
mcslain
AFAIK, you can create constraints on views, purely for the sake of documentation.
Sense: these constraints are never implemented, they must be defined using the NOVALIDATE keywords to DISABLE.
And since these constraints, say the b_view_pk in your case, are DISABLED/NOVALIDATE, you cannot have a foreign key (ENABLED), which points to them.
Pouvez have you a foreign key pointing at them is DISABLED/NOVALIDATE too, however.
But I bet it's not what you want.
Tags: Database
Similar Questions
-
Forgive my question. I am very new to Oracle.
How can I make sure that changes in the key primary supplier_id (concerning the supplier table) would also appear directly in the FOREIGN KEY (supplier_id) in the products table?
Is that not all the primary key and FOREIGN KEY on?
My paintings:
I created 2 tables and connect to apply in the data base referential integrity, as I learned.
CREATE TABLE - parent provider
(the numeric (10) of supplier_id not null,)
supplier_name varchar2 (50) not null,
Contact_Name varchar2 (50).
CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)
);
CREATE TABLE - child products
(the numeric (10) of product_id not null,)
supplier_id numeric (10) not null,
CONSTRAINT fk_supplier
FOREIGN KEY (supplier_id)
REFERENCES beg (supplier_id)
);
I inserted the following text:
INSERT INTO provider
(supplier_id, supplier_name, contact_name)
VALUES
(5000, 'Apple', 'first name');
I expect that the supplier_id (5000) to the provider of the table also appears in the products table under key supplier_id having the same value which is 5000. But this does not happen.
How to get there?
Thanks in advance!
Hello
What is a foreign key in Oracle?
A foreign key is a way to ensure referential integrity in your Oracle database. A foreign key means that the values of a table must appear also in another table.
Ok!??
What is now the right way to implement referential integrity in your Oracle database that the values of a table must also be included in another table?
A foreign key referential integrity indeed enfore in ensuring that the value in the child table must have a corresponding parent key (otherwise you will encounter an error, as evidenced by "SomeoneElse"). However, it will never automatically insert a row in the other table.
If you are looking for a solution that automatically inserts a record in the other table, maybe you should go for triggers:
See:
-
How to upgrade the parent table and child by updating the parent table
I have a parent EMPLOYEE table that includes columns (sysid, serviceno, employeename...) sysid is the primary key, serviceno is the Unique key and I have DEPENDENT child table includes columns (sysid, employee_sysid, name, date of birth...) there still SYSID is a primary key for the table of dependants, employee_sysid is a foreign key in the EMPLOYEE table.
Now I want to change SYSID (with the help of the sequence) in the EMPLOYEE table that they want an update in the table of people dependent
Note: I have 10000 records in the EMPLOYEE table as I have 5 more children tables that need to update new SYSID.
Please help mefirst disable FOREIGN KEY constraints.
You can update Parent and child record with the help of the trigger.
Here I give you an examlpe... It can help u.create a parent (id number primary key, name varchar2 (100)) table
/
create table child_1 (primary key id, p_id number number, date of birth, date)
CONSTRAINT FK_id FOREIGN KEY (p_id) REFERENCES parent (ID))
/
create table child_2 (key primary id, p_id2, addr varchar2 number number (1000))
CONSTRAINT FK_id2 FOREIGN KEY (p_id2) REFERENCES parent (ID))
/Insert some test data for the parent tables and children.
change the constraint to disable child_2 table FK_id2
/
change the constraint to disable child_1 table FK_id2
/CREATE OR REPLACE TRIGGER delete_child
BEFORE parent UPDATE ON
FOR EACH LINE
BEGIN
UPDATE CHILD_1
P_ID =:NEW.ID SET
WHERE P_ID =:OLD.ID;
UPDATE CHILD_2
SET = P_ID2: NEW.ID
WHERE P_ID2 =:OLD.ID;
END;
/then Upadte parent table primary key col and check the children tables.
do enable constraints... -
BULL, INSERTION IN THE PARENT TABLE AND THE CHILD TABLE
Hi all
We use bulk insert to improve performance. How to use this concept when I insert the records parent in table parent and child?
example... I have a procedure that accepts the array of student objects
each student object is defined as *(student name, student age, course_object_array) *.
the 3rd element course_object_array is defined as *(coursename,course fee,facultyname) *.
a student can be associated with several courses
Now, I have to insert the data into two tables namely students (studentname, studentage and student_number)
courses (course_id, coursename, fees, facultlyname, student_number)
I use sequences to fill the columns student_number and course_id.
If I use bulk insert, and insert all the records in the parent table how do I the association for each record of a child. How will I know what child folder must be associated with which of the parents?
Concerning
REDAraj_fresher wrote:
Hi thanks for the reply Solomon.I actually know about the bulk collect and for all...
Have you read that FOR ALL with in fact BULK COLLECT? It will allow you to bulk insert via for ALL with VOTING student_numbers attributed to each student placed in a collection. Then, you will use this collection collection of course list to fill the RACE table.
SY.
-
How to create a view in the DB table for some servers
Hello
We need create a country table which will contain data for countries.
I want to create it in such a way that it will be common for all servers - but as a point of view. not the real table, only the data and views do not change.
How can I do?
Thanks in advanceAre you sure you want to say 'tablespace '? A tablespace is a collection of data files. It has nothing to do with the privileges of the object, object namespaces, etc. I'm guessing that you mean that you have two schemas, OBITUARIESCS and ADVERTISEMENTCS. A schema is a collection of objects of database belonged to a particular user. A single table can exist in spaces of multiple tables (assuming it is partitioned). Different schemas can have an infinite number of tables with the same name in the same table. The database schema is the namespace for objects such as tables.
Assuming that you have two schemas in your database, you can create a table of COUNTRIES in the OBITUARIESCS schema. You can then grant SELECT access on the table to another user, ADVERTISEMENTCS, i.e.
GRANT SELECT ON country TO advertisementcs
You can then ask questions (but not change) the COUNTRY code of the property of ADVERTISEMENTCS table
SELECT * FROM advertisementcs.country
If you want to be able to remove the prefix in the schema, you can create a synonym. In the ADVERTISEMENTCS schema
CREATE SYNONYM country FOR advertisementcs.country
and then when the code of the property of ADVERTISEMENTCS wants to query the countries table, it can just
SELECT * FROM country
Justin
-
Checking the referential integrity of a form before the presentation of the Page element
Hi, OTN,.
I have a form on a table with multiple columns, some of which are foreign keys to other tables. Rather than validate the columns for referential integrity when the user inserts/changes in shape, I would use a dynamic action to attract the attention of the user with a javascript alert() when the user loses focus of the element. After a user enters a value into the text box and moves to the next item, I want to be able to query the table, check the existence of the value of the user and issue a javascript alert() if there is no match.
What is the best way to go about this?
I created a dynamic action-to run PL/SQL code on one of the elements of the page, with a code similar to the following:
DECLARE
rf_check varchar2 (30);
BEGIN
SELECT col1 INTO table_a FROM rf_check
WHERE col1 =: P1_ITEM_FK;
EXCEPTION
WHEN NO_DATA_FOUND THEN
HTP.p ("< script type =" text/javascript"> ');
HTP.p ("alert ("ERROR");");
HTP.p ("< /script >" ");
END;
I could not get the dynamic action of delivering javascript. Any thoughts?
Thank you
Matthew Moisen
Published by: Matthew Moisen on 25 October 2012 14:22Matthew Moisen wrote:
What is the best way to go about this?I have to admit that I've never tried, but I would be surprised if Javascript back via statements made htp.p that they are actually executed by the browser.
I would do something like that, by a dynamic action that calls an application process. The PL/SQL procedure request would return via htp.p OK or ERROR. From this result, the javascript would determine to issue the alert. Something like the following (not fully tested):
Javascipt var get = new htmldb_Get(null,html_GetElement('pFlowId').value, 'APPLICATION_PROCESS=FK_CHECK',0); var fk_check = get.get(); if (fk_check=='ERROR') { alert('ERROR'); } Application Process FK_CHECK DECLARE rf_check varchar2(30); BEGIN SELECT col1 INTO rf_check FROM table_a WHERE col1 = :P1_ITEM_FK; HTP.p('OK'); EXCEPTION WHEN NO_DATA_FOUND THEN HTP.p('ERROR'); END;
-
Difficulty with returns control to the parents program after call asynchronous Subvi
I'm trying to set up a directory of context-sensitive help for one of my programs. This is the first time I tried an asynchronous call and I can't seem to make it work properly.
The attached HelpDir.vi is the parent program that gives the user different help files to choose. When the user selects a help file, its Subvi should appear. I would like the user able to let this help file upwards and close the help directory or select another help file to upsimulataneously, if they wish.
The strange thing is that, currently, this vi works exactly as I want if I stress execution on, but works normally, the HelpDir.vi becomes unresponsive when we help files was loaded and becomes sensitive again once the help file has been left.
I set up the parent program with a structure of the event running asynchronous call and forget everything as in the example of the expedition to the France so I do not know why the program parent is not recover control after the launch of the Subvi. Please take a look and let me know if you see what I'm missing.
PS, You may need to update both static references. I don't know if they break when you send the code this way.
Thank you
Tim
Change your dialogues float instead of Modal. Modal windows will always be on top. In the changing Floating, then you can access the window of your main VI as well.
Performance highlight should substitute somehow the disorder of modal window.
-
Why show black screen for some of my users with a view to the horizon?
Hello
I installed horizon view 6.0. now, I just have a problem sometimes some of my users connect to their desktop with vmware view client horizon just see a black screen and cannot do everything even when I'm this office openconsole in vsphere client no show and a black screen for solve the problem I have to restart this desktop computer and its not ok how can I prevent black screen
now I see that my status of vmware tools was obsolete is so important?
What di I do?
Best regards
Babak
As often occurs when the wrong VGA driver is installed. This occurs when the view Agent is installed on the desktop, and then the VMware Tools is updated after the fact. The result is the driver included with the Agent to view VGA is replaced with the VGA driver in VMware Tools. You can see some advantages to the relocation of the Agent of the view, or update the VMware Tools and then install the Agent from the view.
-
How to edit a map with a view that the target object?
Environment: OWB 11 GR 2
I imported several cards of our old OWB 10.1.0.4 environment that have a view as the target object. In this version if I wanted to make a change to the definition of the view, I want to update the map and an outgoing "balance" to the view and it would update the View object with the SQL update. I would then deploy the view and obviously not the card.
I tried to do the same function in OWB 11 GR 2, but I have not yet found the thing. IMHO the documentation is very vague, weak, in this area, at least the many pages I've read.
I opened the card for editing and when I select the view target object and look at the Properties window, the link to the SQL code is empty, even if this isn't the SQL code of the View object.
I tried to use it out 'synchronize' in several different ways, but could not do any SQL appear in this properties link. I also noticed that the SQL code of the View object is now empty as well.
What Miss me?
Thank you very much!!
-garyHi Gary
You use the 'create and link... ". "on the operator to see in the map (right mouse click on the operator for the menu option) and select a name and a module.
See the blog post here that describes it well than its gr 10, 2 and 11 GR 1 material, but its exactly the same thing for 11 GR 2.
http://blogs.Oracle.com/warehousebuilder/2007/07/what_is_new_in_11g_and_10203_f.htmlCreate and link is like synchronize the first outgoing - if you can consider it, weird I know, but that's how.
See you soon
David -
ODI 12 c: IKM for differential insert and update with a sequence in the target table
Hello
I have a map where I fill in a column of my target table using a database sequence. Now my mapping is supposed to load the target gradually table. So I need a revenge for update and incremental insert. Now with this differential IKM it compares all the columns to match all colmuns line to understand, it should be an insert or update. Now, the following code shows that when the ROW_WID is loaded with a sequence of database.
If NOT EXISTS
(select 1 from W_LOV_D T
where T.ROW_WID = S.ROW_WID
and ((T.CREATED_BY = S.CREATED_BY) or (T.CREATED_BY IS NULL and S.CREATED_BY IS NULL)) and
....
....
< the rest of the comparison of columns >
)
So when running ODI returns following error
Caused by: java.sql.SQLSyntaxErrorException: ORA-00904: "S". "" ROW_WID ": invalid identifier
Please suggest if there is no other IKM I should use or if there is another way around it without changing the code IKM...
Hi Marc,
Thanks for your reply.
I had solved it. The incremental update process inserts all rows from the source table to I$ table that exists in the target table. It does so by the where sql such as mentioned in my questions as
WHERE THERE is NOT (
. COLUMNS = -
Master detail relationship with condition enforcement in the secondary table
Hello
I have two tables are Dept (Master), PMCs (Detail). I have to show emp details with somewhere condition.
Ex;
I have a "Dept_effect_date" field in the dept table. When I m showing PGE details in the Details view, it must the EMOS who are hired after the dept_effect_date.
Sainaba.
Hello
The request of the employees table looks very good. Although it seems more logical to get the service id of the employeesEO instead of DepratmentsEO.
The next step should be to create a viewLink between the DepartmentsVO and the EmployeesVO based on the service ID field.
Once you have done this, add the EmployeesVO as a DepartmentsVO child in yout request module (and it will appear as such in the DataControl), so use these your to create master/detail table.
Updating the data based on the selected master will be automatically managed by ADF.
Kind regards
Elias.
-
How to stop refreshing materialized views if the source table is null
any ideas?Probably not what you were hoping for, but here's a few ideas.
Your account shows - 113 (85 pending)
1. How about helping to keep the forum clean by examining your 85 not resolved previous issues and give credit relatively USEFUL or RESPONDED to those who helped you in the past.2. read the FAQ at the top right of the page and view information about your system and your software so that we know what you're working with.
3 ask your question in the body of the thread. Don't tell "of ideas.
What is your question? Is this an academic question or you have a real problem that needs to be addressed?
If you have a problem producing the DDL for the materialized view, and information about the type of discount that has been set up for this. Is there a newspaper view materialized on the underlying tables?
The simple answer to your quest is to use UPDATE them on REQUEST and check the base tables before making a manual
a: the best answer depends on what version of Oracle you are using and what is your actual configuration. Are your
MVs in REFRESH GROUPS? Who can make a difference in the response.How can anyone help with this issue if you do not provide the information needed (FAQ)? Why is - someone MUST help if you show you don't appreciate help in marking questions to which answered once you have helped.
-
Paintings incorporated through the parent table formatting
Hello community!
So I try for a number of hours to consider a solution before posting on the forums, but I have something better to do than to wallow in the marrow of the madness of Adobe for hours and so I would first like to announce my membership in the Club of Haters Robohelp - having reached the rank of Vehiment Loather quickly! Yes, Adobe, if my words are directed into the body for which I am writing, your end is near!
My second and more important problem is in what regards the incorporation of tables in tables. The facts:
- RoboHelp HTML (Webhelp) V9
- My parent table contains a bottom line on the first line.
- My embedded table contains shading in all the lines.
- My embedded table is not supposed to have a bottom line in the first row.
- He does.
- Any attempt to delete it fails - has tried to directly modify the table properties, HTML code and pull my hair. None of this has worked and now I'm bald.
- Best webhelp solutions exist on the market and I'm begging and pleading my manager to put them!
In addition, when you build the project, the toolbar appears to miss its bottom line (separate it from the subject). How can I change the border of the toolbar to add this line?
- I tried to add a line to the body, but which disappears as soon as you scroll to the bottom.
Any assistance as always appreciated.
Hi again,
Might be better to stay with Flare if RoboHelp cause you so much trouble
This problem is most likely a problem of inheritance of CSS. The selectors in your css in the table crushing parent selectors in the css of your nested table. For these nested tables to work, you must manually adjust the selectors to make it work... You need to create a style for the nested table, such as table.parent table.child tr:first - child {border-bottom: none ;} }
If you can zip a sample with nested tables and you theme stylesheet and send people contact [at] wvanweelden [dot] had, I can take a look and try to edit the css for you.
Take a bow
Willam
-
Form on a Table with report - change of the source table after created form
Hi all
I have a 'form on a Table' where the various fields have the "Source Type" = "column of the database. I have 2 Questions for this type of shape:
1: in the field "Source value or expression", it is possible to change the name of the field in the Table. But I can't understand how view or even change the underlying Table (which had to be chosen at the beginning, when the form was created at the start).
2: my question in section that relates to the first question would be, if it is possible to have multiple underlying tables in the same region. Or whether it would be necessary to create a second region or change the "Column of the database" type in a type of SQL query?
Thank you and best regards,
David
To change the table, you need to change the process of the page. A process has been generated called:
Extraction of line of
Here, you can modify the table, but you also have to make in your shipment after processes. Who are probably named:
ApplyMRD and ApplyMRU
If you want a form to be based on more than one table, you can create a view and base your form on this point of view instead of on the table, or you need customized treatment.
-
Create a table with a thinner than the source table granulaty
Hello
I had a problem. I have a source table that has vacation date / period for employees inside. I want to create a table where I "split" the period of vacation days for each employee.
Example:
Holiday table:
Name - Holiday beginning - end of holiday
Mr.X - 1.1.2011 - 5.1.2011
Mr.Y - 2.5.2011 - 3.5.2011
-> new table:
Name - Day of vacation
Mr.X - 1.1.2011
Mr.X - 2.1.2011
Mr.X - 3.1.2011
Mr.X - 4.1.2011
Mr.X - 5.1. 2011
and so on
Is there an operator or something else with which I could create the new table? I use OWB 11 GR 2
THXHello
Join your source table to another table that contains all the dates (for example, you can use time dimension in OWB):Select vt.name, d.date_value in the vacation_table, vt, dates_tab d vacation_day
where d.date_value between vt.vacation_start and vt.vacation_endKind regards
Oleg
Maybe you are looking for
-
Hi help please. "I want to factory reset to lenovo tablet a1 7"
I would like to know how to reset lenovo tablet wifi a1 is locked with a password and I don't remember to reset. I want to do a reset without going into the configuration or another option
-
Mail does not work on OS 10.11.2 (El Capitan)
I've upgraded to the latest version of El Capitan last Friday. I had no end of problems with Mac Mail. First, it would hang because he tried to check the database. I am using the Apple Store, Apple Care and advice on these Forums of Apple. I finally
-
trying to connect my laptop to my TV can't do it now, I did it once before, but I think that I went somrwhere and cloned it .can sume one help me pleas jack. E-mail address is removed from the privacy * if we're cut off
-
Placement of Certificate SSL VPN on workstations
If you use the certificate for two-factor authentication. What certificates: root CA, SSL Cert, Cert user authentication (identity) Web page) and what Office did you place their Machine or user account. Then under this account which folder to place t
-
I am new to Dreamweaver and bought cs6, I want to build mobile applications. I should start by Web sites first, or should I jump in full. I am a novice and need a direction and had to begin.