Forum Discussion

Connor888's avatar
Connor888
Frequent Visitor
6 years ago
Solved

Feed a parameter to an external data connection (ODBC)

Hello! 

 

I'm trying to build a query which connects to an external database with ODBC, but only retrieves a certain line of data determined by an input table in excel, which just has a single cell with an item number in it. 

 

What I've tried to do is as follows (simplified because the SQL is loooong):

 

ExtData = Odbc.Query("dsn=myexternalsource","select * from FILE where ItemNumber ='" & Variable & "'"

 

Where 'Variable' is from the input table loaded elsewhere. This gives me a firewall error, as a step can't reference an external data source and another query. 

 

I can get around  this by just loading the whole table and then inner joining or filtering with the input table, but this will be slower than passing the request off to the server to do it for me since the file I'm querying is very large and I'm retrieving a lot of data. The question is, is this possible?

 

Thanks! ☺

  • Hi Connor888 ,

     

    Because of Query isolation, it is hard to query another data source by refer another query, but it should work if you query them in the same query, such as following:

     

    let
      Source = get...excel...file...from.connector.instead.of.another.query,
      Line = get...certain...line...from...Source,
      Variable = get..itemnumber..from..Line,
      ExtData = Odbc.Query("dsn=myexternalsource","select * from FILE where ItemNumber ='" & Variable & "'"
    in
      ExtData

     


    Best regards,

     

1 Reply

  • v-lid-msft's avatar
    v-lid-msft
    Icon for Community Support rankCommunity Support

    Hi Connor888 ,

     

    Because of Query isolation, it is hard to query another data source by refer another query, but it should work if you query them in the same query, such as following:

     

    let
      Source = get...excel...file...from.connector.instead.of.another.query,
      Line = get...certain...line...from...Source,
      Variable = get..itemnumber..from..Line,
      ExtData = Odbc.Query("dsn=myexternalsource","select * from FILE where ItemNumber ='" & Variable & "'"
    in
      ExtData

     


    Best regards,