How to find number of rows in a table
i have one table ,it contains millions of record,how can i know number of rows in that table without using count(*),
i tried in user_table ,for the column NUM_ROWS,but it is not showing number of rows,pls send me a solution for this.
regards,
singh
Ok, that only was to show simply that max option
might not an option to reduce execution time.Yes, but I/O variances have a tendency to really skew the observed elapsed execution time - making execution time alone a poor choice to determine what SQL will perform better than another.
Both MAX(ROWNUM) and COUNT(*) results in the same amount of I/O - as both uses the exact same execution plan, I/O wise. In this example, a FTS.
SQL> create table testtab nologging as select * from all_objects where rownum < 10001;
Table created.
-- warmed up the buffer cache with a couple of SELECTs against TESTAB in order
-- to discard PIOs from the results
SQL> set autotrace on
SQL> select count(*) from testtab;
COUNT(*)
10000
Execution Plan
Plan hash value: 2656308840
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 35 (9)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | TABLE ACCESS FULL| TESTTAB | 9262 | 35 (9)| 00:00:01 |
Note
- dynamic sampling used for this statement
Statistics
0 recursive calls
0 db block gets
131 consistent gets
0 physical reads
0 redo size
223 bytes sent via SQL*Net to client
238 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> select max(rownum) from testtab;
MAX(ROWNUM)
10000
Execution Plan
Plan hash value: 2387991791
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 35 (9)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | COUNT | | | | |
| 3 | TABLE ACCESS FULL| TESTTAB | 9262 | 35 (9)| 00:00:01 |
Note
- dynamic sampling used for this statement
Statistics
0 recursive calls
0 db block gets
131 consistent gets
0 physical reads
0 redo size
225 bytes sent via SQL*Net to client
238 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
So seeing that we have the exact same baseline for both queries, and that PIO does not influence the results, we time a 1000 executions of both.
SQL> declare
2 cnt number;
3 begin
4 for i in 1..1000
5 loop
6 select count(*) into cnt from testtab;
7 end loop;
8 end;
9 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:03.19
SQL>
SQL> declare
2 cnt number;
3 begin
4 for i in 1..1000
5 loop
6 select max(rownum) into cnt from testtab;
7 end loop;
8 end;
9 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:15.87
SQL>
This shows that what makes the MAX() more expensive is just that - determining the MAX(). For each row, Oracle has to call its internal MAX() function with two values - the current max result and the new value. This function then returns the new max value. This overhead per row adds up to a significant overhead in execution time - making the MAX() approach 5x slower than the COUNT() approach.
Similar Messages
-
How to find the LOCKED ROWS in a table?
Not locked objects, but for a table the locked rows.
Check below links :
http://www.jlcomp.demon.co.uk/faq/locked_rows.html
How to find the locked row.
who are waiting for same record?
HTH
Girish Sharma -
How to find latest updating row in a table
Hi
How to find latest updating row in a tableADF 7 wrote:
SELECT * FROM Table WHERE lastupdTimestamp = (SELECT MAX(lastupdTimestamp) FROM Table)lastupdtimestamp - holds and date an time of an records when it last updation takes place in table.
lastupdtimestamp is a column in my table.And how will this make sense in the scenario I've described, where UserA does an update before UserB, but commits the update after UserB's commited update? And add UserC and UserD and a 1000 more users to this scenario where concurrent updates happen.
What actual time does this lastupdtimestamp contain and represent? And why? How is that lastupdtimestamp used in business logic and processing? Or is it just a silly-bugger-let's-add-somekind-of-time column to that table that essentially meaningless?
Not saying that one should never add such a timestamp based column. Simply that one needs to understand WHAT it contains and it needs to be SENSIBLY used within the data model.
However, in my experience such columns are often slapped on afterwards, never featured in the actual data model designed, and is then used without a second though that the database and its data is a multi-user and multi-process system. And things happen at the same time. And things overlap (serialisation is the exception - not the rule). -
How to retrieve number of rows of a table by jdbc?
can anyone show me a simple snippet of a java code about how to retrieve the number of ROWS in a table?
or even only showing the jdbc command that does this job would be enough.
thanks in advance :)
cheers1. query for the count, then execute the query
"select count(*) from test" then
"select * from test"
2. create a scrollable ResultSet then
rs.last();
int count = rs.getRow();
rs.beforeFirst();
Jamie
p.s. this topic has been discussed MANY times. Do a search on this forum and you will get lots of other discussions on this topic. -
How to find newly updated rows in a table
Hi..
How to know newly updated rows in a table.
Thanks in advance
palOr other good thing would be to add LAST_UPDATED column to your table, that can reflect the time the row gets updated.
G -
How to find number of rows in tables
Hi,
Can you please help me how to know the number of rows in all the tables databsae.
Thanks In Advance,Just found out that the behaviour changed in 11.2.0.2:
SQL> select * from v$version where rownum = 1
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
1 row selected.
SQL> select owner, table_name, column_value cnt
from (select owner, table_name, 'count(ora:view("' || owner || '","' || table_name || '"))' xq
from all_tables
where table_name in ('EMP', 'DEPT')),
xmltable (xq) order by owner, table_name desc
OWNER TABLE_NAME CNT
FLEET EMP 14
FLEET DEPT 4
MICHAEL EMP 14
MICHAEL DEPT 5
SCOTT EMP 14
SCOTT DEPT 4
STEFAN EMP 14
STEFAN DEPT 4
8 rows selected. -
How to find latest updated row in a table
Hi
Here I have command that display updated time.But I Need which row was lastly updated (show particular row) in that table.
select scn_to_timestamp(max(ora_rowscn))
from employee;First of all, SCN to timestamp mapping exists for a short period of time, so if change is relatively old you'll get ORA-08181:
SQL> select max(ora_rowscn) from emp;
MAX(ORA_ROWSCN)
22622685
SQL> select scn_to_timestamp(max(ora_rowscn)) from emp;
select scn_to_timestamp(max(ora_rowscn)) from emp
ERROR at line 1:
ORA-08181: specified number is not a valid system change number
ORA-06512: at "SYS.SCN_TO_TIMESTAMP", line 1
SQL> Anyway, based on SCN we can find out which BATCH of table row modifications was committed last. But you can't find out which modification withing that BATCH was made last.
SY. -
How to find number of rows after query
I have a simple query page. On this page I enter query criteria and hit the go button I get the query result. (say it finds one record)
On processFormRequest of the controler of this page after I execute (executing explicitly because I am using some bind variable too) the query I print getFetchedRowCount() and getRowCount() and I get 10 (as the total records according bind variable criteria are 10). Where I am expecting 1 as the result.
and I want to get the value of that row as well.
Can anyone please guide me how I can achieve this?
ThanksYes I am using queryBean for search region. I can see both, criteria that I am passing through search region and bind variable in the query.
If I pass the customer name it gives me that customer as a result.
but the counts i get doesn't seem to consider that search criteria from query region.
Interestingly when I execute the query again with the same customer name ...I get the correct count. i.e 1
Followoing is the query from "about this page-->business component reference details."
SELECT * FROM
select distinct super_customers.party_name
customer_name,
super_cust.cust_account_id customer_id,
sup_cust_acct.Status,
sup_cust_acct.customer_class_code,
CINT_CRM.Get_Customer_Type(sup_cust_acct.customer_type),
sup_cust_acct.FOB_Point,
sup_cust_acct.sales_channel_code,
From
hz_parties Customers,
hz_parties Super_Customers,
hz_parties cust_cont_rel,
HZ_RELATIONSHIPS REL,
HZ_Cust_Accounts rel_cust_acct,
HZ_Cust_Accounts sup_cust_acct,
HZ_CUST_ACCT_RELATE_ALL Super_Cust
where
customers.party_id = rel.subject_id
and cust_cont_rel.party_id = rel.party_id
and rel_cust_acct.party_id = customers.party_id
and Super_Cust.related_cust_account_id = rel_cust_Acct.cust_account_id
and super_cust.cust_account_id = sup_cust_acct.cust_account_id
and Super_Customers.party_id = sup_cust_acct.party_id
and sup_cust_acct.account_number like 'SC%'
and cust_cont_rel.status = 'A'
and rel.status = 'A'
and rel_cust_acct.status = 'A'
and Super_Cust.status = 'A'
and sup_cust_acct.account_number like nvl(:customerNumber, sup_cust_acct.account_number)
and nvl(rel.object_id, -1) = nvl(nvl(:contactPartyId, rel.object_id), -1)
and upper(super_customers.party_name) like upper(nvl(:customerName, super_customers.party_name))
and sup_cust_acct.account_number like 'SC%') QRSLT
WHERE
(( UPPER(CUSTOMER_NAME) like UPPER(:5)
AND (CUSTOMER_NAME like :6
OR CUSTOMER_NAME like :7
OR CUSTOMER_NAME like :8
OR CUSTOMER_NAME like :9)) -
How to find number of rows inserted by dynamic query
EXECUTE IMMEDIATE l_sql
USING p_start_date, p_end_date
RETURN sql%rowcount into l_count;
Here l_sql is is selecting record from table_1 based on p_start_date, p_end_date and inserting record in table_2.
There is some further process to be done on table_2 which I want to do only if atleast 1 record is inersted in table_2 by the select query on table_1 for this I am using RETURN sql%rowcount into l_count;
I am geting error pls-00103 for this.
Is there any way to achieve this functionality.
ThanksIs there any way to achieve this functionality.Depends on your exact form of l_sql. Here are two ways to get the rowcount out of execute immediate:
SQL> create table emp_test as select * from emp where 1=2
Table created.
SQL> begin
execute immediate 'insert into emp_test select * from emp';
dbms_output.put_line ('Count: ' || sql%rowcount);
end;
Count: 14
SQL> rollback
Rollback complete.
SQL> declare
l_count integer;
begin
execute immediate 'begin insert into emp_test select * from emp; :1 := sql%rowcount; end;' using out l_count;
dbms_output.put_line ('Count: ' || l_count);
end;
Count: 14
PL/SQL procedure successfully completed. -
How to find index of row in dynamic table?
Our form has a table to which the user can add rows. We want to be able to edit the custom help text of each field in the row to add the row number for accessibility. But need the index number of the row to reference the row of the fields. And we can't figure out how to get it.
We have tried both the field initialize and field layout events, but our property for index is not being recognized. For the initialize event of one of the fields in the row, we wrote this code:
xfa.host.messageBox("We are in the initialize event for this field.");
var thisRow = this.parent.index;
xfa.host.messageBox(thisRow);
We have the table set up with 8 intial rows. The first message pops up 8 times, but the second doesn't appear at all. How can we get the number of the row we are addressing?
Thanks.Not sure what's going on there but messageBox() is throwing an error for some reason (use CTRL-J in Acrobat to open the Console):
GeneralError: Operation failed.
XFAObject.messageBox:3:XFA:form1[0]:subMain[0]:Table1[0]:Row1[1]:TextField1[0]:ready
Argument mismatch in property or function argument
It works if you add some text:
xfa.host.messageBox("Row Number: " + thisRow);
app.alert() works: app.alert(thisRow);
And console.println() works (less annoying for testing than popups - open the Console window to see the results):
console.println(thisRow);
Ah, just figured it out - messageBox() doesn't seem to like a number first, it's expecting a string. The following works with your original script:
var thisRow = this.parent.index.toString(); -
How to set number of Rows of a table to be displayed based on user action?
Hi Experts,
I am getting data into the table. But only 5 records are displayed default. I want it to be a user selection.
If user wishes to see 10 records, then first 10 records should get displayed. If user selects 'n' records then 'n' records should get displayed..
How to achieve this?
Regards,
Yugesh A.hi Yugesh ,
1 create a input field UI
2 bind its value property to a attribute
3 suppose ca_check attribute ( type string ) under node cn_check is binded
read this in ur doinit of the view
DATA lo_nd_cn_check TYPE REF TO if_wd_context_node.
DATA lo_el_cn_check TYPE REF TO if_wd_context_element.
DATA ls_cn_check TYPE wd_this->element_cn_check.
DATA lv_ca_check LIKE ls_cn_check-ca_check.
* navigate from <CONTEXT> to <CN_CHECK> via lead selection
lo_nd_cn_check = wd_context->get_child_node( name = wd_this->wdctx_cn_check ).
* get element via lead selection
lo_el_cn_check = lo_nd_cn_check->get_element( ).
* get single attribute
lo_el_cn_check->get_attribute(
EXPORTING
name = `CA_CHECK`
IMPORTING
value = lv_ca_check ).
4 nw for ur table , make a another context attribute of type either string or I , say attr1
bind its visiblerowcount property of table to attr1
5 make a attribute in ATTRIBUTES tab of type string , say attribute
set its value to lv_ca_check in doinit itself
wd_this->attribute = lv_ca_Check
6 nw in the method , where u need to validate how m,any rows user enter or doinit itself , set attr1 to the value of that attribute created under ATTRIBUTES tab ( named attribute)
DATA : lv_count type string .
lv_count = wd_this->attribute
7 nw its very simple , set attr1 to lv_count , as it contains the count of the number which has entered in the input field
DATA lo_nd_cn_check TYPE REF TO if_wd_context_node.
DATA lo_el_cn_check TYPE REF TO if_wd_context_element.
DATA ls_cn_check TYPE wd_this->element_cn_check.
DATA attr1 LIKE ls_cn_check-ca_check.
* navigate from <CONTEXT> to <CN_CHECK> via lead selection
lo_nd_cn_check = wd_context->get_child_node( name = wd_this->wdctx_cn_check ).
* get element via lead selection
lo_el_cn_check = lo_nd_cn_check->get_element( ).
* set single attribute
lo_el_cn_check->set_attribute(
EXPORTING
name = `attr1`
value = lv_count ).
I hope it shud help
proceed like these , u wud be able to achieve the desired functionality
regards,
amit
Edited by: amit saini on Oct 20, 2009 1:12 PM -
hi all,
i have a requirement where we have to calculate sum of the row values in advanced table
when i click on ADDROW button a new row is displayed after entering the values
i need to get the sum of values that i enter into the new row
i know about RECALCULATE button which gives sum of columns but i need to get the sum of the rows
plz help me.........
thanx in advance
DEVHi Dev ,
You need to make use of iteration , loop through every record in the VO get the column value and keep adding it
to obtain the sum .
Here is the code to loop through and get the column value
OAApplicationModule am = oapagecontext.getApplicationModule(oawebbean);
int sum = 0;
OAViewObject oaviewobject =(OAViewObject)am.findViewObject("ApplicationsListVO"); // your vo name attached to table region
if(oaviewobject!=null)
oapagecontext.writeDiagnostics(this,"View Object is exists",OAFwkConstants.STATEMENT);
int rowcountValue = oaviewobject.getRowCount(); // retruns no of rows
Row rowAdv= oaviewobject.first();
RowSetIterator iterator = oaviewobject.createRowSetIterator("iterator");
iterator.setRangeStart(0);
iterator.setRangeSize(oaviewobject.getRowCount());
for(int i=0; i<iterator.getRowCount(); i++)
oapagecontext.writeDiagnostics(this,"Inside For loop ",OAFwkConstants.STATEMENT);
rowAdv =iterator.getRowAtRangeIndex(i); // start from 0 to fetch count ( no of rows )
if(rowAdv != null)
if(rowAdv.getAttribute("VacancyName")!=null) // get your column name
vacancyValue = rowAdv.getAttribute("VacancyName").toString();
Sum = sum +vacancyValue ; // Obtain the sum here
Let me know if you need further inputs .
Keerthi -
How to find out the rows inserted between a time period.
Hi,
Please help me to solve this.
Table - emp.
Colmns - empno(Primary Key),ename, mgr
How to find out the rows inserted between a time period.
For eg:- Between 02-Oct-2006 1 PM and 03-Oct-2006 2 PM.
regards,
Mathew.Hi,
Maybe work:
For each row, ORA_ROWSCN returns the conservative upper bound system change number (SCN) of the most recent change to the row. This pseudocolumn is useful for determining approximately when a row was last updated. It is not absolutely precise, because Oracle tracks SCNs by transaction committed for the block in which the row resides
e.g.:
SGMS@ORACLE10> create table test(cod number);
Table created.
SGMS@ORACLE10> insert into test values (1);
1 row created.
SGMS@ORACLE10> insert into test values (2);
1 row created.
SGMS@ORACLE10> commit;
Commit complete.
SGMS@ORACLE10> insert into test values (3);
1 row created.
SGMS@ORACLE10> commit;
Commit complete.
SGMS@ORACLE10> select SCN_TO_TIMESTAMP(ora_rowscn),ora_rowscn,cod from test;
SCN_TO_TIMESTAMP(ORA_ROWSCN) ORA_ROWSCN COD
06/11/06 08:56:56,000000000 727707205 1
06/11/06 08:56:56,000000000 727707205 2
06/11/06 08:57:05,000000000 727707210 3Cheers -
How to find number of lines in an internal table
Dear all,
how to find number of records present in an internal table.DESCRIBE TABLE
Syntax
DESCRIBE TABLE itab [KIND knd] [LINES lin] [OCCURS n].
Extras:
1. ... KIND knd
2. ... LINES lin
3. ... OCCURS n
Effect
This statement determines some properties of the internal table itab and assigns them to the specified variables. The various additions enable you to determine the table type, the number of currently filled rows and the initial memory requirement.
In addition, the system fields sy-tfill and sy-tleng are filled with the current number of table rows and the length of a table row in bytes.
Notes
For detailed information about an internal table, you should use the methods of RTTS of the DESCRIBE TABLE statement.
Without the specification of an addition, the statement DESCRIBE TABLE only sets the system fields sy-tfill and sy-tleng.
Addition 1
... KIND knd
Effect
The table type of the internal table itab is determined and a corresponding one-digit identification is assigned to the data object knd. A character-type data type is expected for the data object. The identifications are "T" for standard tables, "S" for sorted tables and "H" for hashed tables. These values are also defined as constants sydes_kind-standard, sydes_kind-sorted, and sydes_kind-hashed in the type group SYDES.
Addition 2
... LINES lin
Effect
The current number of table rows of the internal table itab is determined and is assigned to the data object lin.The data type i is expected for the data object.
Note
As of release 6.10, the current number of rows of an internal table can also be determined using the in-built function lines.
Addition 3
... OCCURS n
Effect
The initial memory requirement defined during the creation of the internal table with the addition INITIAL SIZE or the obsolete addition OCCURS is determined and assigned to the data object n. The data type i is expected for the data object.
Example
Descending sorting of a generically typed internal table in a subprogram. Since sorted tables cannot be sorted in a descending order, the table type is checked to avoid an exception that cannot be handled.
TYPE-POOLS sydes.
FORM sort_descending CHANGING itab TYPE ANY TABLE.
DATA tabkind(1) TYPE c.
DESCRIBE TABLE itab KIND tabkind.
IF tabkind = sydes_kind-standard OR
tabkind = sydes_kind-hashed.
SORT itab DESCENDING.
ELSEIF tabkind = sydes_kind-sorted.
MESSAGE '...' TYPE 'E'.
ELSE.
MESSAGE '...' TYPE 'E'.
ENDIF.
ENDFORM.
DESCRIBE FIELD INTO
Note
This statement is for internal use only.
It cannot be used in application programs.
Syntax
DESCRIBE FIELD dobj INTO td.
Effect
All characteristics of the field f, its components , sub-components etc. are displayed in the field td (type description). td has to be of the type SYDES_DESC, defined in Type Group SYDES. Because of this, the type group SYDES must be integrated into the ABAP-program with a TYPE-POOLS statement .
The structure SYDES_DESC has two table-type components TYPES and NAMES:
In TYPES, the tree structure of the type belonging to f is displayed. The components of a node are stored in the table TYPES in a continuous manner. Beginning and end of the line area that represents the components are stored in TYPES-FROM and TYPES-TO. The reference to the superior node can be found in TYPES-BACK. If no superior resp. subordinate node exists, then this is marked by the value 0 (For the relevance of further components, refer to the following sections).
The names of components, types etc. are not stored directly in TYPES. Instead, the components TYPES-IDX_... hold an index in the name table NAMES. The value 0 indicates that there is no reference to the name table.
NAMES contains the possibly fragmented names in the component NAMES-NAME. If a name continues in the following line, this is indicated by an asterisk ('*') in the component NAMES-CONTINUE.
The type description table (TYPES) not only stores information about the tree structure but also further information about the type of f resp. its components. This includes especially all information that can be determined using the usual additions to DESCRIBE FIELD. In detail, TYPES contains the following columns:
IDX_NAME
Component Name
IDX_USER_TYPE
Name of a user-defined type, i.e., a type that was defined through its TYPES-statement. Derived types (... TYPE A-B) and structures from the ABAP-Dictionary are not considered to be user-defined types.
CONTEXT
For user-defined types only: The context, in which the type is defined. Possible values are defined in the constant SYDES_CONTEXT of the type group SYDES. Please only use these constants to carry out a comparison. In detail, we distinguish between the following type contexts:
SYDES_CONTEXT-PROGRAM: Program-global type
SYDES_CONTEXT-FORM : FORM-local type
SYDES_CONTEXT-FUNCTION: FUNCTION-local type
SYDES_CONTEXT-METHOD : METHOD-local type
IDX_CONTEXT_NAME
For user-defined types only:
With a local context: The name of the FORM or FUNCTION, whose type was defined. The name of the associated program is then the first entry in the name table.
With a global context: The name of the program in which the type was defined.
IDX_EDIT_MASK
Conversion routine from the ABAP-Dictionary, is in accordance with the addition EDIT MASK at simple DESCRIBE.
IDX_HELP_ID
Help-Id when referencing to fields from the ABAP-Dictionary
LENGTH
Internal length, corresponds to the addition LENGTH at simple DESCRIBE
OUTPUT_LENGTH
Output length, corresponds to the addition OUTPUT-LENGTH at simple DESCRIBE
DECIMALS
Number of decimal digits, corresponds to the addition DECIMALS at simple DESCRIBE
TYPE
ABAP-Type, corresponds to the addition TYPE at simple DESCRIBE
TABLE_KIND
A table type is stored here for the components which represent an internal table. The same values are returned as with the variant DESCRIBE TABLE itab KIND k. Components which do not represent a table get the return value set to SYDES_KIND-UNDEFINED (see type group SYDES).
Example
Example definition of the complex data type EMPLOYEE_STRUC:
PROGRAM DESCTEST.
TYPES: BEGIN OF name_struc,
first TYPE c LENGTH 20,
last TYPE c LENGTH 20,
END OF name_struc,
BEGIN OF absence_time_struc,
day TYPE d,
from TYPE t,
to TYPE t,
END OF absence_time_struc,
phone_number TYPE n LENGTH 20,
BEGIN OF employee_struc,
id LIKE sbook-customid,
name TYPE name_struc,
BEGIN OF address,
street TYPE c LENGTH 30,
zipcode TYPE n LENGTH 4,
place TYPE c LENGTH 30,
END OF address,
salary_per_month TYPE p LENGTH 10 DECIMALS 3,
absent TYPE STANDARD TABLE OF absence_time_struc
WITH NON-UNIQUE DEFAULT KEY,
phone TYPE STANDARD TABLE OF phone_number
WITH NON-UNIQUE DEFAULT KEY,
END OF employee_struc.
You can determine the structure of the type EMPLOYEE_STRUC by collecting the type group SYDES as follows:
TYPE-POOLS: sydes.
DATA: employee TYPE employee_struc,
td TYPE sydes_desc.
DESCRIBE FIELD employee INTO td.
The following table shows a few selected columns of the type description table TD-TYPES. For a better overview, the names of the columns IDX_NAME, IDX_UERR_TYPE and IDX_EDIT_MASK have been shortened:
|FROM| TO |BACK|NAME|UTYP|EMSK|TYPE
|--||||||--
1 | 2 | 7 | 0 | 0 | 2 | 0 | v
2 | 0 | 0 | 1 | 6 | 0 | 4 | N
3 | 8 | 9 | 1 | 7 | 5 | 0 | u
4 | 10 | 12 | 1 | 8 | 0 | 0 | u
5 | 0 | 0 | 1 | 9 | 0 | 0 | P
6 | 13 | 13 | 1 | 11 | 0 | 0 | h
7 | 17 | 17 | 1 | 12 | 0 | 0 | h
8 | 0 | 0 | 3 | 13 | 0 | 0 | C
9 | 0 | 0 | 3 | 14 | 0 | 0 | C
10 | 0 | 0 | 4 | 15 | 0 | 0 | C
11 | 0 | 0 | 4 | 16 | 0 | 0 | N
12 | 0 | 0 | 4 | 17 | 0 | 0 | C
13 | 14 | 16 | 6 | 0 | 18 | 0 | u
14 | 0 | 0 | 13 | 20 | 0 | 0 | D
15 | 0 | 0 | 13 | 21 | 0 | 0 | T
16 | 0 | 0 | 13 | 22 | 0 | 0 | T
17 | 0 | 0 | 7 | 0 | 0 | 0 | N
Please note that the entries in rows 6 and 7 represent internal tables (ABAP-Type h). There is always an entry for the corresponding row type (rows 13 and 17) to an internal table.
The indices in the rows 5 to 7 refer to entries in the name table TD-NAMES. If you look, e.g., at row 3, you find the corresponding component name in TD-NAMES from row 7 (NAME) onward and the corresponding user type from row 5 (NAME_STRUC) onward.
In the name table TD-NAMES you find the following entries. Note that the names SALARY_PER_MONTH and ABSENCE_TIME_STRUC are stored in two parts:
|CONTINUE|NAME |CONTINUE|NAME
|--| -||--
1 | |DESCTEST 12 | |PHONE
2 | |EMPLOYEE_STRUC 13 | |FIRST
3 | |SBOOK-CUSTOMID 14 | |LAST
4 | |==ALPHA 15 | |STREET
5 | |NAME_STRUC 16 | |ZIPCODE
6 | |ID 17 | |PLACE
7 | |NAME 18 | * |ABSENCE_TIME_ST
8 | |ADDRESS 19 | |RUC
9 | * |SALARY_PER_MONT 20 | |DAY
10 | |H 21 | |FROM
11 | |ABSENT 22 | |TO -
How to find number of files in a folder using pl/sql
please someone guide as to how to find number of files in a folder using pl/sql
RegardsThe Java option works well.
-- results table that will contain a file list result
create global temporary table directory_list
directory varchar2(1000),
filename varchar2(1000)
on commit preserve rows
-- allowing public access to this temp table
grant select, update, insert, delete on directory_list to public;
create or replace public synonym directory_list for directory_list;
-- creating the java proc that does the file listing
create or replace and compile java source named "ListFiles" as
import java.io.*;
import java.sql.*;
public class ListFiles
public static void getList(String directory, String filter)
throws SQLException
File path = new File( directory );
final String ExpressionFilter = filter;
FilenameFilter fileFilter = new FilenameFilter() {
public boolean accept(File dir, String name) {
if(name.equalsIgnoreCase(ExpressionFilter))
return true;
if(name.matches("." + ExpressionFilter))
return true;
return false;
String[] list = path.list(fileFilter);
String element;
for(int i = 0; i < list.length; i++)
element = list;
#sql {
insert
into directory_list
( directory, filename )
values
( :directory, :element )
-- creating the PL/SQL wrapper for the java proc
create or replace procedure ListFiles( cDirectory in varchar2, cFilter in varchar2 )
as language java
name 'ListFiles.getList( java.lang.String, java.lang.String )';
-- punching a hole in the Java VM that allows access to the server's file
-- systems from inside the Oracle JVM (these also allows executing command
-- line and external programs)
-- NOTE: this hole MUST be secured using proper Oracle security (e.g. AUTHID
-- DEFINER PL/SQL code that is trusted)
declare
SCHEMA varchar2(30) := USER;
begin
dbms_java.grant_permission(
SCHEMA,
'SYS:java.io.FilePermission',
'<<ALL FILES>>',
'execute, read, write, delete'
dbms_java.grant_permission(
SCHEMA,
'SYS:java.lang.RuntimePermission',
'writeFileDescriptor',
dbms_java.grant_permission(
SCHEMA,
'SYS:java.lang.RuntimePermission',
'readFileDescriptor',
commit;
end;
To use:
SQL> exec ListFiles('/tmp', '*.log' );
PL/SQL procedure successfully completed.
SQL> select * from directory_list;
DIRECTORY FILENAME
/tmp X11_newfonts.log
/tmp ipv6agt.crashlog
/tmp dtappint.log
/tmp Core.sd-log
/tmp core_intg.sd-log
/tmp da.sd-log
/tmp dhcpclient.log
/tmp oracle8.sd-log
/tmp cc.sd-log
/tmp oms.log
/tmp OmniBack.sd-log
/tmp DPISInstall.sd-log
12 rows selected.
SQL>
Maybe you are looking for
-
Servlet forces a download of pdf instead of displaying it
Hi, First I apologize for the cross posting, but I'm in need of an answer ASAP, and I'm not sure what forum best suits this problem. I have a servlet that retrieves a pdf from a database and displays it. This servlet has been working fine up until re
-
Anyone know of a hard perspex keyboard cover?
Hi I have something very specific in mind, and I'm trying to find out if it exists and can be bought. I have a G5 with a standard Apple keyboard, and my wife and I have it running, doing various tasks, pretty much 24/7, whether we're at the computer
-
Edit Chart error in web application designer
Hello, Whenever I try to edit a chart in de WAD the edit popup window is empty (no edit fields). Does anyone know how to solve this error. BW is running on WAS 6.20 and I am running SAP GUI 6.40 patch 22. Kind regards, Raymond Does
-
Printing takes 2-3 minutes to spool
I have a Lexmark E250dn printer. It worked perfectly for a long time. But, then it started taking 2-3 minutes for a document to print. It sits there with the message "sending data" and then suddenly prints a few minutes later. I've tried updating to
-
is it possible to set a passcode like the iphone everytime i try to use the phone Solved! Go to Solution.