Find table name and constraint type based on field name
I have a field or column name with me...I want to find the table name for which it is a primary key...Any query to do this job so that the execution costs are low...
Currently i have to mix dba_constraints and ALL_TAB_COLUMNS to get this...any way to fetch the data from a single table/anyother cost effective process is appreciated
Why are you using dynamic SQL? Just place it as static SQL in your PL/SQL code. Simply like this
select table_name
into ..
from (
select cc.column_name
, cc.table_name
, count(cc.column_name) over(partition by c.constraint_name) column_count
from user_constraints c
join user_cons_columns cc
on c.constraint_name = cc.constraint_name
where constraint_type = 'P'
where column_count = 1
and column_name = p_name;
And in some case (Not this one) if you have to use dynamic SQL you need to pass your variables are bind variables to your SQL. You should not be appending it in the string. That's a very bad thing to do. Your code will be going for hard parse, your code will be exposed to SQL Injection. With your SQL this is how you use bind variable.
execute immediate
q'[
select table_name
from (
select cc.column_name
, cc.table_name
, count(cc.column_name) over(partition by c.constraint_name) column_count
from user_constraints c
join user_cons_columns cc
on c.constraint_name = cc.constraint_name
where constraint_type = 'P'
where column_count = 1
and column_name = :1
using p_name
into <your_variable>;
And finally to exactly tell why your code is failing, You have not use sing quotes to enclose your p_name that you are appending to your code. Following would fix the error.
DO NOT USE IT IN ANY CASE. ITS WRONG ALWAYS!!
'select table_name from '||' (
select cc.column_name,cc.table_name, count(cc.column_name) over(partition by c.constraint_name) column_count
from user_constraints c join user_cons_columns cc
on c.constraint_name = cc.constraint_name where constraint_type = ''P'') '||
' where column_count = 1 and column_name = '''|| p_name || '''';
AGAIN NEVER WRITE A CODE AS SHOWN ABOVE.
Similar Messages
-
How to find table name for the fields from Standard Extractor in CRM system
How to find table name of fields from the standard extractor in CRM system ?
e.g. We use LBWE TCode in R/3 system to find table name for the field from Extractor VCSCL(e.g.).
Likewise is there any way to find table name for the fields from Standard extractor like 0CRM_LEAD_I.Hi ,
Please find the link below for understanding BW CRM analysis.
http://help.sap.com/bp_biv135/html/bw.htm
activate the CRM DSs by scenario:
1) Activate the application component hierarchy (tcode RSA9). Changes made to the application component hierarchy in the CRM system can be transferred to the BW using the "Edit Application Component Hierarchy" (SBIW - Postprocessing of DataSources).
SAP Note 434886 must be implemented in CRM 3.0 before the application component hierarchy is activated.
2) Activate the Business Content DataSources (tcode RSA5).
Select/enter the application component and choose Execute (F8).
To compare the shipped and active versions, choose the 'Select Delta' pushbutton. If there is no active version of the DataSource, it is selected automatically.
To activate the shipped version, choose the 'Transfer DataSources' pushbutton.
3) Management of the versions of the BW-Adapter metadata (tcode BWA5). All DataSources are displayed that are managed by the BW Adapter.
As in transaction RSA5 (Service API Metadata Activation), the 'Select Delta' function can be used to select the inactive DataSources or compare shipped and active versions.
You can also go directly to the screen for maintaining DataSources that are managed by the BW Adapter.
The 'Compare Version' function makes a detailed comparison of the shipped and active versions.
All BW-Adapter metadata is considered when versions are compared:
Header information (Table SMOXHEAD)
Mapping information (Table SMOXRELP)
Global selection conditions (Table SMOXGSEL)
Attribute key fields (Table SMOXAFLD)
Hope this helps.
Regards,
csm reddy -
Class and class type based on inspection method
Hi experts,
I have a requirement in my script like this i have a inspection method. based on this inspection method i have to get class and class type. and from which table we can get this class and class type based on inspection method. please suggest the solution.
Thanks in advance
Thanks and Regards
D.RameshHi Sai,
Have you tried Run Time Type services? If you need to perform some interspection of a class, you can use one of two classes:
CL_ABAP_OBJECTDESCR or
CL_ABAP_REFDESCR
there are several methods you can use:
Describe_by_Name
Describe_by_Object_Ref
describe_by_data_ref
describe_by_data
One of these should do the trick...it just depends on what situation you are in.
Hope this helps!
Quack -
How to find Table names for PO & Invoices in SRM Standalnoe system SRM 7.0?
Hi,
How to find Table names for PO & Invoices in SRM Standalnoe system SRM 7.0? Please let me know.
Thanks,
MonicaHi,
In SRM for all objects like SC ( BUS21210),BID,PO(BUS22010),Confirmation (BUS2203),invoice etc all the data stored
in BBP_PDHGP and BBP_PDBEI tables only, These is no separate tables..
for your reference below are the few SRM tables
BBP_PDACC Account Assignment
BBP_PDATT Document Attachment
BBP_PDBEH Backend Specific Header Data
BBP_PDBEI Backend Specific Item Data
BBP_PDBGP Partner Extension Gen. Purchasing Data
BBP_PDBINREL Transaction Object Linkage (EBP)
BBP_PDHCF Set for Tabular Customer and Solution Fields on Hdr
BBP_PDHGP Business Transaction Purchasing Information
BBP_PDHSB Bid Invitation
BBP_PDHSC Header Extension for Customer Fields
BBP_PDHSS Hdr Extension for SAP Internal Enhancements (IBUs and so on)
BBP_PDICF Set for Tabluar Customer and Solution Fields on Itm
BBP_PDIGP Business Transaction Item-Purchasing Information
BBP_PDISB Bid Invitation/Bid-Specific Item Data
BBP_PDISC Item Extension for Customer Fields
BBP_PDISS Item Ext. for SAP Internal Enhancements (IBUs and so on)
BBP_PDLIM Value Limit
BBP_PDORG Purchasing Organizational Unit
BBP_PDPSET Further Procurement Information
BBP_PDTAX Tax
CDCLS Cluster structure for change documents
CDHDR Change document header
CDPOS_STR Additional Change Document - Table for STRINGs
CDPOS_UID Additional Table for Inclusion of TABKEY>70 Characters
CRM_JCDO Change Documents for Status Object (Table JSTO)
CRM_JCDS Change Documents for System/User Statuses (Table JEST)
CRM_JEST Individual Object Status
CRM_JSTO Status Object Information
CRMD_LINK Transaction - Set - Link
CRMD_ORDERADM_H Business Transaction
CRMD_ORDERADM_I Business Transaction Item
CRMD_PARTNER Partners
SROBLROLB Persistent Roles of BOR Objects
SROBLROLC Persistent Roles of Business Classes
SRRELROLES Object Relationship Service: Roles
Thanks & Regards,
Prasad S -
Find the relationship between tables where the constraint type is 'R'
Hello,
I am trying to find an answer of the following question:
How to query the user_constraints view (probably some more views should be involved here) in order to get information about the table name, the column (or columns) that is (are) a foreign key to another table, the name of the referenced table, and the name of the referenced column (or columns) and finally the name of the FK. And additionally, if the referenced table from the first row has its own constraints of type 'R', then to have this table in the second row, where this same table stands in the first column. Each table that is a participant in this tree, of course, could have one or many FK to other tables. One does not know this at run time.
A predicate to say with which table to start the search from will look like this:
<pre>
user_constraints.table_name = 'my_table_name'
</pre>
So, if you could help by providing at least hints for such a query, I will be glad to see different answers.
Thanks :)Thanks a lot for the answer!
That will work and is a very useful starting point. -
How to find Table Name and Field Names given a Data Source
Hi,
I tried ROOSOURCE table in R/3 to find the Extract Structure and Extractor names for a specific data source, let us say 2LIS_02_ITM (PO Item Level).
I know the extract structure for this data source is MCO2M_0ITM
I am not able to find where this structure is extracting the data for every field.. I wanted to know the corresponding table name and the respective field names.. Both the existing and Appended fields..
Thanks,
NarenHi,
Check in in LBWE and Click on Maintenance and see the table names
EKKO
EKPA
EKPO
Tables are use for this DS
Eg:
MCEKKO BEDAT Document Date
MCEKKO BSART Document Type
MCEKKO BSTYP Doc. Category
MCEKKO BUDAT Accounting date
MCEKKO EBELN Purchasing Doc.
MCEKKO EKGRP Purch. Group
Note: here EKKO is table
https://wiki.sdn.sap.com/wiki/display/BI/BW%20SD%20MM%20FI%20DATASOURCES
thanks
Reddy
Edited by: Surendra Reddy on Mar 10, 2010 8:18 AM
Edited by: Surendra Reddy on Mar 10, 2010 8:19 AM -
How to find table name and field name in JSP FORM
Hi
In JSP form's like XML publisher responsibility>templet
In that form how can we see the system-last query . and how to see the table namehi yamini,
plz go to help->record history (for fining table name)
and
help->diagnostic->examine (for finding field name)& enter last_query
in JSP form also same above only i think.
or check in back end & apply who columns
Edited by: raghava bandi on Nov 7, 2008 2:05 AM -
How to find table name and field name thru Tcode
Hi,
how to find out table name and field names thru transaction code..........plz point out step by step.Hi
I am not getting your question... as i understand, if you go to SE84 tcode you can get it.
Go to SE84.Select ABAP Dictionary sub tree. Double click on "database tables'. Give some number in "Maximum number of hits. DONT GIVE ANY OTHER INPUTS. Just press F8. You will get all table names.
For fields also do like this by selecting FIELDS sub tree.
Reward if it is useful.
Thanks
Siva Kumar -
Table structure and constraints in HTML table
This script creates a html file (Structure.html) that contains structure of a specific table.
When the following script is executed in sql * plus, it asks for the table name for which
structure information is needed. after entering the table name, it writes the table structure
into structure.html file.
SET LINESIZE 150
SET PAGESIZE 150
SET FEEDBACK OFF
SET VERIFY OFF
COLUMN "COLUMN NAME" FORMAT A50
COLUMN "DATA TYPE" FORMAT A15
COLUMN "IS NULL" FORMAT A15
COLUMN CONSTRAINTS FORMAT A15
PROMPT Enter table name:
ACCEPT TABNAME
SET MARK HTML ON
SPOOL STRUCTURE.html
PROMPT &TABNAME
-- Query ---
SELECT TRIM(A.COLUMN_NAME) AS "COLUMN NAME",
TRIM(DATA_TYPE||'('||DECODE(A.DATA_LENGTH,22,A.DATA_PRECISION||','||A.DATA_SCALE,
A.DATA_LENGTH) || ')') AS "DATA TYPE",
TRIM(DECODE(A.NULLABLE,'Y',' ','NOT NULL')) AS "IS NULL",
TRIM(DECODE(C.CONSTRAINT_TYPE,'P','PRIMARY KEY','R','FOREIGN KEY('||D.TABLE_NAME||')','U','UNIQUE', 'C','CHECK')) AS CONSTRAINTS,
TRIM(C.CONSTRAINT_NAME) AS "CONSTRAINT NAME",
C.SEARCH_CONDITION AS "CHECK CONDITION",
A.DATA_DEFAULT AS "DEFAULT VALUE"
FROM USER_TAB_COLS A,
USER_CONS_COLUMNS B,
USER_CONSTRAINTS C,
USER_CONS_COLUMNS D
WHERE
A.TABLE_NAME = '&TABNAME' AND
A.TABLE_NAME = B.TABLE_NAME(+) AND
A.COLUMN_NAME = B.COLUMN_NAME(+) AND
B.CONSTRAINT_NAME = C.CONSTRAINT_NAME(+) AND
C.R_CONSTRAINT_NAME = D.CONSTRAINT_NAME(+);
SPOOL OFF
SET MARK HTML OFFHi,
For Head Count you can use 0HR_PA_0 datasource and the other Employee details like start date and end date you can get them from employee master data and FTE can be calculated from the Emloyee Master Data and Head count data.
Hope this helps...
Thanks, -
Finding table-name from a DSN name
i need to find the total number and names of tables from a DSN setup on an access DB. can u tell me how? I couldn't find it in JDBC tutorial ..
ThanxTry this
DatabaseMetaData meta=conn.getMetaData();
ResultSet set=meta.getTables("Database_name",null,null,null);
System.out.println("got meta data ");
while(set.next()){
System.out.println(set.getString(3));
// 3 rd column is the name of table
The resultant resultset has following columns (as strings)
(as per javadoc)
TABLE_CAT String => table catalog (may be null)
TABLE_SCHEM String => table schema (may be null)
TABLE_NAME String => table name
TABLE_TYPE String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
REMARKS String => explanatory comment on the table
TYPE_CAT String => the types catalog (may be null)
TYPE_SCHEM String => the types schema (may be null)
TYPE_NAME String => type name (may be null)
SELF_REFERENCING_COL_NAME String => name of the designated "identifier" column of a typed table (may be null)
REF_GENERATION String => specifies how values in SELF_REFERENCING_COL_NAME are created. Values are "SYSTEM", "USER", "DERIVED". (may be null) -
Hello,
ebs r12 12.1.1
os oul5x64
i am looking for a table name in the database to compare the setup between 2 systems.
when connect as sysadmin --->Concurrent --->manager --->define-- select Standard manager -->select Specialization Rules--
in this form there are columns
Exclude Type Application Name
Exclude Program Master Schedule/MRP Copy MPS Plan
how can i find the table that stores the Application and Name above.
Thanks in advance.Hi,
if I understand your requirement, you want to find the application names, which are stored in
FND_APPLICATION and FND_APPLICATION_TL tables.
you need to join these tables to the APPLICATION_ID column in FND_CONCURRENT_QUEUES_VL to get application_name.
Tip: one way to confirm if you are checking correct table is to query for same data on the Form and in the database and comparing.
Regards
Imran -
How to find table name which provide data for the DataSource
Hi friends,
How to find the Table name which providing data for the Business content DataSources (Master Data). Is there any table or Transation which give datasource and Table name at once.
Thanks&Regards
RevathiHi Revathi...........
1)If the datasource is extracting data from any table.................open the datasource using RSO2..........there u will get the table name......
2) If the datasource is extracting data from any view.............go to RSA2..........copy the view name..........go to SE11 >> give the view name >> and check..........
3) If Datasource is Function module based............then u hav to check in RSA2 >> give the datasource name >> execute >> there u will find the Extract structure name......Copy the Extract Structure name >> Go to SE11 >> in the Data Element field give the Extract structure name >> Display >> From the Entry Help/Check tab u can get the Table name............
If u double click on the Extractor..............u will get the Function Module..............from there also u can check that the FM extracting data from which tables............
For Other datasources also...........u can get the structure name from here........
4) If the Datasources r LO datasources............then u can get the table name in LBWE.............LO extractor - goto transaction LBWE.................... Select the maintenance link for your datasource............
here in the right hand pane.........in the drop down box, you can see the structures associated with this extractor ........ just remove the MC for the structure names to get the base table names. e.g. EKKO for MCEKKO.
5) There is a pattern for the Extract structure name for LO datasources.............for an example..........
DataSource 2LIS_11_VAITM ......Extract structure name is MC11VA0ITM
2LIS_11_VAHDR >> MC11VA0HDR
Hope this helps.........
Regards,
Debjani....... -
How to find table name(s) in a dynamic query
In one of our (9iAS PORTAL)applications, any user can able to run their query statment and get output. All queries will be executed as dynamic SQL thru' a common shema/user who has 'SELECT' privilege on all tables but all users don't have this privilege on all tables. Now, before executing any query I need to find out what are the table name(s) used in this query to check the privilege for the respective user. How do I extract all table names being used in a dynamic query?.
Thanks
-KrishnamurthyI guess that his users log in to application first, then application uses one account to log in to database, so application are not direct database user since all users share the same account to database. If so, when a user lgins in, you may write it down from application to a database audit table, and you need to write down the dynamic query to the database audit table too, then you may query that audit table to find out. up to here, it looks that your application has to do more to assign what role to a user running the application, since database does not know what user is assessing it.
-
Finding table name on which a trigger fired.
I need my trigger to report the name of the table and the DML event that caused the "for each row" trigger to fire.
How do I have the trigger identify this information without hardcoding the table name and event into the trigger ?Actually, I blieve that you can find the name of the trigger by looking in the call stack trace. I think I have seen code for this posted at asktom (asktom.oracle.com).
To find the triggering statement you can do the following providing you have version 9+:
set echo on
create table t ( x int );
create or replace trigger t_trigger
before insert on t
declare
l_text ora_name_list_t;
begin
dbms_output.put_line( 'The statement that caused me to fire is:' );
for i in 1 .. ora_sql_txt( l_text )
loop
dbms_output.put_line( l_text(i) );
end loop;
end;
set serveroutput on
variable n number
insert /* check this out */ into t values ( :n );
drop table t
I forgot where I stole this code from but it was probably posted on comp.databases.oracle.server or asktom.
HTH -- Mark D Powell -- -
To find table name ( urgent)
1) structure name : MEPO_TOPLINE.
2) " " : GOHEAD.
plz.. send what is the TABLE name for above structures.. and what is the procedure to find...MEPO_TOPLINE is used in the following programs:-
1.LMEGUICD1
2.LMEGUICIC
3.LMEGUICIC
4.MM06EFTO
GOHEAD is used in the following programs:-
Program
Short description
LJ1IEXGMPAI
Include LJ1IEXGMPAI
LJ1IEXGMPBO
Include LJ1IEXGMPBO
LJ1IEXGMTOP
LJ1IEXGMU01
Copy the MIGO status and header data
LJ1IEXGMU02
Prepare Internal excise header structure
LJ1IEXGMU06
Reset all the excise data
LJ1IEXGMU09
saves the document, including rg23d, details and header
LMIGODA2
LMIGODI2
LMIGOEN3
LMIGOHC2
LMIGOHG2
LMIGOHI2
LMIGOJB2
Nota fiscal implementation
LMIGOKA1
LMIGOKB1
LMIGOKD1
LMIGOKE1
LMIGOKF1
LMIGOKG1
LMIGOKH1
LMIGOKL2
LMIGOKL3
LMIGOKL4
LMIGOKM1
LMIGOKO2
LMIGOKO4
LMIGOKP1
LMIGOKP2
LMIGOKP3
LMIGOKP4
LMIGOKR1
LMIGOKS1
LMIGOKS4
LMIGOSM3
LMIGOTOP
K.Kiran.
Maybe you are looking for
-
Yoga 2 Pro : Please list any defective Hardware you have experienced.
I am trying to see if there is/was any common problems on Yoga 2 Pro. Mine is still new 10 days old. i7-4500U, Win 8.1 came with it with ship date of 4/23/2014 So far, it had a hickup of staying on sleep mode once (SW problem) If you list yours, if
-
I had to wipe my hard drive clean and reload all my programs. After reloading Itunes, I noticed that some songs will not play, they are skipped over, or the songs plays for 1-2 secs then it skips on to next song. Any ideas what I did wrong? All songs
-
How to get music off my ipod into my itunes
My computer crashed and i had to reinstall itunes on it. i have lost all my music and need to pull the music off of the ipod. how do i do this
-
We have installed and configured HFM, Planning, Essbase, FR, FDM in single server-Windows 2008 R2 SP1 (64-bit). We have checked all diagnostic logs and configuration is 100% successful. All the services start successfully. We can connect to foundatio
-
Hi I am running program (SA38) for printing accounting documents and ledger details using program name /SMB14/SE38_P001_J03. However on execution, system is throwing a dump saying that the smart form/functional package is not available for printing.