How to find foreign key in pl/sql

Error starting at line 1 in command:
DELETE FROM ZKET_SOLE WHERE IID_SOLA = 1
Error report:
SQL Error: ORA-02292: integrity constraint (IRCKIS.ZKETSTIP_ZKET_FK) violated - child record found
02292. 00000 - "integrity constraint (%s.%s) violated - child record found"
*Cause:    attempted to delete a parent key value that had a foreign
dependency.
*Action:   delete dependencies first then parent or disable constraint.
i need to find foreign key but i do not know how. I know that it must be in dictionary but i can not find it. I do not have access to ER model.
Thx

You could use a query similar to this:
SELECT ucc.constraint_name,ucc.table_name,ucc.column_name
FROM user_cons_columns ucc
JOIN user_constraints uc on uc.constraint_name=ucc.constraint_name
WHERE CONSTRAINT_TYPE='R'You could also use the ALL_CONSTRAINTS / ALL_CONS_COLUMNS views.
Hope this helps!

Similar Messages

  • How to find Primary Key for a particular SAP Databse Table?

    Hi Guys,
                  How to find Primary Key and foreign key  for Particular SAP Databse table ?for Ex : EKKO , EKPO , EKKN , EKBE , EKBEH  , EKET and EKETH.
    Thanks,
    Srinivas.

    Use transaction SE11 to display the table. Put the cursor on the field you want to display the check table and click 'Foreign key' push button (a key with an bottom point arrow), then it will show the check table of the foreign of a field.
    Or by just simple double click on the field, a pop-up window of all the attribute (including the foreign key and the check table if exists) will show too.
    <i><b>Please reward point for helpful answer.</b></i>
    Minami

  • How to find Installation Date for each SQL installation

    Dear All,
    I need a basic info. How to find installation date of each SQL instance (My environment running with multiple standalone/cluster instances)?
    So, I need a query to find installation date easily (I don't want to check it in registry by manual). Thanks in advance...

    Hi Balmukund
    This is the same answer that (1) Prashanth posted
    from the start, letter on (2) Stan posted
    this again with the same link, and now for the third time, (3) you posted it with the same link :-)
    * This answer is correct for specific instance.
    The OP asked a solution for several instances. Therefore he should execute this on each instance. As I mentioned he can do it dynamically on all instances, for example using powershell (basic logic is, first find all instances and than post this query in a
    loop).
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]
    Then your answer is correct :)
    Balmukund Lakhani
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    | Facebook
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • How to find existing DAC connection to sql server

    How to find existing DAC connection in sql server  

    Hi RoyalM,
    Vishal has answered your initial question. If you have the connection issue. I suggest you elaborate the issue in a new thread.
    You can access DAC using SQLCMD from a command prompt. Or check the existing DAC connection in a command prompt:
    1. Open Command Prompt.
    2. Type: SQLCMD –S <servername\instance> -d master and press Enter.
    1> SELECT name,local_tcp_port FROM sys.dm_exec_connections ec join sys.endpoints e on (ec.endpoint_id=e.endpoint_id) WHERE e.name='Dedicated Admin Connection'
    2> go
    3. If it returns the result, it means there is an existing DAC connection. It also shows the port used by dedicated admin connection.
    Thanks.
    Tracy Cai
    TechNet Community Support

  • Find foreign key which are able or not

    Same as the topic ~ how can I find all the able/unable foreign key/contraints inside a database ? Using TSQL

    Hello,
    Please try the scripts provided on the following resources:
    http://blog.sqlauthority.com/2009/07/17/sql-server-two-methods-to-retrieve-list-of-primary-keys-and-foreign-keys-of-database/
    http://blog.sqlauthority.com/2006/11/01/sql-server-query-to-display-foreign-key-relationships-and-name-of-the-constraint-for-each-table-in-database/
    http://blog.sqlauthority.com/2007/09/16/sql-server-2005-list-all-the-constraint-of-database-find-primary-key-and-foreign-key-constraint-in-database/
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • How to Remove Foreign Key Constraint

    Hello Freinds,
    I have created two sample tables ...
    create table primaryTable(id int primary key,value int);
    OK; 1 row affected
    create table childTable(id1 int primary key,id int references primaryTable(id),value int);
    OK; 1 row affected
    ants_dsn_3.4> select * from childTable;
    | ID1 | ID | VALUE |
    | 1 | 1 | 1 |
    | 2 | 2 | 1 |
    | 3 | 3 | 1 |
    OK; Returned 3 rows from 3 fields
    ants_dsn_3.4> select * from primaryTable;
    --------------------------+
    | ID | VALUE |
    --------------------------+
    | 1 | 1 |
    | 2 | 1 |
    | 3 | 1 |
    --------------------------+
    I want to drop the Foreign key in the Child Table.
    And when i do that i get the Following error.
    ants_dsn_3.4> alter table childTable drop ID;
    [ANTs Software][ANTs DATABASE ODBC driver][ants_dsn_3.4] Server returned error : ERROR (70007): Cannot drop the column 'ID' that has a constraint on it
    Freinds Can you help to solve this problem as iam new to data base side.
    Thanks in advance,
    Faizan.

    The reason you are having a problem is that you are using a very bad technique for creating your constraints.
    SQL> create table primaryTable(id int primary key,value int);
    Table created.
    SQL> create table childTable(id1 int primary key,id int references primaryTable(id),value int);
    Table created.
    SQL> select constraint_name, constraint_type
      2  from user_constraints
      3  where table_name = 'CHILDTABLE';
    CONSTRAINT_NAME                C
    SYS_C0011508                   P
    SYS_C0011509                   R
    SQL> ALTER TABLE childtable DROP CONSTRAINT SYS_C0011509;
    Table altered.
    SQL> Create your constraints properly and you won't get system generated names.
    CREATE TABLE primaryTable(id INTEGER, value INTEGER);
    ALTER TABLE primarytable
    ADD CONSTRAINT pk_primarytable
    PRIMARY KEY (id)
    USING INDEX;And columns named ID and VALUE are enough to make me refuse to hire someone for a job. Get a copy of Joe Celko's books and learn how to name columns. Also do not use reserved words for column names:
    SELECT keyword
    FROM gv$reserved_words;Now lets get back to your referential constraint:
    CREATE TABLE childTable(id1 INTEGER, id INTEGER, value INTEGER);
    ALTER TABLE childtable
    ADD CONSTRAINT pk_childtable
    PRIMARY KEY (id)
    USING INDEX;
    ALTER TABLE childtable
    ADD CONSTRAINT fk_child_primary_id
    FOREIGN KEY (id)
    REFERENCING primarytable(id);BTW: I would fail a first quarter student who, on their midterm, wrote what you've written above. You should find yourself a good beginning book on database design.

  • How to apply Foreign Keys on top of a Common Lookup table

    I have an issue where i am mandated to enforce RI on an applications database (a good thing). but I have several common lookup tables where many of the "codes" reside for many different code types. I also have the mandate that i cannot change the
    underlying DDL to make composite keys to match the codes table PK. I am currently looking at creating indexed views on top of the Codes table to seperate the logical tables it contains. This is several hundred views. Although doable is there another solution
    I am not seeing? I have scoured the web in search of an answer knowing I cannot be the only SQL developer in this situation. I do know that I do not want to write several hundred triggers to enforce RI. Table schema below, the CdValue column is the column
    that is used throughout the hundreds of tables that use this codes table, and their corresponding column is not named the same.
    CREATE TABLE dbo.CodesTable (
    PartyGrpId INT  NOT NULL
      , CdTyp  VARCHAR ( 8 ) NOT NULL
      , CompId INT  NOT NULL
      , CdValue VARCHAR ( 8 ) NOT NULL
      , CdValueDesc VARCHAR ( 255 ) NULL
      , AltValueDesc VARCHAR ( 100 ) NULL
      , DefaultInd CHAR ( 1 ) NULL
      , OrderNum SMALLINT NULL
      , ActiveCd CHAR ( 1 ) NULL
      , ExpireDtm SMALLDATETIME NULL
      , EffectDtm SMALLDATETIME NULL
      , ModById INT  NULL
      , ModDtm SMALLDATETIME NULL
      , CreateById INT  NULL
      , CreateDtm SMALLDATETIME NULL
      , CONSTRAINT PC_dbo_EcdDetail
        PRIMARY KEY CLUSTERED ( PartyGrpId ASC, CdTyp ASC, CompId ASC, CdValue ASC )
        ON FG_Data
    ) ON FG_Data;
    I did though run into one forum where a person brought up a great idea. Filtered Foreign Keys, what a novel concept, if it could work it would make so much less code to fix an issue like this. :)
    ALTER TABLE dbo.BusinessStatus WITH NOCHECK
    ADD CONSTRAINT FK_dbo_BusinessStatus_CodesTable FOREIGN KEY (LoanStsDtCd) REFERENCES dbo.CodesTable (CdValue) WHERE CdTyp = 'Status'
    U.S. Army Airborne! The only way to fly

    >> I have several common lookup tables where many of the "codes" reside for many different code types. <<
    No! This is called “Automobiles, S quids and Lady Gaga” SQL and laugh at you or fire you or both. A table is a set; a set has one and only one kind of element it it. This is the basis of RDBMS and First Normal Form. 
    This is so bad it has a name; OTLT for “One True Lookup Table” ;I give an example of how stupid this in one of my books where a Dewey Decimal Classification for Churches is the same as the ICD code for deformed testicles. 
    There is no such crap as a “generic_type_code” in RDBMS. It either a “<something in particular>_type” or a “<something in particular>_code” in data modeling and the ISO-11179 standards.
    You have more NULL-able columns in one table than you should have in an entire schema! 
    You have audit data (creation and modification) in the row under audit. This is both stupid and illegal. You cannot expose the audit trail to the data user by law. When you delete a row, you also destroy the audit trail –Doh! 
    You have no CHECK() constraint on the (effective_date, expiry_date) pair. 
    Putting “_table” in a table name is a design error called a “tibble” to make fun of how silly it. You might want to download the PDF of bad SQL code smells from Red Gate so you can avoid things like this. 
    >>  the CdValue column is the column that is used throughout the hundreds of tables that use this codes table, and their corresponding column is not named the same. <<
    “_value” and “_code” are both what ISO-1179 calls an attribute property. It is a silly as a list of adjectives without a noun. 
    Each encoding is a separate table in a valid schema, each with its own validation and verification. You have to stop doing this. This is fundamental!! 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to represent foreign key relationship between entity services

    Hi All,
    I have two entity services sbu and lob with remote persistensy(web service).In the sql database also i have these two tables.
    lob table attributes: lobId and lobName.
    sbu table attributes:sbuId,sbuName,and lobId.Here lobId a is foreign key referring to primary key of lob table.
    I want to represent this in the entity services.
    Can you plz tell me how can i do this?.
    Thanks
    Sampath.G

    Hi Sampath,
    to avoid creating a lob entity set the lobId and the timestamp attributes. because this is not smoothly done in the service browser, continue writing your UI.
    in old caf implementation this blog serie gives you a short overview...
    /people/raphael.vogel/blog/2006/05/18/writing-a-betting-pool-application-for-the-soccer-world-cup-2006-part-i
    /people/raphael.vogel/blog/2006/05/18/writing-a-betting-pool-application-for-the-soccer-world-cup-2006-part-ii
    /people/raphael.vogel/blog/2006/05/19/writing-a-betting-pool-application-for-the-soccer-world-cup-2006-part-iii
    /people/raphael.vogel/blog/2006/05/21/writing-a-betting-pool-application-for-the-soccer-world-cup-2006-part-iv
    Regards, Jens

  • How to find multiple keys in single cell using Numbers?

    I'm trying to add functionality to one of my Numbers tables where want to check a single cell for multiple keywords from a list. The hole thing works perfectly fine in Excel but it behaves differently in Numbers.
    The formula I am using is:
    =IF(ISERROR(LOOKUP(2^15;FIND($E$2:$E$11;A2)));"not found";"found")
    The following screenshots show that it correctly finds the keys in the cell when using Excel but not in Numbers. Although, it seems to work if the key is in the same row as the input cell.
    Excel table using the formula I posted in the C column:
    Numbers table using the formula I posted in the C column:
    Would be really happy if somebody knows how I could accomplish that!
    Cheers,
    Maik

    If you are working in Numbers you can do this efficiently with a small AppleScript without going back to Excel or clone. One click and you get the following result:
    This script works with Numbers 2.3, which your screenshot suggests you are using. If you are using Numbers 3 it needs a very small adjustment.
    This is the script:
    --https://discussions.apple.com/thread/6315365?tstart=30
    property inputCol : 1 --> col A, as in example
    property resultCol : 3 --> col C, as in example
    property keysCol : 5 --> col E, as in example
    property targDoc : 1 --> 1 is front document; can change to "MyDocName"
    property targSheet : 1 --> 1 is first sheet; can change to "MySheetName"
    property targTable : 1 --> 1 is first table; can change to "MyTableName"
    tell application "Numbers"
              set t to document targDoc's sheet targSheet's table targTable
              set keysList to t's column keysCol's cells's value
              repeat with i from 2 to t's row count -- assumes 1 Header Row
                        set inputVal to t's row i's cell inputCol's value
                        if inputVal is not 0 then --skip blank cells; Numbers 2 reads blanks as 0
                                  --check if Input matches a key:
                                  if inputVal is in keysList then
                                            set t's row i's cell resultCol's value to "found"
                                  else
                                            set t's row i's cell resultCol's value to "not found"
                                  end if
                                  --check if Input contains a key:
                                  repeat with aKey in keysList
                                            if inputVal contains aKey then set t's row i's cell resultCol's value to "found"
                                  end repeat
                        end if
              end repeat
    end tell
    --end of script
    To run, copy into AppleScript Editor, change the properties if needed, and click the green triangle 'Run' botton.
    SG

  • Foreign key errors in sql plus

    Hello, im pretty new to sql and i am stuck on a project in my database management class and i was wondering if anyone can help us out. I don't know if it would be easier to send what i've done or just post the error so if anyone could help it will be appreciated.
    This is one part of the sql
    CREATE TABLE PREREQUISITE_T
         (COURSECODE                VARCHAR2(10)NOT NULL,
         PREREQUISITECODE          VARCHAR2(20),
    PRIMARY KEY (COURSECODE),
    PRIMARY KEY (PREREQUISITECODE),
    FOREIGN KEY (COURSECODE) REFERENCES COURSE_T(COURSECODE),
    FOREIGN KEY (PREREQUISITECODE));
    INSERT INTO PREREQUISITE_T VALUES ('23131', '3213');
    INSERT INTO PREREQUISITE_T VALUES ('23541', '4213');
    INSERT INTO PREREQUISITE_T VALUES ('23251', '3413');
    INSERT INTO PREREQUISITE_T VALUES ('56131', '3513');
    INSERT INTO PREREQUISITE_T VALUES ('75431', '3613');
    INSERT INTO PREREQUISITE_T VALUES ('45631', '3813');
    INSERT INTO PREREQUISITE_T VALUES ('65461', '3913');
    INSERT INTO PREREQUISITE_T VALUES ('45351', '5413');
    the error i get is
    ERROR at line 1:
    ORA-02298: cannot validate (STUDENT.SYS_C003016) - parent keys not found
    It works fine without the primary keys but when i put in foreign keys it is all messed up. If there a a tutorial or anyone could take a look at the rest of the code i can send it out. Any help is appreciated.

    probably u had given the column value not exists in the reference table.
    see the example
    create table tst(x number ,y number);
    alter table tst add constraints pk_x primary key(x);
    create table tst1(x number, y number);
    alter table tst1 add constraints fk_x foreign key(x) references tst(x);
    SQL> insert into tst values(&x,&y);
    Enter value for x: 1
    Enter value for y: 2
    old 1: insert into tst values(&x,&y)
    new 1: insert into tst values(1,2)
    1 row created.
    SQL> /
    Enter value for x: 2
    Enter value for y: 3
    old 1: insert into tst values(&x,&y)
    new 1: insert into tst values(2,3)
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> insert into tst1 values(&x,&y);
    Enter value for x: 2
    Enter value for y: 1
    old 1: insert into tst1 values(&x,&y)
    new 1: insert into tst1 values(2,1)
    1 row created.
    SQL> /
    Enter value for x: 5
    Enter value for y: 6
    old 1: insert into tst1 values(&x,&y)
    new 1: insert into tst1 values(5,6)
    insert into tst1 values(5,6)
    ERROR at line 1:
    ORA-02291: integrity constraint (SHFLDEV.FK_X) violated - parent key not found

  • How to create foreign key automatically?

    I am writing to seek help, in regards creating foreign key automatically, when I insert data into my ''price'' table.  I have 2 tables, one called prices and names.  the relationship between them, if that one name can have many prices and one price
    can have many names (many-to-many). Hence, i have junction table called  "Name_Prices", as shown below in the sample database schema:
    Names
    name_id [pk]
    name
    type
    UploadDate
    Prices
    Price_id [pk]
    name_id [fk]
    price
    uploadDate
    Name_Prices
    name_id REFERENCE names (name_id)
    price_id REFERENCE prices (price_id)
    PRIMARY KEY (name_id, price_id)
    The  price's data input comes in as CSV file everyday. (please see the example below) :
    name name_type price UploadDate
    ALBA MBS 93.5 17/10/2014
    ALESC Trup 58 17/10/2014
    ALESC Trup 52 17/10/2014
    My desire goal/output is to be able to create a functionality, where I can insert the price's data into the database (''prices''), it will automatically insert foreign key in the price
    table (from the names table), and if there is a new price's name, then the database will create a new name id for it, in the name's table, transferring the name, its type, from the CSV input data. 
    In order to achieve this task, where would I start implementing this logic?(in SQL server or application-side) what steps does this involve and is this task achievable, all in sql server side (i.e. store procedure, functions etc..). 
    Apology in advance, if the question is not clear to understand, i happy to follow up with further questions, if required.  
    Any help would be very appreciated. Many thanks

    As noted above, I modified the design:
    Products
    Product_id [pk]
    Product
    type
    UploadDate
    Prices
    Price_id [pk]
    price
    uploadDate
    Product_Prices
    Product_id REFERENCE Products (Product_id)
    price_id REFERENCE prices (price_id)
    PRIMARY KEY (Product_id, price_id)
    Note
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • How to find message key to  OBIEE11

    We´d like to customize a couple of OBIEE11 msgs - I know where are the files, etc... OTH there are several msgs per file... so if I need to change a specific message.. it should be in some of the files...The issue is how to find it ? Is there a simple way ? other than opening each file...
    Txs
    Antonio

    txs. for your comments... but the troube is to find the specific msg in one of those files... Isn´t there a way - lets say when you are in answer 'looking at the msg in the screen' to find some info about it ? like key ? which file it is in ?
    txs

  • Data Modeler - How to add foreign keys to physical model?

    I imported few tables from data dictionary and tried to generate a DDL file. The DDL didn't include foreign keys for some reason. Then I noticed that the foreign keys are in the relational model but not in the physical model. How do I get those foreign keys to the physical model?

    That's the place where I'm looking for the foreign keys in physical model. I noticed that in relational model the Generate check box of a foreign key was unchecked. When I checked it, the key appeared in the physical model. But why is it unchekced sometimes? This has happened only few times, usually the foreign keys do appear in the physical model. If I do something special during import, I don't know what it is...

  • How to find scrollLock key state

    How to find the scrollLock key state in actionacript3.0.
    Like Caps Lock and num Lock on/off state.

    am I right, that you don't want to know, that the KEY-COMMIT or KEY-DELREC or something else is pressed,
    what you want is : which trigger can be used, so that in the trigger-code can be detected, which KEY has fired. And the answer should then be "F10" and not "KEY-COMMIT"
    it that your question ?
    Gerd

  • Finding foreign keys

    hi,
    anyone got sql that would tell which tables reference a primary key in a another table e.g. the link from primary key to foreign key in a schema?
    thanks

    query DBA_CONSTRAINTS
    SQL> desc dba_constraints
    Name                            Null?    Type
    OWNER                            NOT NULL VARCHAR2(30)
    CONSTRAINT_NAME                  NOT NULL VARCHAR2(30)
    CONSTRAINT_TYPE                        VARCHAR2(1)
    TABLE_NAME                       NOT NULL VARCHAR2(30)
    SEARCH_CONDITION                        LONG
    R_OWNER                             VARCHAR2(30)
    R_CONSTRAINT_NAME                        VARCHAR2(30)
    DELETE_RULE                             VARCHAR2(9)
    STATUS                              VARCHAR2(8)
    DEFERRABLE                             VARCHAR2(14)
    DEFERRED                             VARCHAR2(9)
    VALIDATED                             VARCHAR2(13)
    GENERATED                             VARCHAR2(14)
    BAD                                  VARCHAR2(3)
    RELY                                  VARCHAR2(4)
    LAST_CHANGE                             DATE
    INDEX_OWNER                             VARCHAR2(30)
    INDEX_NAME                             VARCHAR2(30)
    INVALID                             VARCHAR2(7)
    VIEW_RELATED                             VARCHAR2(14)

Maybe you are looking for

  • Keyboard and Trackpad Not Working; Mac OSX Unexpectedly Quit?

    Hey everyone... I think I may need to stop by the Apple store to figure this one out, but I just wanted to make sure if there was anything I could do on my own first. So basically, on my MacBook Pro that I got nearly two years ago (late September of

  • Detecting the current window in Forms 4.5

    Hello, Is there a way to detect the current window that is in use? I want to find the window's x/y coordinates to center another form or LOV on top of it. Thanks for any help you can provide. Frank

  • Trackpad draging and jumping around the screen

    trackpad works for a while but then the trackpad begins to drag (when I move my finger around the trackpad, the curser either doesent move at all or moves very slowly) and the curser begins to jump around the screen when the trackpad and computer ise

  • IPod Touch white screen of death

    I've tried a hard factory reset and got nothing. I tried putting it in DFU mode and nothing. It shows up in iTunes I just don't know what to do to fix the white screen! I can hear the audible lock click and can swipe on the screen to unlock. But I ca

  • What Iview(VAC) showsTeam calendar ui element in the leave req or calendar

    Hi All, I have a requirement in which i need to to disable the tool tip coming on the leave data in the leave request application in show calendar.In the leave request application under show team calendar ,when the cursor is placed on the leave appli