4 Replies Latest reply on Mar 28, 2013 10:51 AM by jane_lj

    alias AS

    jane_lj Novice

      Hi,

       

      I have my VDB deployed to Teiid which has my own translator.

       

      When I do a query with alias like this:

       

      statement 1 -- SELECT uwi AS aaa FROM table1

       

      The column name displayed in the result is still uwi, not aaa.

       

      Only this one works fine:

       

      statement 2 -- SELECT count(uwi) AS aaa from table1

       

       

      Do I need to implement it in my translator to make statement 1 work?

       

      Thanks.

        • 1. Re: alias AS
          Steven Hawkins Master

          > The column name displayed in the result is still uwi, not aaa.

           

          I assume you mean from the Teiid client.  In the resultset metadata there is both a column name and a column label.  With JDBC4 it was standardized that the column name should refer to the actual column when possible.  The column label is probably what you want instead, which will always refer to the alias if one is given.

           

          Steve

          • 2. Re: alias AS
            jane_lj Novice

            Thank you, Steve.

             

            I'm not doing from Teiid client code.

             

            I'm using a third party tool "SQuirreL" which can let me connect to my VDB and do "SELECT uwi AS aaa FROM table1".

             

            So from what you said, my understanding is I don't need to do anything for alias "AS" in my translator, right? Just want to make sure my translator is not the one make the alian not work.

            • 3. Re: alias AS
              Steven Hawkins Master

              > I'm using a third party tool "SQuirreL"

               

              Which is accessing Teiid through the Teiid client.

               

              > my understanding is I don't need to do anything for alias "AS" in my translator, right?

               

              There is nothing that you need to do relative to user query aliases from your translator correct.

               

              > Just want to make sure my translator is not the one make the alian not work.

               

              This goes back to the difference between whether you (or SQuirreL) is pulling ResultSetMetadata.getColumnName or getColumnLabel - see also http://docs.oracle.com/javase/6/docs/api/java/sql/ResultSetMetaData.html#getColumnLabel%28int%29

              • 4. Re: alias AS
                jane_lj Novice

                Thank you very much, Steven.