// First define the ODBC connection in Windows


var odbcClient = new ODBCClient();


//------------details via http://www.connectionstrings.com/ .----------------------------------------------


odbcClient.source = "DSN=MySQL_ODBC; Uid=root; Pwd=DundasB1;"; // DNS, user and password of your database


if (odbcClient.open()) {    

//console.log ("ODBC Opend:", odbcClient.info());            //.info -> information of connected datasource


    try

    {

        var querytag = tagquery // define the Node we want to use to read the Query String from.

        var query = odbcClient.query(tagquery); // SQL query to bring the desired value from your database

        var value = []; //Create an array variable

        value.push(query[0][0]);//define las 2 partes del array y=0 x=0        

        //console.log("value is " +value);

        var timestamp = []; //Create an array variable

        timestamp.push(query[0][1]);//extract the second part of the array        

        //console.log("timestamp is " +timestamp);

            

        

                

        var node = new UaNode("AGENT.OBJECTS.Database_ARF.ValorResultado"); // Define the node that we want to assign the query result

        node.assign({value: value, sourcetime:new Date(timestamp)}); // Assign the query result to the node value

        //console.log(error);

                

        return(value);

        odbcClient.close();

    }

    catch (exp)

    {

        console.log(exp);

        if (exp.indexOf('No Data') > -1)

            return 0; // ok

            

        return undefined;

    }

    finally

    {

        if (odbcClient && odbcClient.opened == true)

            odbcClient.close();