Forum Discussion
maxtester
8 years agoContributor
You can make this also more dynamic and use this function. Just pass the SQLObject
function ExtractObjectFromSQLResult(obj_SQLObject,bool_DoNotSchowResults){
var obj_Result = []
//Get first item
obj_SQLObject.First()
Log.Message("Recors found: " +obj_SQLObject.RecordCount)
var j = 0
//Itterate through result and put into array
while (!obj_SQLObject.EOF)
{
var obj_OneSet = {}
if(bool_DoNotSchowResults === undefined || bool_DoNotSchowResults != true){
Log.Message("Fields found: " +obj_SQLObject.FieldCount)
}
for(var i = 0; i<obj_SQLObject.FieldCount;i++){
var str_FullName = obj_SQLObject.Field(i).fullname
var str_Value
//If the datatype is a bigint, take the DisplayText
if(obj_SQLObject.Field(i).DataType === 25){
str_Value = obj_SQLObject.Field(i).DisplayText
}
else{
str_Value = obj_SQLObject.Field(i).value
}
if(bool_DoNotSchowResults === undefined || bool_DoNotSchowResults != true){
Log.Message("Get line " +i+ ": " +str_FullName +";" + str_Value)
}
//AddToAobject
obj_OneSet[str_FullName] = str_Value
}
//add to object array
obj_Result[j] = obj_OneSet
j++
obj_SQLObject.Next();
}
return obj_Result
}