Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1303

Re: Odbc and client library/drivers

From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver
Subject Re: Odbc and client library/drivers
Date 2012-09-19 23:44 +0200
Organization Erland Sommarskog
Message-ID <XnsA0D3F197028B1Yazorman@127.0.0.1> (permalink)
References <94298aed-7cbb-41f8-a155-c4632fc9db35@googlegroups.com> <XnsA0D2DF54CB785Yazorman@127.0.0.1> <4486daa1-575b-4713-9ca5-f4c8654eb9c8@googlegroups.com> <XnsA0D3D87BB2DB5Yazorman@127.0.0.1> <3fe97e67-bae3-423e-9a1d-bdb938e48e7d@googlegroups.com>

Show all headers | View raw


björn lundin (b.f.lundin@gmail.com) writes:
> Exactly.
> Person A (wrinting standard code) decides to select some values from a
> table. Person B takes the prdoct, and make customer adjustments, B adds
> column ColB to the table. Person C does the actual project coding, and
> sees that standard does a select 
> from the table. He now uses the new column.
> But A only did select ColA from the table.
> 
> However the struct (which is autogenerated from the table definition)

I think this is the error. Just as you should not always use SELECT *, 
you should use the same object all over town just because the data 
comes from the same table. Rather you should have a record type per stored
procedure or somesuch.

> Yes, we use all the columns. We have no 'nice to have an extra string col' 
> at all.

My experience from having worked with a system that has lived for a
long time, is that everyonce in a while I would find columns that 
were useful once, maybe with a previous customer, but which smells
funny. Or that the need of a column (or an entire table) disappears. 
There is also the situation that a new requirement could possibly be
bundled with some existing functionality.

All these are situations where I wanted to first find the references in
the database code, and then sometimes look further in the client code
to see if the idea I had could be pursued.

> (DM) The application has already called SQLGetData for the current row;
> the number of the column specified in the current call was less than the
> number of the column specified in the preceding call; and the driver
> does not return the SQL_GD_ANY_ORDER bitmask for the
> SQL_GETDATA_EXTENSIONS option in SQLGetInfo 

I found in the entry for SQLGetData for SQL Server Native Client that it 
says: "The SQL Server Native Client ODBC driver does not support using 
SQLGetData to retrieve data in random column order.".

> Are there any other driver that lets me retrieve values from a resultset 
> in the order I choose?
 
There are a couple of vendors on the market, but I would guess
they mainly focus on non-Windows platforms. They may also be less
complete than Microsoft.

As I said, I am not very well versed in ODBC, but it appears that binding
columns with SQLBindCol is an alternative, although it may not fit well
with Ada. But given this restriction, this is an accident waiting to happen
unless you bundle it properly. I am thinking that you would use something
that uses SQLDescribeCol to find out the column order, and then 
retrieves the column to fill the record. But I only have a dim idea
of how that would work.

I will have to learn ODBC one day, since my interface for Perl programmers
uses OLE DB, and Microsoft has deprecated OLE DB as a means of connection
to SQL Server.

-- 
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Odbc and client library/drivers björn lundin <b.f.lundin@gmail.com> - 2012-09-18 10:48 -0700
  Re: Odbc and client library/drivers Erland Sommarskog <esquel@sommarskog.se> - 2012-09-18 21:57 +0200
    Re: Odbc and client library/drivers björn lundin <b.f.lundin@gmail.com> - 2012-09-18 13:24 -0700
      Re: Odbc and client library/drivers George Neuner <gneuner2@comcast.net> - 2012-09-19 11:46 -0400
      Re: Odbc and client library/drivers Erland Sommarskog <esquel@sommarskog.se> - 2012-09-19 21:16 +0200
        Re: Odbc and client library/drivers Gene Wirchenko <genew@ocis.net> - 2012-09-19 13:14 -0700
          Re: Odbc and client library/drivers björn lundin <b.f.lundin@gmail.com> - 2012-09-19 13:41 -0700
            Re: Odbc and client library/drivers björn lundin <b.f.lundin@gmail.com> - 2012-09-19 13:45 -0700
              Re: Odbc and client library/drivers björn lundin <b.f.lundin@gmail.com> - 2012-09-19 13:56 -0700
                Re: Odbc and client library/drivers björn lundin <b.f.lundin@gmail.com> - 2012-09-19 14:00 -0700
        Re: Odbc and client library/drivers björn lundin <b.f.lundin@gmail.com> - 2012-09-19 13:26 -0700
          Re: Odbc and client library/drivers Erland Sommarskog <esquel@sommarskog.se> - 2012-09-19 23:44 +0200
            Re: Odbc and client library/drivers björn lundin <b.f.lundin@gmail.com> - 2012-09-20 01:50 -0700
              Re: Odbc and client library/drivers Erland Sommarskog <esquel@sommarskog.se> - 2012-09-20 23:31 +0200
                Re: Odbc and client library/drivers björn lundin <b.f.lundin@gmail.com> - 2012-09-21 01:18 -0700
                Re: Odbc and client library/drivers bradbury9 <ray.bradbury9@gmail.com> - 2012-09-21 02:57 -0700
                Re: Odbc and client library/drivers björn lundin <b.f.lundin@gmail.com> - 2012-09-21 03:10 -0700
                Re: Odbc and client library/drivers björn lundin <b.f.lundin@gmail.com> - 2012-09-21 03:14 -0700
  Re: Odbc and client library/drivers rja.carnegie@gmail.com - 2012-09-19 16:57 -0700
    Re: Odbc and client library/drivers björn lundin <b.f.lundin@gmail.com> - 2012-09-20 01:58 -0700

csiph-web