# Possible "multiple dispatch" due to API differences between package versions?

**URL:** https://discourse.julialang.org/t/possible-multiple-dispatch-due-to-api-differences-between-package-versions/49005
**Category:** New to Julia
**Created:** [October 25, 2020, 9:52pm UTC](https://discourse.julialang.org/t/possible-multiple-dispatch-due-to-api-differences-between-package-versions/49005 "2020-10-25T21:52:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![indycdrom](https://avatars.discourse-cdn.com/v4/letter/i/eada6e/32.png) [@indycdrom](https://discourse.julialang.org/u/indycdrom)
#### Post date: [October 25, 2020, 9:52pm UTC](https://discourse.julialang.org/t/possible-multiple-dispatch-due-to-api-differences-between-package-versions/49005/1 "2020-10-25T21:52:04Z")

</div>

hi there,  
I am wondering whether it is possible to have one function having multiple dispatches simply due to the API changes between package versions.

For example, the newest version of ODBC.jl (v1.0.4), does no longer support ODBC.DSN and the assciated ODBC.query/ODBC.execute. To connect to databases, I need to use ODBC.Connection and DBInterface.execute. My question is that, if I have to maintain environments with different ODBC versions, how can I have one set of codes to accommodate that?

The following multiple dispatch did not work and errored out during initiation when running in the new ODBC environment（ **UndefVarError: DSN not defined** ）.

function myfunction(dsn::ODBC.DSN)  
#my codes  
end

function myfunction(cnn::ODBC.Connection)  
#my codes  
end

Can anybody point out a way, or I have to write two set of codes?

thanks!

---

<div class="post-metadata">

### Author: ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)
#### Post date: [October 25, 2020, 10:15pm UTC](https://discourse.julialang.org/t/possible-multiple-dispatch-due-to-api-differences-between-package-versions/49005/2 "2020-10-25T22:15:44Z")

</div>

You can try something like:

```julia
if isdefined(ODBC, :DSN)
    function myfunction(dsn::ODBC.DSN)
    #my codes
    end
else
    function myfunction(cnn::ODBC.Connection)
    #my codes
    end
end

```
