Re: [PHP] ODBC and long text fields



On Sunday 07 January 2007 8:26 pm, Jochem Maas wrote:

Now I'll be honest and say I don't quite follow what they're talking
about. I do not claim to be an ODBC guru, but SQLGetData is a lower-level
operation, SQL level or C level I don't know, but not something that
happens in PHP code as far as I am aware. Are they saying there's a bug
in PHP's
odbc_fetch_row()? Or is it a bug in their driver if it can't handle
whatever it is odbc_fetch_row() does internally?
Or should we be using odbc_result()
instead of odbc_fetch_row() if we're dealing with a text field rather
than a varchar or int?

the way I read it odbc_result() is just an alternative way of doing what
you do with odbc_fetch_row() - I can't see any reason why doing it with
odbc_result() would suddenly make it work - nonetheless it might be worth
trying it just to rule it out.

with regard to wanting results returned in a 'named' fashion, does the new
setup still not allow use of odbc_fetch_array() instead of
odbc_fetch_row()? not that I see any logic in that solving the issue, again
it might be worth trying to see if it does.

Honestly I've not tried. (I also don't have the wrapper code in front of me
at the moment. <g>) That could be a nice thing to simplify for performance,
but I suspect that if the problem is with odbc_fetch_row() then
odbc_fetch_array() will have the same bug.

I don't know much about MSSQL, or whether 'text' is an actual field type,
but maybe this function offers a wayout?:

http://php.net/manual/en/function.odbc-binmode.php

No, that looks like it's for binary data. "Text" is a MS SQL field for
huge-ass text fields, essentially similar to the MySQL field of the same name
(at least at an API level). We also tried playing with odbc_longreadlen()
and setting MS SQL's TEXTSIZE and TEXTLENGTH parameters to no avail.

are the php versions on the 2 systems you mention exactly the same? (you
mention 5.1 and 5.1.6) this could be a clue to the problem.

It's either both 5.1.6 or 5.1.6 live and 5.1.4 devel. (I don't recall what
our exact version is atm.) We're in the process of upgrading our server
soon, and I'm not sure what it will have. Probably 5.2, just to keep life
interesting. :-)

lastly I don't suppose that it possible for you to switch to using the
MSSQL specific php extension? [http://php.net/mssql] it might offer a
better/faster connection to the MSSQL server as well as making the issue go
away.

I don't believe the client allows direct MSSQL connections. Besides, the
MSSQL functions still require an ODBC driver underneath, so if the problem is
with the ODBC driver then that won't change anything.

--
Larry Garfield AIM: LOLG42
larry@xxxxxxxxxxxxxxxx ICQ: 6817012

"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
.



Relevant Pages

  • Re: Incorrect number of parameters, expected 2.
    ... ODBC will replace them with whatever the underlying driver wants. ... Since Matt was able to get it to work with the table name in double quotes ... I believe him when he says it's a bug in the ODBC driver. ... > MNM> string constants embedded in the SQL. ...
    (microsoft.public.data.odbc)
  • RE: Invalid cursor state when using PRINT in MSSQL
    ... SQL> print 'start' select 1 ... Running your Perl code to my SQL Server with my DSN etc I get: ... You go try turning on ODBC tracing in the driver manager, ... > The server and all the SP's I am running this on is MSSQL and not Sybase. ...
    (perl.dbi.users)
  • Re: AS400 & filter by date
    ... we need to import data from AS400 to MS SQL 2000 via ODBC driver ... (iSeries ODBC by IBM). ... with system date (MS SQL) ... CURRENT_DATE which you would then have to convert to the number format that ...
    (microsoft.public.sqlserver.dts)
  • Embedded SQL in COBOL (was: If you were inventing CoBOL...)
    ... If the SQL is talking ... >through an ODBC driver, it can access any brand of relational ... When the compiler provides an ODBC client driver, ...
    (comp.lang.cobol)
  • Re: HOWTO?: force optimizer to use a "remote index join" when joining local to remote table
    ... If you are using ODBC, you can turn on ODBC tracing ... This will work for any ODBC driver or client, ... ODBC messages take the form of SQL statements. ... syntax is similar to MS SQL Server SQL. ...
    (microsoft.public.access.externaldata)