How to retreive table names ?
Hi Gurus,
Having query using DatabaseMetaData..
I am trying to get Tables names from my database using code below..
try{
String[] type = {"TABLE"};
con2 = MyConnection.getConnection();
DatabaseMetaData metaData = con2.getMetaData();
ResultSet rs = metaData.getTables(null, null, "%", type);
System.out.println("Table Names:");
while (rs.next())
ResultSetMetaData rm = rs.getMetaData();
String s = rs.getString("TABLE_NAME");
System.out.println(s);
This code works fine and it gives me table names.. BUT my que is it retreives ALL table names including some system tables. (it gives me tables, for example, like: DR$NUMBER_SEQUENCE).
I just want to retreive ONLY table-names that I have created.
Is there any other override available for getTable() I can use ? OR any other solution ?
Thanks in advance!
You see where you have this?
ResultSet rs = metaData.getTables(null, null, "%", type);Specifically where you have the nulls and the %?
You can pass actually useful things in there if you wanted and that might help. Consult the Javadoc API for more information on this.
Similar Messages
-
How get all table name from database
hi master
sir
how get all table name from databaseThe big question is 'why'.
Selecting from view 'dba_tables' will indeed give the list of all tables in the database, but that includes the dictionary tables and the internal tables, and many others that are probably not of interet to a person who needs to ask this question. Besides, the dba_tables view requires access to a DBA account.
There are several other views: "user_tables" will list all the tables in this user's schema; and "all_tables" will list all the tables this user can access in some way.
The above do not, of course, include any information about synonyms, sequences, views, indexes and so on.
The correct answer and the meaningful answer may be two different things. -
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 -
How to Concatenate Table name and Where condition at runtime
I am passing parameter as User and Zone to Stored Procedure.How to concatenate Table Name
and WHERE CONDITION in SQL Statement.i have different type of users and zones.Hi !
declare
cur sys_refcursor;
r emp%rowtype;
v_sql varchar2(512);
begin
-- do your logic here
v_sql := 'select * from emp';
open cur for v_sql;
loop
fetch cur into r;
exit when cur%notfound;
dbms_output.put_line(r.ename);
end loop;
close cur;
end;In this example you can see how can be done this with cursor vars .. You should concatenate v_sql string according to your requirements.
But as in further posts has already been mentioned , be carefull at publishing such kind of procedures and think on security.
Also when you want dynamicaly change from clause , you should consider using different records to accept data ? Maybe all your tables has the same structure and then this problem will be smaller.
T
T -
How to retrive table names with Java?
Hello!
If I connect to my Oracle Database 10g Express Edition Instance with some Java code and I run the following code:
ResultSet resultSet = databaseMetaData.getTables(null, null, "%", types);
while( resultSet.next() )
String tableName = resultSet.getString(3);
System.out.println(tableName);
I get loads of different names of tables beside those that belongs to my user like:
DR$NUMBER_SEQUENCE
DR$OBJECT_ATTRIBUTE
DR$POLICY_TAB
ARTICLES
BIN$tQZXQ0iGufbgQAB/AQELFg==$0
BIN$tQZXQ0iLufbgQAB/AQELFg==$0
But when I log in to http://127.0.0.1:9090/apex I get a perfect list of the tables belonging to the user:
ARTICLES
CUSTOMERS
DATATYPES
ORDERROWS
ORDERS
REQUESTROWS
REQUESTS
SUPPLIERROWS
SUPPLIERS
Does any one understand how to access just these table names that is created with my user?
Best regards
FredrikHello Adrian!
Yes you are right I now understand that this is the wrong forum.
So I posted the "same question" at:
How to retrive table names belonging only to a user?
How ever I seems to have problem with the schema name parameter any way.
Best regards
Fredrik -
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 -
Query for retreiving table names that have the same data
Hi,
Does anybody know how to retreive all the table names that have the same data in their respective tables but i dont know the table names or its fields. Is there any possible query to perform this action???
Thanks in Advance,
Balaji.What about...
WITH manager_list AS
SELECT name,
LTRIM(MAX(SYS_CONNECT_BY_PATH(id,','))
KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
FROM (SELECT m.name,
e.id,
ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr,
ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev
FROM manager m,
join_table jt,
employee e
WHERE m.id = jt.manager_id
AND jt.employee_id = e.id
AND m.name = :P_MANAGER)
GROUP BY name
CONNECT BY prev = PRIOR curr AND name = PRIOR name
START WITH curr = 1
), all_list AS
SELECT name,
LTRIM(MAX(SYS_CONNECT_BY_PATH(id,','))
KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
FROM (SELECT m.name,
e.id,
ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr,
ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev
FROM manager m,
join_table jt,
employee e
WHERE m.id = jt.manager_id
AND jt.employee_id = e.id)
GROUP BY name
CONNECT BY prev = PRIOR curr AND name = PRIOR name
START WITH curr = 1
SELECT a.*
FROM manager_list m,
all_list a
WHERE m.employees = a.employeesWould be easier in 11g, but I don't have an installation here so this is based on 10g.
Cheers
Ben -
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.
-
How to populate table name dynamically to a ref cursor
Hi,
I came accross with a requirement that in ref cursor how can i pass the table name
for ex
open ref_cur for select * from emp;Like that i've some 100 tables , instead of typing each and every time the table name
that should be dynamically changed
Like below
open ref_cur for select * from &tbl_nm;How can i do that??
Thank youI assume you are using SQL*Plus:
SQL> variable ref_cur refcursor;
SQL> begin
2 open :ref_cur for select * from &tbl_nm;
3 end;
4 /
Enter value for tbl_nm: emp
old 2: open :ref_cur for select * from &tbl_nm;
new 2: open :ref_cur for select * from emp;
PL/SQL procedure successfully completed.
SQL> print ref_cur
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 12/17/1980 00:00:00 800 20
7499 ALLEN SALESMAN 7698 02/20/1981 00:00:00 1600 300 30
7521 WARD SALESMAN 7698 02/22/1981 00:00:00 1250 500 30
7566 JONES MANAGER 7839 04/02/1981 00:00:00 2975 20
7654 MARTIN SALESMAN 7698 09/28/1981 00:00:00 1250 1400 30
7698 BLAKE MANAGER 7839 05/01/1981 00:00:00 2850 30
7782 CLARK MANAGER 7839 06/09/1981 00:00:00 2450 10
7788 SCOTT ANALYST 7566 04/19/1987 00:00:00 3000 20
7839 KING PRESIDENT 11/17/1981 00:00:00 5000 10
7844 TURNER SALESMAN 7698 09/08/1981 00:00:00 1500 0 30
7876 ADAMS CLERK 7788 05/23/1987 00:00:00 1100 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7900 JAMES CLERK 7698 12/03/1981 00:00:00 950 30
7902 FORD ANALYST 7566 12/03/1981 00:00:00 3000 20
7934 MILLER CLERK 7782 01/23/1982 00:00:00 1300 10
14 rows selected.
SQL> begin
2 open :ref_cur for select * from &tbl_nm;
3 end;
4 /
Enter value for tbl_nm: dept
old 2: open :ref_cur for select * from &tbl_nm;
new 2: open :ref_cur for select * from dept;
PL/SQL procedure successfully completed.
SQL> print ref_cur
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> SY. -
How to write table name in SQL according to the user input
hi
i want to select data from a table , and the table name, field name is input by the user, for example, user input table name T1, field name F1 and i want to construct a SQL like select F1 into a_var from T1 . how does the SQL statement written? thanks for your advice.hi
for ur requirement u should go for field sysmbols...
dynamic internal tables..
u can chk this....
TYPE-POOLS : slis.
PARAMETERS : p_struc LIKE dd02l-tabname.
DATA : it_fieldcat TYPE lvc_t_fcat,
t_output TYPE REF TO data .
FIELD-SYMBOLS: <t_output> TYPE table ,
<wa_output> TYPE ANY,
<fval> TYPE ANY.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE = I_BUFFER_ACTIVE
i_structure_name = p_struc
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER = I_BYPASSING_BUFFER
I_INTERNAL_TABNAME = I_INTERNAL_TABNAME
CHANGING
ct_fieldcat = it_fieldcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE i000(bctrain) WITH 'MERGE FAILED'.
*ELSE.
MESSAGE i000(bctrain) WITH 'MERGE SUCCESS'.
ENDIF.
CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
ASSIGN t_newline->* TO <fs_dyntable>.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
I_STYLE_TABLE =
it_fieldcatalog = it_fieldcat
I_LENGTH_IN_BYTE =
IMPORTING
ep_table = t_output
E_STYLE_FNAME =
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ASSIGN t_output->* TO <t_output>.
SELECT * up to 10 rows FROM
(p_struc) INTO
CORRESPONDING FIELDS OF
TABLE <t_output>.
*write : / 'dynamic table created'.
LOOP AT <t_output> ASSIGNING <wa_output>.
DO.
ASSIGN component sy-index of structure <wa_output> to <fval>.
IF sy-subrc <> 0.
WRITE : /.
EXIT.
ELSE.
WRITE : <fval>.
ENDIF.
ENDDO.
ENDLOOP.
Message was edited by:
Premalatha G -
How user variable table names in select statement
Dear all,
I have three table gp1,gp2,g3. i want user variable table in sql query
for example at oracle forms have a list table showing table names gp1,gp2,gp3
at form i want user this query
select gpno from :table where gpno=120;
how i can specify table name Dynamicly in select query
ThanksForms_DDL is a one-way street: You can only pass DDL commands TO the database; you cannot get data back using Forms_DDL.
Exec_SQL is the Forms package that enables dynamic sql within a form. But to retrieve data, you have to make a Exec_SQL call for every column in every row. So it is not a good thing to use, either.
The ref cursor method should work. You could also retrieve the data into a record group using populate_group_with_query -- it also enables dynamic data retrieval.
But if you already know you have three distinct tables and you know their names, I would keep it simple and just write three sql select statements. -
How to use table name as variable in insert statement
Hi,
I want to insert data from the cursor into the table and I want to submit table name as a variable. I tried the code below but it's not working. Any ideas how to solve this problem? Thx
DECLARE
v_new_table_name VARCHAR2(30) := 'test';
--open cursor
CURSOR ACM IS
SELECT *
FROM DWH.CLI_DIMENSION@SLSPDW CLI
WHERE where_clause
FROM some_table;
BEGIN
FOR REC_ACM IN ACM LOOP
EXECUTE IMMEDIATE 'INSERT INTO ' || v_new_table_name || ' VALUES REC_ACM'; --table name as a variable in which the data from cursor will be inserted
V_ROWCOUNT := V_ROWCOUNT + 1;
IF MOD(V_ROWCOUNT, 100) = 0 THEN --this feature commits after 100 rows.
COMMIT;
END IF;
END LOOP;
COMMIT;
DBMS_OUTPUT.PUT_LINE('Number of inserted records:' || V_ROWCOUNT);
END;Try this and let me know if it works. I have not tested it so I can not say for sure.
DECLARE
v_new_table_name VARCHAR2(30) := 'test';
CURSOR ACM IS
SELECT * FROM DWH.CLI_DIMENSION@SLSPDW CLI
WHERE where_clause
FROM some_table;
BEGIN
loop
fetch ACM INTO REC_ACM
exit when ACM%NOTFOUND;
EXECUTE IMMEDIATE 'INSERT INTO ' || v_new_table_name || ' VALUES REC_ACM';
V_ROWCOUNT := V_ROWCOUNT + 1;
IF MOD(V_ROWCOUNT, 100) = 0 THEN
COMMIT;
END IF;
end loop;
COMMIT;
DBMS_OUTPUT.PUT_LINE('Number of inserted records:' || V_ROWCOUNT);
END; -
How to assign table name for select query in loop.
Hi friends my requirement is count the no of records of all the database table which comes into an internal table ."Check the below coding". Iam fetching the tables from dd03l table into an internal table .plz give me a sujjesion how to assign a table name in select query in a loop.
SELECT tabname FROM dd09l
INTO TABLE i_dd09l
WHERE protokoll = 'X'.
IF sy-subrc = 0.
SORT i_dd09l BY tabname.
ENDIF.
LOOP AT i_dd09l.
SELECT COUNT(*) INTO val FROM i_dd09l-tabname.
IF sy-subrc = 0.
i_dd09l-count = val.
ENDIF.
MODIFY i_dd09l INDEX sy-index.
CLEAR val.
ENDLOOP.
error : 'I_DD09L-TABNAME' is not defined in the abap dictionary as a table.data: dy_table type ref to data,
dy_line type ref to data,
xfc type lvc_s_fcat,
ifc type lvc_t_fcat,
dy_field type ref to data.
LOOP AT i_dd09l.
perform get_structure using i_dd09l-tabname .
CREATE DATA dy_table TYPE TABLE OF (_dd09l-tab_name).
UNASSIGN <dyn_table>.
ASSIGN dy_table->* TO <dyn_table>.
SELECT COUNT(*) INTO val FROM <dyn_table>.
IF sy-subrc = 0.
i_dd09l-count = val.
ENDIF.
MODIFY i_dd09l INDEX sy-index.
CLEAR val.
ENDLOOP.
form get_structure using p_table.
data : idetails type abap_compdescr_tab,
xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails = ref_table_des->components.
loop at idetails into xdetails.
clear xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
append xfc to ifc.
endloop.
endform. "get_structure
Try like this hope it will work.
Regards,
madan. -
How to use table name dynamically in report procedure
Hello every body
I want to use table name dynamically means at runtime i want to pass table name.
I can do this by lexical parameter in main query.
But my problem is that i want to crate new format trigger or new function that use 1 cursor in which that lexical parameter : table name is used.
so how to do that?
i can not use that lexical parameter it is giving error.
please help me how to do that.Call a database function which you pass the lexical parameter. Then in the database function you use dynamic sql or the execute immediate option to build the SQL string.
Return the information from this function to build your business logic on in your format trigger.
Marcos -
How to pass Table name as argument in Stored Proc
Hi ,
I have a requirement wherein the table name has to be passed as an argument of SP and the output should be the count from that table based on some filter condition.
Something like this:
create or replace procedure Testing(p_table varchar2,p_count OUT integer) AS
begin
select count(1) into p_count from p_table;
end;
Getting the error on running above code:
PL/SQL: ORA-00942: table or view does not exist
Please let me know how can we do this?
Thanks.Example :SQL> create or replace procedure Testing(
2 p_table varchar2,
3 p_count OUT integer) AS
4 begin
5 execute immediate 'select count(1) from '||p_table
6 into p_count;
7 end;
8 /
Procedure created.
SQL> var n1 number;
SQL> exec Testing('user_objects',:n1);
PL/SQL procedure successfully completed.
SQL> print n1
N1
37
SQL>
Maybe you are looking for
-
Video - LabVIEW Object-Oriented Programming Introductory Walktrough
LabVIEW Object-Oriented Programming, or LVOOP for short, has been around for about a year now. Have you had time to take a look at it? If not, it's about the time. I made you a short video on the very basics of LVOOP development process. It doesn't g
-
SAP Enterprise Service Explorer
To me it seems that the SAP ES Explorer is the current textbook tool to connect .net in Visual Studio 2008 with SAP backend. Can I use the tool only with an ESR on SAP side established, or also having just one WebAS ABAP. Since I have to configure th
-
I just installed iLife 09. A bulk of my photos were converted from non-digital negatives to CD. Of course when I import the discs, iPhoto assumes that the date I import the disc is the date of the event. I CAN NOT find a way to edit the date of the e
-
Material for Industry Reference Model & AIA PIP
Where I can get material for the industry reference model of the business process (Order to Cash/Oppertunity to Quote etc )? Is there any link where I can more macro level details of the AIA PIP released so far? Thanks priyadarshi.
-
Loss of Photoshop 7.0.exe
Photoshop 7.0.exe has inexplicably disappeared from my PC - all other Photoshop files are present, as are complete ImageReady and Illustrator but actual Photoshop 7.0 gone? Could this happen during an auto update?