Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 56958 invoked from network); 20 Jan 2005 17:25:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 20 Jan 2005 17:25:28 -0000 Received: (qmail 96597 invoked by uid 500); 20 Jan 2005 17:25:27 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 96574 invoked by uid 500); 20 Jan 2005 17:25:26 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 96559 invoked by uid 99); 20 Jan 2005 17:25:26 -0000 X-ASF-Spam-Status: No, hits=0.4 required=10.0 tests=DNS_FROM_RFC_ABUSE X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from web53806.mail.yahoo.com (HELO web53806.mail.yahoo.com) (206.190.36.201) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 20 Jan 2005 09:25:26 -0800 Received: (qmail 50234 invoked by uid 60001); 20 Jan 2005 17:25:24 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=tM6EUZw85oFx6ik3+SKEDeokO+JbVBl7ecMPvTz+AZdyh5lOlg9BEyK0wi2khcZbJAlffdmNKHXkrS115VvVQPMvST8cXdwlKs8/nw9WpWKQZlm5Z494cajTC0j4KebxWe64Hg4hyh/IfgKNF3bYL7Kac8UHD/wKI5aKipv45MA= ; Message-ID: <20050120172523.50232.qmail@web53806.mail.yahoo.com> Received: from [206.173.41.67] by web53806.mail.yahoo.com via HTTP; Thu, 20 Jan 2005 09:25:23 PST Date: Thu, 20 Jan 2005 09:25:23 -0800 (PST) From: Jason Palmatier Subject: Re: LABEL ON functionality in Derby? To: Derby Discussion In-Reply-To: <41EEBEE4.9030503@Source-Zone.Org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi Rajesh, I was afraid Derby wouldn't have a way to set these values on the table itself. Your code snippet gives me an idea of how I might fake the functionality to a caller of a wrapper class though. Thanks again for the reply! Jason --- Rajesh Kartha wrote: > Hi Jason, > > I don't think the LABEL ON is supported in Derby. > But to use your > example for a table, I could achieve the same in the > following way using > ResultSetMetaData: > > Table: > ===== > create table aTable(id INTEGER NOT NULL, name > VARCHAR(255) NOT NULL, > description VARCHAR(255)) > > Select Statement: > ============ > SELECT id as "The First Column" , name as "The > Second Column", > description as DESC_DETAILS FROM aTable > > The select method : > ============= > > private void selectRows() throws SQLException{ > String sql="SELECT id as \"The First > Column\" , name as \"The > Second Column\", description as DESC_DETAILS FROM > aTable "; > stmt=conn.createStatement(); > ResultSet rs=stmt.executeQuery(sql); > ResultSetMetaData rsmd = rs.getMetaData(); > int numberCols = rsmd.getColumnCount(); > for(int i=1; i<=numberCols; i++) > { > System.out.print(rsmd.getColumnLabel(i)+" > | "); //print > the NEW Column names > } > System.out.println("\n"); > while(rs.next()){ > System.out.println(rs.getInt(1)+"\t | > "+rs.getString(2)+"\t > | "+rs.getString(3)+" "); > } > stmt.close(); > } > > The output of the above select shows: > > The First Column | The Second Column | DESC_DETAILS > | > > 0 | NAME 0 | DESCRIPTION for 0 > 1 | NAME 1 | DESCRIPTION for 1 > 2 | NAME 2 | DESCRIPTION for 2 > 3 | NAME 3 | DESCRIPTION for 3 > 4 | NAME 4 | DESCRIPTION for 4 > > The ResultSetMetaData returns the column names used > in the Select query > above. Needless to say, > the above works per statement. Hope the above helps. > > -Rajesh > > > > Jason Palmatier wrote: > > >Hi Rajesh, > > > > The select isn't what I'm looking for in this > case. > > I'm trying to create a table and then set the > value > >that would be returned by the ResultSetMetaData > call > >getColumnLabel(): > > > >ResultSet rs = stmt.executeQuery("SELECT COLUMN1, > >USERNAME FROM myTable"); > >ResultSetMetaData rsmd = rs.getMetaData(); > >int numberCols = rsmd.getColumnCount(); > >for(int i=0; i >{ > > System.out.println("Column " + i + " Label: " > > + rsmd.getColumnLabel(i); > >} > > > >This usually returns a String that can be used for > the > >human readable column heading when a table's > contents > >are displayed. After you execute a CREATE TABLE > >statement you would follow it with a > > > >LABEL ON COLUMN myTable > >( > > COLUMN1 is 'The First Column', > > COLUMN2 is 'The Second Column', > > USERNAME is 'User Name', > > PASSWORD is 'User Password' > >); > > > >This would set the labels for the specified columns > in > >the table "myTable" (this is DB2 syntax on an > >iSeries). I didn't find the LABEL ON command in > the > >Derby Reference manual so I was wondering if there > was > >another way to do this in Derby. Does that make > >sense? > > > >Thanks for the reply, > >Jason > > > >--- Rajesh Kartha wrote: > > > > > > > >>Hi, > >> > >>Is 'Select as from ' , what you are > >>looking for. > >> > >>The schema: > >>-------------- > >>ij> select * from atab; > >>ID |COL1|COL2 > >>--------------------- > >>1 |CA |MI > >> > >>1 row selected > >> > >>Using the 'select as' > >>------------------------ > >> > >>ij> select id as IDENT_NUM from atab; > >>IDENT_NUM > >>----------- > >>1 > >> > >>1 row selected > >> > >> > >>-Rajesh > >> > >> > >>Jason Palmatier wrote: > >> > >> > >> > >>>Does Derby support anything like LABEL ON which > >>> > >>> > >>allows > >> > >> > >>>you to set the label (i.e. a displayable name) > for > >>> > >>> > >>a > >> > >> > >>>column after a table is created? I checked the > >>>reference manual and it doesn't seem to but I > >>> > >>> > >>wanted > >> > >> > >>>to ask here to be sure. > >>> > >>>Thanks, > >>>Jason > >>> > >>>__________________________________________________ > >>>Do You Yahoo!? > >>>Tired of spam? Yahoo! Mail has the best spam > >>> > >>> > >>protection around > >> > >> > >>>http://mail.yahoo.com > >>> > >>> > >>> > >>> > >>> > >> > >> > > > > > > > > > >__________________________________ > >Do you Yahoo!? > >Yahoo! Mail - 250MB free storage. Do more. Manage > less. === message truncated === __________________________________ Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. http://mobile.yahoo.com/maildemo