mikra01 / nimodpi

Oracle ODPI-C wrapper for Nim
MIT License
21 stars 0 forks source link

Not sure if I'm using this correctly #2

Closed UNIcodeX closed 4 years ago

UNIcodeX commented 4 years ago

Looking at the when isMainModule block of db_odpi.nim I put this together.

import strformat

import nimodpi

const
  userName:         string = "{username}"
  password:         string = "{password}"
  server:           string = "{server}"
  port:             string = "{port}"
  serviceName:      string = "{servicename}"
  connectionString: string = fmt"""(DESCRIPTION = (ADDRESS = 
                    (PROTOCOL = TCP)
                    (HOST = {server})  
                    (PORT = {port}))
                    (CONNECT_DATA =(SERVER = DEDICATED)
                    (SERVICE_NAME = {serviceName} )
                  ))"""

var octx: OracleContext

newOracleContext(octx, DpiAuthMode.SYSDBA)

var conn: OracleConnection

createConnection(octx, connectionString, userName, password, conn)

let strSQL = """
select
  current_date
from dual
"""

But not even trying to execute the SQL, I get the following error.

~\.nimble\pkgs\nimodpi-0.1.0\nimodpi.nim(478, 8) template/generic instantiation of `cImport` from here
~\.choosenim\toolchains\nim-1.2.0\lib\core\macros.nim(632, 26) Error: undeclared identifier: 'dpiAuthMode'

Any advice?

mikra01 commented 4 years ago

Hi, if you are using XE you can directly compile and run "db_oracle.nim" without modifications. do you tried that? btw, could you provide me your nim version?

mikra01 commented 4 years ago

think you had an issue with the odpi-c driver version. nimterop always fetched the master branch ( hardcoded within nimodpi.nim ). I changed that now to a specific tag ( for now 4.0.2). If you like to switch to another version be sure to delete nimterop's nimcache directory ( /nimcache/nimterop/ ) before compiling.