Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8519615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:17:56+00:00 2026-06-11T06:17:56+00:00

On a new job I have to figure out how some database reporting scripts

  • 0

On a new job I have to figure out how some database reporting scripts are working.
There is one table that is giving me some trouble. I see in existing scripts that it is a partitioned table.
My problem is that whatever query I run on this table returns me “no rows selected”.

Here are some details about my investigation in this table:

Table size estimate

SQL> select sum(bytes)/1024/1024 Megabytes from dba_segments where segment_name = 'PPREC';

MEGABYTES
----------
45.625

Partitions

There are a total of 730 partitions on date range.

SQL> select min(PARTITION_NAME),max(PARTITION_NAME) from dba_segments where segment_name = 'PPREC';

MIN(PARTITION_NAME)            MAX(PARTITION_NAME)
------------------------------ ------------------------------
PART20110201                   PART20130130

There are several tablespaces and partitions are allocated in them

SQL> select tablespace_name, count(partition_name) from dba_segments where segment_name = 'PPREC' group by tablespace_name;

TABLESPACE_NAME                COUNT(PARTITION_NAME)
------------------------------ ---------------------
REC_DATA_01                                       281
REC_DATA_02                                        48
REC_DATA_03                                        70
REC_DATA_04                                        26
REC_DATA_05                                        44
REC_DATA_06                                        51
REC_DATA_07                                        13
REC_DATA_08                                        48
REC_DATA_09                                        32
REC_DATA_10                                        52
REC_DATA_11                                        35
REC_DATA_12                                        30

Additional query:

SQL> select * from dba_segments where segment_name='PPREC' and partition_name='PART20120912';

OWNER SEGMENT_NAME PARTITION_NAME SEGMENT_TYPE    TABLESPACE_NAME HEADER_FILE HEADER_BLOCK BYTES BLOCKS EXTENTS 
----- ------------ -------------- --------------- --------------- ----------- ------------ ----- ------ -------
HIST  PPREC        PART20120912   TABLE PARTITION REC_DATA_01              13       475315 65536      8       1

INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS PCT_INCREASE FREELISTS FREELIST_GROUPS RELATIVE_FNO BUFFER_POOL
-------------- ----------- ----------- ----------- ------------ --------- --------------- ------------ -----------
  65536                              1  2147483645                                                 13    DEFAULT

Tabespace usage

Here is a space summary (composite of dba_tablespaces, dba_data_files, dba_segments, dba_free_space)

TABLESPACE_NAME                TOTAL_MEGABYTES USED_MEGABYTES FREE_MEGABYTES
------------------------------ --------------- -------------- --------------
REC_01_INDX                              30,700            250         30,449
REC_02_INDX                               7,745              7          7,737
REC_03_INDX                              22,692             15         22,677
REC_04_INDX                              15,768             10         15,758
REC_05_INDX                              25,884             16         25,868
REC_06_INDX                              27,992             16         27,975
REC_07_INDX                              17,600             10         17,590
REC_08_INDX                              18,864             11         18,853
REC_09_INDX                              19,700             12         19,687
REC_10_INDX                              28,716             16         28,699
REC_DATA_01                             102,718            561        102,156
REC_DATA_02                              24,544          3,140         21,403
REC_DATA_03                              72,710              4         72,704
REC_DATA_04                              29,191              2         29,188
REC_DATA_05                              42,696              3         42,692
REC_DATA_06                              52,780            323         52,456
REC_DATA_07                              16,536              1         16,534
REC_DATA_08                              49,247              3         49,243
REC_DATA_09                              30,848              2         30,845
REC_DATA_10                              49,620              3         49,616
REC_DATA_11                              40,616              2         40,613
REC_DATA_12                             184,922        123,435         61,486

The tablespace usage seems to confirm that this table is not empty, in fact its last tablespace (REC_DATA_12) seems pretty busy.

Existing scripts

What I find puzzling is that there are some PL/SQL stored procedures that seem to work on that table and get data out of it.
An example of such a stored procedure is as follows:

procedure FIRST_REC as
vpartition varchar2(12);
begin
select 'PART'||To_char(sysdate,'YYYYMMDD') INTO vpartition FROM DUAL;

execute immediate
'MERGE INTO FIRST_REC_temp a
 USING (SELECT bno, min(trdate) mintr,max(trdate) maxtr
        FROM PPREC PARTITION ('||vpartition||') WHERE route_id IS NOT NULL AND trunc(trdate) <= trunc(sysdate-1)
        GROUP BY bno) b
    ON (a.bno=b.bno)
    when matched then
    update set a.last_tr = b.maxtr
    when not matched then
    insert (a.bno,a.last_tr,a.first_tr)
    values (b.bno,b.maxtr,b.mintr)';
    commit;

However if I try using the same syntax manually on the table, here is what I get:

SQL> select count(*) from PPREC PARTITION (PART20120912);

  COUNT(*)
----------
         0

I have tried a few random partitions and I always get the same 0 count.

Summary
– I see a table that seems to contain data (space used, tablespaces, data files)
– The table is partitioned (one partition per day over a period of 730 days ending end of January 2013)
– Scripts are extracting data from that table somehow

Question
– My queries using PARTITION are all returning me “no rows selected”. What am I doing wrong? How could I find out how to extract data from this table?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:17:58+00:00Added an answer on June 11, 2026 at 6:17 am

    I suppose it’s possible that some other process might be deleting the data, but without visiting your site there’s no way for anyone here to tell if that might be so.

    I don’t see in your post that you mentioned the name of the partitioning DATE column, but based on the SQL you posted I’ll assume it’s TRDATE – if this is not correct, change TRDATE in the statement below to be the partitioning column.

    That said, give this a try:

    SELECT COUNT(*)
      FROM PPREC
      WHERE TRDATE >= TO_DATE('01-SEP-2012 00:00:00', 'DD-MON-YYYY HH24:MI:SS')
    

    This assumes you should have data in this table from September. If you find data, great. If you don’t – well, Back In The Day (when men were men, women were women, and computers were water-cooled 🙂 we had a little saying about memory on IBM mainframes:

    1.  If you can see it,   and it's there,     it's Real.
    2.  If you can't see it, but it's there,     it's Protected.
    3.  If you can see it,   but it's not there, it's Virtual.
    4.  If you can't see it, and it's not there, it's GONE!
    

    🙂

    Use of the PARTITION clause should be reserved for situations where you are experiencing a performance problem (note: guessing about what is or is not going to be a performance problem is not allowed. Until you’ve got a performance problem you don’t have a performance problem. Over the years I’ve found that software spends a lot of execution time in the darndest places :-), and the usual fixes (adding indexes, deleting unnecessary data, human sacrifice, etc) haven’t worked. Basically, write your queries normally and trust the database to get it right. (In the general case – always write the simplest code – and do the simplest thing – that could possibly work. 99+ percent of the time it will be fine. That allows you to spend your optimization time on the less-than-one-percent cases where simple isn’t good enough – and most of the software you write or design will be simple and easy to understand).

    Share and enjoy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added a new job in my hudson server which builds the project
In my new job more people are using Python than Perl, and I have
I'm new to asp world, and I have to keep my new job :)
Where I used to work, we version-controlled with Mercurial. I have a new job
I inherited several projects Javas in my new job, but I'm having some problems
Let's say I have the following grid: I can't seem to figure out how
I have an excel spreadsheet based on a pivot table that is periodically updated
I've a problem which is giving me some hard time trying to figure it
I have a PHP file that handles sending out confirmation emails. I also have
I was given this question at a job interview recently and couldn't figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.