How to find the table name on which integrity constraint not found
Hi All
How to acheive this
I have a lot of tables with lot of primary key - foreign key
relationship.
In plsql
when any inserts happen in the child table & the corresponding row is not present in the parent table, we get an exception
ORA-02291: integrity constraint (user1.ppk) violated - parent key not found
On this exception , in the exception block i want to trap teh name of the parent table on which the primary key for the particular child table was not there
Is it possible to retrieve the parent table in this way. I am looking for a generic plsql code block which can help to acheive this
Regards
scott@ORA92> SET SERVEROUTPUT ON
scott@ORA92> DECLARE
2 e_no_parent_key EXCEPTION;
3 PRAGMA EXCEPTION_INIT (e_no_parent_key, -2291);
4 v_fk_cons VARCHAR2 (61);
5 v_owner VARCHAR2 (30);
6 v_parent_table VARCHAR2 (61);
7 v_pk_cons VARCHAR2 (30);
8 v_parent_column VARCHAR2 (30);
9 BEGIN
10 INSERT INTO emp (empno, deptno) VALUES (99, 60);
11 EXCEPTION
12 WHEN e_no_parent_key THEN
13 -- extract schema.constraint_name from sqlerrm:
14 v_fk_cons:= SUBSTR (SQLERRM,
15 INSTR (SQLERRM, '(') + 1,
16 INSTR (SQLERRM, ')') - (INSTR (SQLERRM, '(') + 1));
17 DBMS_OUTPUT.PUT_LINE ('Foreign key constraint violated: ' || v_fk_cons);
18 -- extract parent schema.table and parent key:
19 SELECT owner, table_name, constraint_name
20 INTO v_owner, v_parent_table, v_pk_cons
21 FROM user_constraints
22 WHERE (owner, constraint_name) =
23 (SELECT r_owner, r_constraint_name
24 FROM user_constraints
25 WHERE owner || '.' || constraint_name = v_fk_cons);
26 DBMS_OUTPUT.PUT_LINE ('Parent table: ' || v_owner || '.' || v_parent_table);
27 DBMS_OUTPUT.PUT_LINE ('Parent key: ' || v_owner || '.' || v_pk_cons);
28 -- extract parent table columns:
29 FOR rec IN
30 (SELECT column_name
31 FROM user_cons_columns
32 WHERE owner = v_owner
33 AND table_name = v_parent_table
34 AND constraint_name = v_pk_cons)
35 LOOP
36 DBMS_OUTPUT.PUT_LINE
37 ('Parent table column: ' || rec.column_name);
38 END LOOP;
39 END;
40 /
Foreign key constraint violated: SCOTT.FK_DEPTNO
Parent table: SCOTT.DEPT
Parent key: SCOTT.PK_DEPT
Parent table column: DEPTNO
PL/SQL procedure successfully completed.
Similar Messages
-
How to find the tables name in R3 datasource
I am looking to find out the tables were used for that Datasources(0m_cc0_9). Pls let me know the steps to find out thsi.
Thanks
TajHi Tamkris
1. First go to help.sap.com and simply search for the datasource. You would come to a page where detailed description of the datasource is given.Just note that SAP sometimes plays spoilsport and for few Datassources it doesnt give the table names. But in your case for 0CO_OM_CCA_9, details are given.
2. If in some cases table names are not given, simply go to rsa3. open another session ST05. Activate the trace.In Rsa3, enter the datasource name. And then run extraction. Go to ST05 switch off the trace and then view the log.
In the log, all tables that are hit are shown
3. And if all this doesnt help, start debugging the datasource. TYpically these would be function module based. So dig in!
Hope this info helps
Prakash
Assigning points is a way of saying thanks on SDN! -
How to find the column name and table name with a value
Hi All
How to find the column name and table name with "Value".
For Example i have value named "Srikkanth" This value will be stored in one table and in one column i we dont know the table how to find the table name and column name
Any help is highly appricatable
Thanks & Regards
Srikkanth.M2 solutions by Michaels (the latter is 11g upwards only)...
michaels> var val varchar2(5)
michaels> exec :val := 'as'
PL/SQL procedure successfully completed.
michaels> select distinct substr (:val, 1, 11) "Searchword",
substr (table_name, 1, 14) "Table",
substr (t.column_value.getstringval (), 1, 50) "Column/Value"
from cols,
table
(xmlsequence
(dbms_xmlgen.getxmltype ('select ' || column_name
|| ' from ' || table_name
|| ' where upper('
|| column_name
|| ') like upper(''%' || :val
|| '%'')'
).extract ('ROWSET/ROW/*')
) t
-- where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
order by "Table"or
SQL> select table_name,
column_name,
:search_string search_string,
result
from cols,
xmltable(('ora:view("'||table_name||'")/ROW/'||column_name||'[ora:contains(text(),"%'|| :search_string || '%") > 0]')
columns result varchar2(10) path '.'
where table_name in ('EMP', 'DEPT')
TABLE_NAME COLUMN_NAME SEARCH_STRING RESULT
DEPT DNAME ES RESEARCH
DEPT DNAME ES SALES
EMP ENAME ES JONES
EMP ENAME ES JAMES
EMP JOB ES SALESMAN
EMP JOB ES SALESMAN
EMP JOB ES SALESMAN
EMP JOB ES PRESIDENT
EMP JOB ES SALESMAN
9 rows selected. -
How to find the machine name from which the table is created ?
YogeshTurn on DDL auditing.
http://www.oracle-base.com/articles/10g/Auditing_10gR2.php outlines some uses ... i'm sure you can find more with a google search. -
Regarding finding the table name for a field in R12 forms
Hi all,
I need to know how to find the table name for a field in R12. I am working on extracting the employee information but i need to know how to get the table names for the fields.
Thank you,
rajPlease see these threads.
How to find table name in ebs
How to find table name in ebs
E-Business tables
E-Business tables
Thanks,
Hussein -
Find the table names in a package body
How to find the table names in a package body in single query .(SQL).
Hi,
you can find dependent objects of a package from below query
select distinct referenced_name ,REFERENCED_TYPE from ALL_DEPENDENCIES where name = 'PACKAGE' and referenced_owner not in ('SYS','PUBLIC') and referenced_type = 'TABLE';
Thanks
Handle: user12057782
Status Level: Newbie
Registered: Oct 13, 2009
Total Posts: 5
Total Questions: 4 (4 unresolved)
mark answered if helpful/correct
Edited by: CKPT on Nov 22, 2010 1:21 PM -
How can one find the table name of the Delta Que and setup table?
Hi !
Is there any method to find the table name of the delta que and Extraction que ?setup table = <extract structure>_setup
example: setup table for MC11VA0ITM = MC11VA0ITM_SETUP
Delta Queue is based on following 3 tables:
ARFCSDATA
ARFCSSTATE
TRFCQOUT
assign points if useful ***
Thanks,
Raj -
Using column value is it possible to find the table name in the database?
Hi all,
using column value is it possible to find the table name in the database?
guys i need the table value
Note:
oracle-9i
for example:
i don't know NIC(column value) in which table in the database.
Thank you,
with regards,
JP.
Edited by: Guest on Feb 27, 2012 5:42 AMHi,
As far as I understand what you are asking for I would suggest 4 data dictionaries that will help you to know the table name from the column names
1. USER_TAB_COLS
2. ALL_TAB_COLS
3. DBA_TAB_COLS
4. COLS
These can give you detail information about the columns and respective tables at user, schema, dba level. Further information on the table can be found by querying ALL_OBJECTS table giving table_name as Object_name, or you can join the data dictionaries too.
To know about various data dictionaries avalible in Oracle please query select * from cat;
Let us know if you need further assistance.
Twinkle -
How to find the program name of the smart form?
How to find the program name of the smart form if output type is not known?
thanks in advance...How to find the program name of the smart form if output type is not known?
thanks in advance...
T-code SE16
Enter table name: TNAPR -> Press enter key
Enter smartform name in input field(SFORM): Z_your_smartform_name
Execute
you can find program name under the column PGNAM/Program name.
Regards
sudheer -
How to find the form name from VA02 T.code
how to find the form name from VA02 T.code
Hi Rajyam,
I guess you are looking out for the formname which prints sales related documents.
If this is what you want,then go to the T-code NACE and select the option K1Sales activities and click on the Output Types button on the top.The new window has all the types of Output types listed.Select the most appropriate and double click on the Processing routines button in the left side screen.
The new window lists the program names and the forms associated with that output type.
In case you have any further clarifications,do let me know.
Regards,
Puneet Jhari. -
How to find the program name of the created sap query ?
how to find the program name of the created sap query ?
Hi avinash,
Try in this way..
Go to SE16 and then go to table TSTC.
in that give program name as <b>*followed by your query name</b>
(for example *TESTQUERY)
and run , that will give progname======queryname.
this way you can find program name.
vijay -
How to see the Table Names & Field Names by other than F1 help
Hi Experts
How to see the Table Names & Field Names by other than F1 help, & How to see the List of MM Table Names.
RgdsThe only option to see the active table/ field name is through F1 --> Technical Information. Apart from this, you can use any 3rd part application like GUIex (INbuilt in SAP ECC 6.0 ... can be activated by clicking on the tri-color button on the top right), but you need technical knowledge to understand the information. As far consolidated list of MM tables is concerned, SAP don;t provide you the same at one place, it experience and knowledge which help you in this regard. For your immediate reference MM tables are as under :
EBAN - Purchase Requisition
EBKN - Purchase Requisition Account Assignment
EBUB - Index for Stock Transport Requisitions for Materi
EINA - Purchasing Info Record: General Data
EINE - Purchasing Info Record: Purchasing Organization D
EIPA - Order Price History: Info Record
EKAB - Release Documentation
EKAN - Vendor Address: Purchasing Document
EKBE - History per Purchasing Document
EKBEH - Removed PO History Records
EKBZ - History per Purchasing Document: Delivery Costs
EKBZH - History per Purchasing Document: Delivery Costs
EKEH - Scheduling Agreement Release Documentation
EKEK - Header Data for Scheduling Agreement Releases
EKES - Vendor Confirmations
EKET - Scheduling Agreement Schedule Lines
EKETH - Scheduling Agreement Schedules: History Tables
EKKI - Purchasing Condition Index
EKKN - Account Assignment in Purchasing Document
EKKO - Purchasing Document Header
EKPA - Partner Roles in Purchasing
EKPB - "Material Provided" Item in Purchasing Document
EKPO - Purchasing Document Item
EKPV - Shipping-Specific Data on Stock Tfr. for Purch. D
EKRS - ERS Procedure: Goods (Merchandise) Movements to b
EKUB - Index for Stock Transport Orders for Material
EORD - Purchasing Source List
EQUK - Quota File: Header -
How to find the query name using infoset name
Hi Experts
Iam new to the sap queries(SQ01,SQ02), some queries already created.
now i want to do some modification, my problem is i am not able to find the query name.
I know the infoset name, can you tell me how to find the query name using the infoset name, is ther any table for this.
i tried in sq01 also, but its confusion, pls advice me on this.
thanks in advance.
regards
rajaramHi
try like this..
SQ02 --> go to --> Query Directory..
from there you can get all the queries belong to a Infoset. -
How to find bex query name of which dashboard built on?
How to find bex query name of which dashboard built on?
Hello,
When you add a "SAP BW Connection" to you dashboard, you find in the output parameters the query technical name and the query description. you can bind it to the embedded spreedsheet and then use it in yoyr dashboard
Best regards,
Mohamed AISSA -
Hi experts,
I want to find information which is stored in the particular transaction (find the table name)
tcode is COR3 in that enter process order and enter after that go to adminstrative data in that created user.
I want find user information will be stored in which table . pls help me in thisHi,
There are both technical and functional ways of knowing the Table Names:
1. You can ask your functional consultant to give you the basic or the main table name. From there you can use a where used list to get the list of all the tables that are connected to this table by the foreign key relationship.
2. You can get to know the name of the package from the package hierarchy. You can also use se84 to find the objects from the repository information browser.
3. You can use the ST05 transaction to run and SQL trace to find all the tables that where accessed during the TCODE execution. But here you need to be precise as it will show you all the names of all the database tables accessed.
Hope this will help you.
Thanks,
Samantak.
Maybe you are looking for
-
How to hide column of DataGrid
I am making a web part in which I am using System.Web.UI.WebControls.DataGrid control. It's AutoGenerateColumns property is set to TRUE. I am trying to hide a column at run time. I have written the following code on this controls ItemCreated event bu
-
Discussion and Name not showing up in itunes
Hey everyone I've just released a new podcast to itunes through libsyn. When I go to itunes the podcast says it's by 'unknown' and the overall show description isn't on there. Here's the link: Can anyone let me know how to fix this. Bev
-
Simple but complete PI/XI scenario
Hello, I have just started learning about PI/XI. Now I have access to a PI 7.1 system and would like to start "learning by doing" instead of just reading about stuff. I would like to start with something simple like a file to mail scenario where I am
-
Can I ask if the free trial version that I downloaded is supposed to function fully or is it limited in ways from the paid version? Please answer this specifically....when I just downloaded the free trial of Illustrator, it seems limited in its funct
-
Printers recommended for mac os x 10.6.8?
Printers recommended for a macbook os x 10.6.8?