V4REV - select using sql functions returns bizarre values

Bernard Devlin bdrunrev at gmail.com
Thu Dec 15 09:44:27 CST 2011


Here is the code.  When I came across the first function call that did
not work ("format()"), I ran through a sampling of them, as given in
the wiki.   I am otherwise able to select my data from the database
(provided that data is non-blob data, as mentioned in my earlier
emails/reports about the bugs in the bind/array interface).

All the "select function" calls listed below are directly from the
Valentina Wiki, and they are sent to the database using
VDatabase_SqlSelect, which returns a cursor, and the values are
extracted from the cursor using VField_Value (which appears to be the
only way to get hold of those values).   As I say, in the case of
_some_ function calls (those returning integers) they seem to be
returned correctly.

Anyway, here's my code that produces the bizarre results.

function doLocaleFormat pDataString, kFormatType, pLocaleId
   put fullPathFromConfigDict( getValentinaConfig() ) into tFilePath
   put gValDatabaseAuditDict[tFilePath]["handle"] into tValDatabaseHandle
   repeat for each line tStatement in valFunctionStatements()
      put cr & tStatement after tListOfResults
      put tListOfResults into msg
      put VDatabase_SqlSelect( tValDatabaseHandle, tStatement) into tCursor
      put tCursor into tValDict["db_response"]
      handleError tValDict
      put getListFromValCursor( tCursor) into tResult
      put  "=" && tResult after tListOfResults
      get VCursor_Destructor( tCursor )
   end repeat
   return tListOfResults
end doLocaleFormat

function valFunctionStatements
   put "SELECT DATABASEVERSION();" & cr after tList
   put "SELECT CONCAT('Va', 'len', 'tina');" & cr after tList
   put "SELECT HEAD('aesop', 'ea');" & cr after tList -- => 'ae'
   put "SELECT HEX( 327680 ) ;" & cr after tList
   put "SELECT FORMAT(now(), '', 'kDateFormatFull');" & cr after tList
   put "SELECT INITCAP ( 'valentina' );"  & cr after tList
   put "SELECT LEFT('database', 5);" & cr after tList
   put "SELECT IF('Hello!' LIKE 'Hello_', 1, 0);" & cr after tList
   put "SELECT LOCATE('len', 'Valentina');" & cr after tList
   put "SELECT MD5('1234567890');" & cr after tList
   put "SELECT REGEX_REPLACE('abcd', '(ab)(cd)', '$2--$1:' );" & cr after tList
   put "SELECT REVERSE('data');" & cr after tList
   put "SELECT RPAD('hello',7,'?');" & cr after tList
   put "SELECT SCHEMAVERSION();" & cr after tList
   return line 1 to -1 of tList
end valFunctionStatements

function getListFromValCursor pValCursorPointer
   put VCursor_FieldCount( pValCursorPointer ) into tFieldCountTotal
   put VCursor_RecordCount( pValCursorPointer ) into tRowCountTotal
   get VCursor_FirstRecord( pValCursorPointer )
   repeat with tRowCounter = 1 to tRowCountTotal
      get VCursor_Position(pValCursorPointer, tRowCounter )
      put VCursor_Position(pValCursorPointer ) into tCurrentRow
      repeat with tFieldCounter = 1 to tFieldCountTotal
         put VCursor_Field( pValCursorPointer, tFieldCounter ) into fldRef
         try
            put VField_Name( fldRef) into tFieldName
            put VField_Type(fldRef  ) into tFieldType
            switch
               case tFieldtype contains "blob"
                  put VBLOB_ReadRawData( fldRef ) into tFieldValue
                  break
               default
                  put VField_Value( fldRef ) into fldValue
                  break
            end switch
         catch tErr
            breakpoint
         end try
         put fldValue & tab after tList
      end repeat
      put cr after tList
   end repeat
   return line 1 to -1 of tList
end getListFromValCursor

Bernard


On Thu, Dec 15, 2011 at 12:25 PM, Ruslan Zasukhin
<ruslan_zasukhin at valentina-db.com> wrote:
> I believe issue is not infunction.
>
> They work in other ADKs and just in Vstudio.
>
> Issue is or
>
> A) in method of V4REV you try to use to get string from cursor
>
> B) or ... Hard to image what else
>
> Please show EXACT code of rev you have to get this ?
>
> Can you get other string fields from cursor ?


More information about the Valentina mailing list