I have a ruby ββscript that I run using JRuby Interpreter. script connects to Sybase database using DBI and Sybase JDBC (jTDS3.jar and jconn3.jar)
My problem is that I have a select query that changes the column names of the table. For example:
SELECT
t.TRANSACTION as 'business_transaction',
t.TRADE_CURRENCY as 'currency',
t.CURRENCY as 'settlement_currency'
...etc...
FROM
TRADE t
...etc...
My problem is to use examples directly from the documentation
sth = dbh.execute(stmt)
printf "Number of rows: %d\n", rows.size
printf "Number of columns: %d\n", sth.column_names.size
sth.column_info.each_with_index do |info, i|
printf "--- Column %d (%s) ---\n", i, info["name"]
end
or simply
sth = dbh.execute(stmt)
rows = sth.fetch_all
col_names = sth.column_names
sth.finish
DBI::Utils::TableFormatter.ascii(col_names, rows)
Not ALL names appear when I set them using the "how" clause in the query. Some of them are the original field names, and some are the names that I specified.
For example, they will be listed as:
or
TRANSACTION
TRADE_CURRENCY
settlement_currency
Squirrel SQL Client , DBI Sybase JDBC? - ?