0

I want to append a new column in the fashion of

public CachedRowSet addColumn(cachedRowSet Original,List<item> column, String columnName);

or

public CachedRowSet addColumn(cachedRowSet Original,int column,String columnName);

with the column value repeated if it is a primitive.

What is the best way to do this?

sakurashinken
  • 3,940
  • 8
  • 34
  • 67

2 Answers2

2

Hmm.. hard to answer without knowing the context. Who is providing that CachedRowSet? They might or might not offer a way to generate a new instance. Are you using CachedRowSetImpl from the RI?

The RowSet is not really intended for that. Can you add it to the generating SQL? SELECT a,b,'additional' from .... Or you can use your CachedRowSet and generate JoinedRowSet with a FULL_JOIN with a single field result set.

eckes
  • 10,103
  • 1
  • 59
  • 71
  • Its coming from a jdbc Teradata query. I'm using the .populate(RowSet r) method to save the rowset after the statement is closed. – sakurashinken Aug 09 '14 at 19:57
0

You can't do that in SQL, let alone CachedRowSet, without executing DDL, and CachedRowSet doesn't support that. The part about a repeating value is an elementary violation of 3NF. You probably don't want to do any of this.

user207421
  • 305,947
  • 44
  • 307
  • 483