Forum Discussion

maxtester's avatar
8 years ago

Converting error for SQL- results to datatype 'unknown' in TC 12

Hi all,


at the moment we try to find out if we can merge our project to TC 12 (actual version 11.20). First we do not want  to merge to JavaScript but use JScript. The most parts of our JScript code works in TC 12. But in one point I realy have a problem in understanding.

I use a SQL- Statement to get some IDs from a MSSQL database. Therefore I use ADO. However the databasefield is a "BigInt" datatype. When I execute my function in TC 11 I get the ID as an Integer and everything is fine . When I execute the same code in TC 12 the value of the field is returned as datatype "unknown" (checked with "typeof" - the TC locals- output shows it as a string).  I realy do not understand what is going on here. Can anybody help.


BTW: The problem is not specific for the uses query. All integer values from databas are returned like described above.





5 Replies

  • I have a solution that works for me :


    JavaScript does only support integer as number. No supply for BigInt. In TC 11 the handling seems to work different with the used JScript version. It doesn't support BigInt too, but it can handle it somehow (maybe conversion to string or whatever).

    However I  use ADO for reading my databases. Some fields have the datatype "BigInt" (for example IDs). When I go through the response I chech which datatype is used for the field. BigInt has the property value "25" for the property "DataType". In this case I need to take the "DisplayText" and not the value, like this: 


    if(obj_SQLObject.Field(i).DataType === 25){
    str_Value = obj_SQLObject.Field(i).DisplayText
    str_Value = obj_SQLObject.Field(i).value


    The only problem is, that "DisplayText" returns a string. So if it is necessary to work with this value (computing or whatever) you need a workaround. I have created a small lodashfp function, which spilts the string into an array:


    var obj_ID = {left: parseInt(_.join("",_.dropRight(4,_.toArray(str_BigInt)))),right: parseInt(_.join("",_.takeRight(4,_.toArray(str_BigInt)))) + int_AddNumber}
    return obj_ID.left +""+ obj_ID.right


    I'm sure that there is a better solution but it works

  • tristaanogre's avatar
    Esteemed Contributor

    Can you post the code that you're using?  Might help to understand what you're dealing with as well as allow us to simulate the situation and debug it for you.

  • Yes I have tried the converting functions. In TC 11 it is ok, but in TC 12 it doesn't work.

    • tristaanogre's avatar
      Esteemed Contributor

      Gotcha... what about instead of your custom routine for converting DisplayText?