Skip to Content.
Sympa Menu

freetds - Re: [freetds] AS clause in 8.0

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: freetds AT lists.ibiblio.org
  • Subject: Re: [freetds] AS clause in 8.0
  • Date: Tue, 27 Mar 2012 22:41:32 -0400

On Tue, 27 Mar 2012 16:55:09 -0400
Richard Stevens <bitwizard AT skybest.com> wrote:

> It seems that somewhere between FreeTDS and PHP, it is determined
> that if there is no function, then the column name could not possibly
> need to be changed or aliased in the resultset.

I don't know whether you're using db-lib or ODBC. I know for certain
db-lib returns the aliased column name.

An ODBC IRD contains both the real column name and the alias. If
you're in that space, cf. SQL_DESC_LABEL in the IRD. According to
Microsoft's documentation for SQLSetDescField, that field has, in order:

1. The alias name (e.g. "1 as FOO")
2. The column name if unaliased
3. Nothing (e.g. "min(FOO)")

You can use bsqldb or bsqlodbc to display the metadata.

$ bsqldb -v -S $S -U$U -P$P <<< \
"select name as foo from systypes where name = 'int' "
bsqldb:183: Verbose operation enabled
bsqldb:232: Query:
select name as foo from systypes where name = 'int'
bsqldb:206: dbsqlsend(): OK
bsqldb:214: dbsqlok(): OK
bsqldb:310: calling dbresults: OK
Result set 1
Allocating buffers
Allocating compute buffers
Metadata
col name source
type size varies
------ ------------------------------ ------------------------------
--------------- ------ ------
1
foo foo char 128 1

Data
foo

-------------
int

Retrieving return status... none
1 rows affected
Retrieving output parameters... none
bsqldb:683: dbresults() returned NO_MORE_RESULTS (2)

HTH.

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page