Using the TableSpaceDAO

Viewpoint
Enthusiast

Using the TableSpaceDAO

I'm trying to use the getTableSkewPct method in the TableSpace model. I've written some code for it but I'm getting an error on Eclipse saying "The method getTableSkewPct() is undefined for the type QueryResults". I was told that to fix the error, I needed to get a for loop to find the tablespace but I can't figure is out. Here is my code...

[code]public QueryResults getMyTableSkewPeak(CpuUsagePreferences preferences)
{
Integer id = getSystemId(preferences.getSystem());
java.util.Date todaysDate = (java.util.Date) Calendar.getInstance().getTime();
Timestamp startTime = Timestamp.valueOf(todaysDate.getYear() + "-" + todaysDate.getMonth() + "-" +
todaysDate.getDate() + " 00:00:00.000000000");
QueryResults ts = tableSpaceDAO.getTableSpace (id, startTime, null);
ts.getTableSkewPct();
return tableSpaceDAO.getTableSpace(id, startTime, null);[/code]
4 REPLIES
Teradata Employee

Re: Using the TableSpaceDAO

First, you need to strongly type your QueryResults (ts) object rather than use the raw type, otherwise you will have to do ugly casting that can cause problems down the road. So, change:

QueryResults ts = tableSpaceDAO.getTableSpace (id, startTime, null);

to:

QueryResults ts = tableSpaceDAO.getTableSpace (id, startTime, null);

Second, you need to pull your query result set from the QueryResults object. Using your example, doing the following will give you the result set:

List resultSetList = ts.getResults();

Now you have a list of size X, where each element in the list contains a TableSpace object. Now you can view the TableSkewPct of a particular objext row in the result set (if of course, the list has at least one element):

resultSetList.get(X).getTableSkewPct();
Enthusiast

Re: Using the TableSpaceDAO

What did you change that first line of code to? It looks like you posting the same thing.
Teradata Employee

Re: Using the TableSpaceDAO

You are defining the QueryResults generic type as having TableSpace objects, so:

QueryResults ts = tableSpaceDAO.getTableSpace (id, startTime, null);
Teradata Employee

Re: Using the TableSpaceDAO

Ah, it's stripping it out:

QueryResults<TableSpace< ts = tableSpaceDAO.getTableSpace (id, startTime, null);

The second part on the earlier example should be:

List<TableSpace> resultSetList = ts.getResults();