I am able to connect to a MSSQL server using sequel, and I can fetch data 
using .fetch, but when trying to use datasets I got "Incorrect syntax"

2.0.0-p247 :002 > a= Sequel.odbc('server', user: 'sqluser', password: 
'password')
#<Sequel::ODBC::Database: {:adapter=>:odbc, :database=>"server", 
:user=>"sqluser", :password=>"password"}>
2.0.0-p247 :006 >   a.fetch("select * from 
_PRODUCTIVIDAD_DIARIA_USUARIO").first

{
         :cliente => " ",
           :fecha => 2014-02-03 00:00:00 -0300,
...

2.0.0-p247 :008 >   a[:_PRODUCTIVIDAD_DIARIA_USUARIO]
#<Sequel::ODBC::Dataset: "SELECT * FROM \"_PRODUCTIVIDAD_DIARIA_USUARIO\"">

2.0.0-p247 :009 > a[:_PRODUCTIVIDAD_DIARIA_USUARIO].first
Sequel::DatabaseError: ODBC::Error: 37000 (102) [FreeTDS][SQL 
Server]Incorrect syntax near '_PRODUCTIVIDAD_DIARIA_USUARIO'.
        from 
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/sequel-4.17.0/lib/sequel/adapters/odbc.rb:45:in
 
`run'
        from 
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/sequel-4.17.0/lib/sequel/adapters/odbc.rb:45:in
 
`block (2 levels) in execute'
        from 
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/sequel-4.17.0/lib/sequel/database/logging.rb:33:in
 
`log_yield'
...

It seems to me that the quotes around the table name are the problem. How 
can that be solved?

Also, the MSSQL server has some tables with non-ascii names, like:

2.0.0-p247 :031 > a.fetch("select TABLE_NAME from 
information_schema.tables").all

    [63] {
        :table_name => "_CAMPA\xC3\x91AS"
    },

I've tried both:

2.0.0-p247 :034 >   a.fetch("select * from _CAMPA\xC3\x91AS").all
Sequel::DatabaseError: ODBC::Error: 37000 (102) [FreeTDS][SQL 
Server]Incorrect syntax near '�'.

and

2.0.0-p247 :035 > a.fetch("select * from _CAMPAÑAS").all
Sequel::DatabaseError: ODBC::Error: 37000 (102) [FreeTDS][SQL 
Server]Incorrect syntax near '�'.

Can that be solved?

Thanks,
Horacio J. Peña

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to