Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  OPL connectivity to SQL server DB using ODBC

    Posted 10/22/18 08:38 AM

    Originally posted by: Nourredine


    Hi guys,

     

    I am trying to connect to connect SQL server database (e.g. Test) located on a server/instance (e.g. AAA is the server and BBB is the instance) using the connection string that is in the OPL documentation (DBConnection db("odbc","dataSourceName/userName/password"))

     

    My connection string using oledb can stated as: DBConnection db("oledb","//Test/AAA\\BBB").

    I tried to swap oledb with odbc: DBConnection db("oledb","//Test/AAA\\BBB"), but I got an error (

    Description Resource Path Location Type
    Database error (state=IL004 code=-12): Bad format for database specification, near "Test/AAA\BBB\".

     

    What would be the connection string to Test on AAA\BB?

     

    Thanks,

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: OPL connectivity to SQL server DB using ODBC

    Posted 10/22/18 09:38 AM

    Hi,

    DBConnection db("oledb","userName/password/database/dbServer");

    or

    DBConnection db("odbc","dataSourceName/userName/password");

    in IDE and OPL > Optimization Programming Language (OPL) > Language Reference Manual > OPL, the modeling language > Data sources > Database initialization

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: OPL connectivity to SQL server DB using ODBC

    Posted 10/22/18 10:17 AM

    Originally posted by: Nourredine


    Thanks Alex it works now; the CPLEX (OPL) model can connect to SQL server database, the solution is found.

     

    I have issue writing the solution to the same database using DBupdate. Below is the connection string, DBUpdate statement and the error message where trying to retreive the ouput from CPLEX and push it to the same database.

    DBConnection DBConn_HiringProblem("odbc","Hiring_Problem/PC08XT7T\\SQL2008DEVDSKTOP//");

     

    solution to DBUpdate(DBConn_HiringProblem, "insert into cplxo_hiring_problem_report(title, person, cost) values (?,?,?)");

     

    Error:

    Database error (state=22001 code=0): [Microsoft][ODBC SQL Server Driver]String data, right truncation, near "solution"

     

     

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: OPL connectivity to SQL server DB using ODBC

    Posted 10/22/18 10:45 AM

    Hi,

    this looks like a database issue.

    Are you sure your columns in the database are big enough to hold the strings from OPL ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer