Table name is not shown to end user if result set contains a query with alias in stored procedure. for example procedure contains a result set with some alias for e.g select count(*) as count1 from tab;
code snippet:(After procedure execution and got the resutlset) ResultSetMetaData rsMetadata = rs.getMetaData(); String tableName = rsMetadata.getTableName(column_index);
There are two points to note here:
Table names associated with columns are not preserved when the table is composed by the stored procedure.
Normally, a result set from a stored procedure will not have table names attached to the columns. However, if the stored procedure always results in the same, single select statement; the optimizer may inline the select statement. In this case the associated table names will be preserved (for normal, non-expression, columns).
If the column is an expression, no table name should be associated it
The table name of an aliased column can be determined, but any column made up of an expression does not return a table name (aliased or not). Your example “select count(*) as count1 from tab” returns no table name (empty string) for column 1, even when the alias is removed.
It seems that SQL Anywhere’s 'implementation-defined returned value' is an empty string