Ask a Question

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

maxtester
Contributor

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.

 

Regards

 

Max

5 REPLIES 5
tristaanogre
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.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
maxtester
Contributor

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
}
else{
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
Esteemed Contributor

Have you tried using aqConvert.VarToInt? (https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqconvert/vartoint.html)

 

It might be worth trying to see if TC's conversion routines can do that for you... you might not need that check on DataType.  If you still do, than use aqConvert.VarToInt on the DisplayText.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
maxtester
Contributor

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

tristaanogre
Esteemed Contributor

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


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
cancel
Showing results for 
Search instead for 
Did you mean: