JRruby, Sybase JDBC, and DBI - Choosing an AS Partition Column Name

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:

--- Column 0 (TRANSACTION) ---
--- Column 1 (TRADE_CURRENCY) ---
--- Column 2 (settlement_currency) ---

or

TRANSACTION
TRADE_CURRENCY
settlement_currency

Squirrel SQL Client , DBI Sybase JDBC? - ?

0
3

, Sybase. jTDS (v1.2.5) http://jtds.sourceforge.net/ , DBI

-, , , jtds, DBI jRuby, , questions - - DBI URL-.

dbi:Jdbc:jtds:sybase://<host>:<port>/<db>

J Jdbc

, ;-)

0

, DBI, JDBC . DBI, , .

0

Sybase 6.0 JDBC drivers have some "interesting" alias-related behavior. The resultSet.findColumn method will fail to find the table column name if an alias is defined.

There are some properties that you can set on the connection to change some of these actions or simply use the JTDS drivers.

http://manuals.sybase.com/onlinebooks/group-jc/jcg0600e/prjdbc/@Generic__BookTextView/1072;pt=1072;uf=0

0
source

Source: https://habr.com/ru/post/1718777/


All Articles