Procedue Table relationship
Procedure-Table relations ship
I am having a oroduction dtabase of around 400 procedures, which uses 250 tables.I want such a script which can produce formate in the form of name of procedure,
table used , mode of table use in I(insertion),U(updation),S(select),D(delete).
like proc A
table t1 i
table t2 d
etc.
Thnaks in advnace,
I imagine there is probably some tool out there that will do the job, but here are a couple of ways to do it, in sql and pl/sql. In the following examples, I have allowed for the possiblities of different case, extra spaces, table prefaced with owner, and commands split between lines. I used a function to remove the extra spaces. If you just need the information and the format is not important, then I would use the SQL. If you need the specific format, then you may want the PL/SQL. I used dbms_output in the PL/SQL example, but you would probably want to use UTL_FILE and output to a file, as the amount of data may exceed the limitations of dmbs_output.
scott@ORA92> -- sample procedures for testing and demonstration:
scott@ORA92> CREATE OR REPLACE PROCEDURE test_proc1
2 AS
3 BEGIN
4 insert into scott.dept(deptno) VALUES (1);
5 UPDATE
6 dept SET deptno = 2;
7 END test_proc1;
8 /
Procedure created.
scott@ORA92> CREATE OR REPLACE PROCEDURE test_proc2
2 AS
3 BEGIN
4 UPDATE emp SET empno = 2;
5 DELETE FROM dept;
6 END test_proc2;
7 /
Procedure created.
scott@ORA92> CREATE OR REPLACE PROCEDURE test_proc3
2 AS
3 BEGIN
4 DELETE emp;
5 END test_proc3;
6 /
Procedure created.
scott@ORA92> -- function used in output:
scott@ORA92> CREATE OR REPLACE FUNCTION remove_extra_spaces
2 (p_string IN VARCHAR2)
3 RETURN VARCHAR2
4 AS
5 v_string VARCHAR2 (32767);
6 BEGIN
7 v_string := REPLACE (LTRIM (RTRIM (REPLACE (p_string, CHR(10), ''))), ' ', ' ');
8 IF INSTR (v_string, ' ') > 0
9 THEN
10 RETURN remove_extra_spaces (v_string);
11 ELSE
12 RETURN v_string;
13 END IF;
14 END remove_extra_spaces;
15 /
Function created.
scott@ORA92> -- information you requested:
scott@ORA92> COLUMN tables FORMAT A30
scott@ORA92> COLUMN dml FORMAT A3
scott@ORA92> SELECT DISTINCT ud.name AS procedures,
2 ud.referenced_name AS tables,
3 'i' AS dml
4 FROM user_dependencies ud,
5 (SELECT name, type,
6 text || ' '
7 || LEAD (text) OVER (PARTITION BY name, type ORDER BY line) AS text
8 FROM user_source
9 WHERE type = 'PROCEDURE') us
10 WHERE ud.type = 'PROCEDURE'
11 AND ud.referenced_type = 'TABLE'
12 AND ud.name = us.name
13 AND (INSTR (remove_extra_spaces (UPPER (us.text)),
14 'INSERT INTO ' || ud.referenced_name) > 0
15 OR INSTR (remove_extra_spaces (UPPER (us.text)),
16 'INSERT INTO ' || ud.referenced_owner || '.' || ud.referenced_name) > 0)
17 UNION ALL
18 SELECT DISTINCT ud.name AS procedures,
19 ud.referenced_name AS tables,
20 'u' AS dml
21 FROM user_dependencies ud,
22 (SELECT name, type,
23 text || ' '
24 || LEAD (text) OVER (PARTITION BY name, type ORDER BY line) AS text
25 FROM user_source
26 WHERE type = 'PROCEDURE') us
27 WHERE ud.type = 'PROCEDURE'
28 AND ud.referenced_type = 'TABLE'
29 AND ud.name = us.name
30 AND (INSTR (remove_extra_spaces (UPPER (us.text)),
31 'UPDATE ' || ud.referenced_name) > 0
32 OR INSTR (remove_extra_spaces (UPPER (us.text)),
33 'UPDATE ' || ud.referenced_owner || '.' || ud.referenced_name) > 0)
34 UNION ALL
35 SELECT DISTINCT ud.name AS procedures,
36 ud.referenced_name AS tables,
37 'd' AS dml
38 FROM user_dependencies ud,
39 (SELECT name, type,
40 text || ' '
41 || LEAD (text) OVER (PARTITION BY name, type ORDER BY line) AS text
42 FROM user_source
43 WHERE type = 'PROCEDURE') us
44 WHERE ud.type = 'PROCEDURE'
45 AND ud.referenced_type = 'TABLE'
46 AND ud.name = us.name
47 AND (INSTR (remove_extra_spaces (UPPER (us.text)),
48 'DELETE ' || ud.referenced_name) > 0
49 OR INSTR (remove_extra_spaces (UPPER (us.text)),
50 'DELETE FROM ' || ud.referenced_name) > 0
51 OR INSTR (remove_extra_spaces (UPPER (us.text)),
52 'DELETE ' || ud.referenced_owner || '.' || ud.referenced_name) > 0
53 OR INSTR (remove_extra_spaces (UPPER (us.text)),
54 'DELETE FROM ' || ud.referenced_owner || '.' || ud.referenced_name) > 0)
55 ORDER BY procedures, tables, dml
56 /
PROCEDURES TABLES DML
TEST_PROC1 DEPT i
TEST_PROC1 DEPT u
TEST_PROC2 DEPT d
TEST_PROC2 EMP u
TEST_PROC3 EMP d
scott@ORA92> --
scott@ORA92> -- output you requested:
scott@ORA92> set serveroutput on size 1000000
scott@ORA92> DECLARE
2 v_insert VARCHAR2(69);
3 v_update VARCHAR2(69);
4 v_delete VARCHAR2(69);
5 v_text VARCHAR2(32767);
6 BEGIN
7 FOR procedure_rec IN
8 (SELECT DISTINCT name
9 FROM user_dependencies
10 WHERE type = 'PROCEDURE'
11 AND referenced_type = 'TABLE'
12 ORDER BY name)
13 LOOP
14 DBMS_OUTPUT.PUT_LINE ('proc ' || procedure_rec.name);
15 FOR table_rec IN
16 (SELECT referenced_owner, referenced_name
17 FROM user_dependencies
18 WHERE name = procedure_rec.name
19 AND referenced_type = 'TABLE'
20 ORDER BY referenced_name)
21 LOOP
22 v_insert := NULL;
23 v_update := NULL;
24 v_delete := NULL;
25 FOR text_rec IN
26 (SELECT UPPER (text) AS text
27 FROM user_source
28 WHERE name = procedure_rec.name
29 AND type = 'PROCEDURE'
30 ORDER BY line)
31 LOOP
32 v_text := v_text || remove_extra_spaces (text_rec.text);
33 IF INSTR (v_text, 'INSERT INTO ' || table_rec.referenced_name) > 0
34 OR INSTR (v_text, 'INSERT INTO '
35 || table_rec.referenced_owner || '.' || table_rec.referenced_name) > 0
36 THEN
37 v_insert := 'table ' || table_rec.referenced_name || ' i';
38 END IF;
39 IF INSTR (v_text, 'UPDATE ' || table_rec.referenced_name) > 0
40 OR INSTR (v_text, 'UPDATE '
41 || table_rec.referenced_owner || '.' || table_rec.referenced_name) > 0
42 THEN
43 v_update := 'table ' || table_rec.referenced_name || ' u';
44 END IF;
45 IF INSTR (v_text, 'DELETE ' || table_rec.referenced_name) > 0
46 OR INSTR (v_text, 'DELETE '
47 || table_rec.referenced_owner || '.' || table_rec.referenced_name) > 0
48 OR INSTR (v_text, 'DELETE FROM ' || table_rec.referenced_name) > 0
49 OR INSTR (v_text, 'DELETE FROM '
50 || table_rec.referenced_owner || '.' || table_rec.referenced_name) > 0
51 THEN
52 v_delete := 'table ' || table_rec.referenced_name || ' d';
53 END IF;
54 IF SUBSTR (v_text, -11) = 'INSERT INTO '
55 THEN v_text := 'INSERT INTO ';
56 ELSIF SUBSTR (v_text, -6) = 'INSERT'
57 THEN v_text := 'INSERT ';
58 ELSIF SUBSTR (v_text, -6) = 'UPDATE'
59 THEN v_text := 'UPDATE ';
60 ELSIF SUBSTR (v_text, -6) = 'DELETE'
61 THEN v_text := 'DELETE ';
62 ELSIF SUBSTR (v_text, -11) = 'DELETE FROM'
63 THEN v_text := 'DELETE FROM ';
64 ELSE
65 v_text := NULL;
66 END IF;
67 END LOOP;
68 IF v_insert IS NOT NULL
69 THEN DBMS_OUTPUT.PUT_LINE (v_insert);
70 END IF;
71 IF v_update IS NOT NULL
72 THEN DBMS_OUTPUT.PUT_LINE (v_update);
73 END IF;
74 IF v_delete IS NOT NULL
75 THEN DBMS_OUTPUT.PUT_LINE (v_delete);
76 END IF;
77 END LOOP;
78 DBMS_OUTPUT.PUT_LINE ('------------------------------------');
79 END LOOP;
80 END;
81 /
proc TEST_PROC1
table DEPT i
table DEPT u
proc TEST_PROC2
table DEPT d
table EMP u
proc TEST_PROC3
table EMP d
Similar Messages
-
Table relationship in PDF Format
hi all
can anyone send me all SAP Table relationships in PDF Format.
thanks in Advance.Check the below URL:
http://www.erpgenie.com/sap/abap/tables.htm
Thanks -
Required CRM Tables & Relationship Diagram
Hi All,
I need CRM Tables & Relationship Diagram. Anybody there to help me to get this. Its urgent.
Thanks in advance.
my mail ID: [email protected]
Thanx & Regards,
SantoshHi Sai, Can anybody send me CRM tables mapping to [email protected] Thanks in advance.
Andy Nguyen -
DMV to list table relationships in a Power Pivot model ?
I have used different queries based on DMVs which let you extract data from a Power Pivot model in order to create a design documentation: list of tables, columns, calculated columns formulas, measures ...etc.
Yet, I have not found the way to extract a list of all tables relationships in the model. Sure enough, I can copy/paste it from the PowerPivot window.
But would someone have a query that extracts table relationships ?
Regards,
BertrandI do not believe that there is any $system based DMV which returns relationship information.
You can get this information from an SSAS Tabular instance using a DISCOVER_CSDL_METADATA call, but that returns an XML document with the all the metadata and I don't know of any easy way to call that against a PowerPivot model (unless it's deployed to sharepoint)
The following is an example query that I ran against a tabular SSAS instance.
<Discover xmlns="urn:schemas-microsoft-com:xml-analysis">
<RequestType>DISCOVER_CSDL_METADATA</RequestType>
<Restrictions>
<RestrictionList>
<CATALOG_NAME>Adventure Works Tabular</CATALOG_NAME>
<PERSPECTIVE_NAME>Model</PERSPECTIVE_NAME>
<VERSION>1.2</VERSION>
</RestrictionList>
</Restrictions>
<Properties>
<PropertyList>
<Catalog>Adventure Works Tabular</Catalog>
<FORMAT>Tabular</FORMAT>
</PropertyList>
</Properties>
</Discover>
http://darren.gosbell.com - please mark correct answers -
It's possible ON UPDATE CASCADE in table relationships?
Hi, how are you?
Sorry my weak English, I'm brazilian.
I like create an "ON UPDATE CASCADE" in my table relationship but find only "ON DELETE CASCADE" in Oracle 9i Database Online Documentation.
I would like your help.
Thank you.
Eduardo A. Reche Lopes
Team T.I.
www.coodetec.com.brTom Kyte wrote a package for this:
UPDATE CASCADE PACKAGE
Generates needed package and triggers to support update cascade in Oracle without removing or infringing on DECLARITIVE RI.
This package supports:
- Tables with multi-part primary keys (primary key(a,c,b))
- Update cascade to many child tables from one parent
- Self-referencing integrity such as that found in the SCOTT.EMP table (mgr->empno)
- Is completely application transparent. The application does not know it is happening
- Versions 7.0 and above of the database.
- Tuned and optimized to fully avoid full table scans on all tables (complete with utility to show you un-indexed foreign keys in a schema, Cascading an update to un-indexed foreign keys can be bad). -
Fact and dimension table relationship?
hi
in se38 i executed this program sap_infocube_designs
i got all cubes and percentage , this is directly fact and dimension table relationship based on this i need to take action is it line item dimension or high cardinality (dimen>20% fact line, dimen>10<20 fact is high cardinality.
regards
suneel.hi,
line item has to be choosen in such a way to control the dim table size for the char that have almost large unique records.
Line item dim table will not be shown by this program.
Ramesh -
Info for table relationship for webcenter interaction database
Hi,
Does any one know where I can get information about the table relationship for webcenter database ? I appreciate your help.
Thanks
YxuSchema Spy is an amazing tool. I haven't used it for the WebCenter apps yet, but this will map everything out for you, providing the relationships you seek.
http://schemaspy.sourceforge.net/ -
Reg: CRM Table Relationship diagram
Hi All,
Please send me the following docs,
(1.) CRM - Table Relationship Diagram
(2.) BDT Cookbook
(3.) BDOC Extension guide
Also send me any other docs related to CRM, which u guys feel useful !!
My Email ID : <removed by SDN Forum Moderator>
Thanks in advance !!
regards
Prembabu RHi,
I got few useful link while searching in forum, Please find the link below
CRM Tables & Relationship Diagram docs
Thanks
Prembabu -
Dear Expert,
Is there any reference document which i can know the B1 table relationship??
Regards,
KitHi,
Well, you have the Database reference help file where all tables and fields are listed, and tells you if a field is a foreign key and in what table.
Nothing more complex than that.
Regards,
Ibai Peñ -
Hi
What is the purpose of tables relationship?
Best...
Mehran
MehranFollowing RSingh's comments.
Relationships between two tables underpins relational theory and all relational databases are based on this theory.
Please see the
link.
If you are serious about understanding the subject or relational theory the two main authorities are Codd and C J Date. Their books are quite academic and difficult to read as an introduction. However the book; -
Training Kit (Exam 70-461): Querying Microsoft SQL Server 2012 (Microsoft Press Training Kit) [Paperback]
does provide a good introduction to relational theory in the early chapters.
To give you a more practical example answer to your question. You could have a order table containing a customer ID which allows you to
relate a particular customer which has raised particular orders.
Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/ -
hi experts
could any one plz send me Table Relationship Diagram ASAP
Thanks in advance
vinayHi kaushal,
Could you pls send me the same doc - CRM Table relations
to [email protected] ?
Thanksa ton in advance !
Jaman -
Can anyone provide me QM tables relationship diagram.
Hi
see the following Qm tables list
QMAT Inspection type - material parameters
QMEL Quality Notification
QMFE Quality notification - items
QMHU QM Link Between Inspection Lot and Handling unit item
QMIH Quality message - maintenance data excerpt
QMMA Quality notification - activitie
QMSM Quality notification - tasks
QMSP QM: material specification
QMTB Inspection method master record
QMTT Inspection Method Texts
QMUR Quality notification - causes
QAES Sample unit table
QAKL Results table for value classes
QALS Inspection lot record
QALT Partial lot
QAMB QM: Link Between Inspection Lot and Materi
QAMR Characteristic results during inspection p
QAMV Characteristic specifications for inspecti
QAPP Inspection point
QASE Results table for the sample unit
QASH Quality control chart
QASR Sample results for inspection characteristics
QASRMS Confirmation Data for Multiple Specifications
QAST Control chart track
QASV Sample specifications for inspection process
QAVE Inspection processing: Usage decision
most of the QA* tables are linked with the fields
PRUEFLOS
VORGLFNR
MERKNR
And Most of the QM* tables are linked with the fields
QMNUM
MANUM
FENUM
<b>Reward points for useful Answers</b>
Regards
Anji -
Billing Tables Relationships -
Hi ALL
Could any one tell ISU Billing tables relationships like Header- line items - consumption history
some of tables not updated, how to update these tables
for ex: DBERCHV Consumption history, DBERCHZ line items.
Thanks in ADVANCE............KK
Edited by: KK on Dec 15, 2008 1:42 PMI resloved my self
-
Hi ALL
Could any one tell ISU Billing tables relationships like Header- line items - consumption history
some of tables not updated, how to update these tables
for ex: DBERCHV Consumption history, DBERCHZ line items.
Thanks in ADVANCE............KK
Edited by: KK on Dec 15, 2008 1:42 PMBinno Don Thomas,
Hi,
As you have mentioned these tables are used to fetch billing related information. can you also suggest, what if these tables are not being updated. As there is no data in DBERCHZ table, but we are able to find data in DBERCHZ1...DBERCHZ8.
There was a program developed for our client during implementation. This FM Fetches data from Table DBERCHZ. currently there is no data in this table and ticket was raised.
Please help so that we could resolve this query.
I would appreciate your help and look forward to maintain healthy contact. -
CRM Tables Relationship.
Hi everyone,
I'm an ABAP Developer, but new for CRM. I'm confused with CRM Table's Relationship, different from R/3. So would anyone share the tables relationship , or give the guide?
I found the prefix of table's name is CRMC or CRMD. Does CRMC means CRM customizing table and CRMD means CRM data table?
Thanks for the help
TonyHi Tony,
Please try these links which may helpful to you:
Links to CRM Documentation
Best Regards,
Johnny.
Maybe you are looking for
-
SO is getting updated from PO thru ME59N
Hi All, We have an issue here , our client is creating automatic PO from ME59N , but to the surprise he found that a new line item has been inserted into the corresponding sales order for which the PO was created. The sales order had only 1 line item
-
Software for controlling internet access with Airport Exreme
I'd like to find software that let's me control what pc's in the house have internet access at certain times. My iMac is my main computer, and I use Airport Extreme as my router.
-
Apps Login Page Error- Insufficient privileges for the current operation
Hi Gurus, We migrated application node from HP-UNIX to SUN Solaris with 11.5.10.2 and 10.2.04 database. When i try to login as sysadmin, got the error You have insufficient privileges for the current operation. But i can able to go in with Forms URL
-
Crystal Report XI doesn't behave like CR 8.5, only Arial without country !
In Crystal Reports Vers. 8.5 our customer works on a MSSQL-DB mit Latin-1 and the Client works even in Latin-1 with only a Polisch Keyboard-Layout ! With Arial (Mitteleuropäisch) and Codepage=238 it was possible to print polisch spezial characters !
-
How do you uninstall iLife 05? I am trying to get my Panansonic Video camera NV EX3 to work on iMovie. It works on iMovie 04. Therefore I would like to reinstall iMovie 04. But because iLife 05 is installed, iLife 04 will not install. I have tried tr