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


Groups > comp.lang.clipper.visual-objects > #11117

Re: SQL fieldtype changes when a query is modified to sort and GetData returns nothing

From "Jamal" <noooospam@example.com>
Newsgroups comp.lang.clipper.visual-objects
Subject Re: SQL fieldtype changes when a query is modified to sort and GetData returns nothing
Date 2017-11-01 01:09 -0400
Organization albasani.net
Message-ID <otbktr$akv$1@news.albasani.net> (permalink)
References <29khvclsp32srlu94bc8t6iq9mi6k7cmfp@4ax.com>

Show all headers | View raw


In the SDK:

This function SqlIsLongType() returns 'M' if column is one of the types 
listed.
I suggest you check the SDK if you have it and debug.

FUNCTION __GetStringFromODBCType( ODBCType AS SHORTINT ) AS STRING PASCAL
    LOCAL cType     AS STRING

    DO CASE
        // other cases goes here.
    CASE SqlIsLongType( ODBCType )           // <<====== HERE
        cType := "M"

    OTHERWISE
        cType := "C"

    ENDCASE

    RETURN cType

FUNCTION SqlIsLongType(nODBCType AS LONG) AS LOGIC
   RETURN ( nODBCType = SQL_LONGVARCHAR )   .OR. ;
      ( nODBCType = SQL_LONGVARBINARY ) .OR. ;
      ( nODBCType = SQL_VARBINARY )     .OR. ;
      ( nODBCType = SQL_WLONGVARCHAR)

HTH,
Jamal

"D.J.W. van Kooten"  wrote in message 
news:29khvclsp32srlu94bc8t6iq9mi6k7cmfp@4ax.com...

I use the following code to read data from a MySQL database over ODBC
in my program:

oConn:=SQLConnection{"Myodbc",cDB,cpw}

cSQL:="SELECT somefield,text FROM Myview where Keyfield is null

oSelectView:=SQLSelect{ cSQL, oConn }
oSelectView:Gotop()
cField:="text"
cFieldType:=oSelectView:FIELDINFO( DBS_TYPE, cField)
cContent:=oServer:Getdata(cField) // Content of field 'text'
correctly assigned

This has always worked. The text field is of type 'text' and returns
"C" in the above FieldInfo statement.

Now my client wanted to insert the data in a specific order and asked
me to change the query as follows:

cSQL:="SELECT somefield,text FROM Myview where Keyfield is null ORDER
BY leadid ASC

So basically it only differs with this added:

ORDER BY leadid ASC

The result is quite strange. While GetData still retrieves the content
of MySQL varchar fields (like 'somefield' in the above query) this is
not the case for the text field anymore. The returned fieldtype
changed from "C" to "M" and the GetData now returns  an empty content.

I emphasize that the query does not give a different result (e.g. if
exectuted in MySQL Workbench where we have one test view record
ready), also not in the VO program where the other fields return
content as before.

What could cause an ORDER BY addition to give this problem?

Dick 

Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

SQL fieldtype changes when a query is modified to sort and GetData returns nothing D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2017-10-31 20:54 +0100
  Re: SQL fieldtype changes when a query is modified to sort and GetData returns nothing "Jamal" <noooospam@example.com> - 2017-11-01 01:09 -0400
    Re: SQL fieldtype changes when a query is modified to sort and GetData returns nothing D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2017-11-03 15:22 +0100
  Re: SQL fieldtype changes when a query is modified to sort and GetData returns nothing Sherlock <sherlock@sherlock.com.au> - 2017-11-02 03:19 -0700

csiph-web