Deepak Mangla
Deepak Mangla

Reputation: 11

How to find out list of objects used last year in IBM i

Is there any query to find out "How to find out list of objects in the system used last year in IBM i/AS400"

Upvotes: 0

Views: 1811

Answers (1)

jmarkmurphy
jmarkmurphy

Reputation: 11493

There are a lot of objects on the typical IBM i. While you can indeed search for the last use of all objects, the query will likely take longer than you want. Better to do 1 library at a time.

You can use this command to retrieve object descriptions into a database file which you can query:

DSPOBJD OBJ(LIBRARY/*ALL)        
        OBJTYPE(*ALL)           
        OUTPUT(*OUTFILE)        
        OUTFILE(LIBRARY/OBJUSED)

Or you can use the table function mentioned by @jweberhard like this:

select * from table (object_statistics('LIBRARY', '*ALL')) a

Note the upper case library name and '*ALL' in the SQL. This is important.

While you can use *ALL in place of LIBRARY in either option, that will cause the run to take a long time.


To get non system libraries you can use something like this:

select * from table (object_statistics('*ALL', '*ALL')) a
where objlongschema not like 'Q%'

Upvotes: 0

Related Questions