title: "ORA-24777: Use of non-migratable database link not allowed" when calling Oracle stored procedure from Windows Service
body: <p>I am creating a Windows Service that will regularly call a set of stored procedures on an Oracle Database. These stored procedures all work when called directly using SQL Developer. In addition, these stored procedures all work when called via a console application. However, when calling these stored procedures with a Windows Service, any stored procedure that has a database link (to an SQL Server) in fails.</p>
  
  <p>To isolate the issue, I have done the following...</p>
  
  <ul>
  <li>Console App and Windows Service use same Oracle Managed Data Reference/Version</li>
  <li>Console App and Windows Service use same exact connection string and app.config settings</li>
  <li>Console App and Windows Service use same exact class for executing the stored procedure</li>
  <li><p>Simplified the stored procedure with the database link to the following: </p>
  
  <pre><code>create or replace 
  PROCEDURE DATALINKTEST AS 
  BEGIN
  
      DECLARE lv_latest_FileLoadId INT;
  
      BEGIN
          SELECT MAX(c."FileLoadId")
          INTO lv_latest_FileLoadId
          FROM table@databaselink c
          WHERE c."account_code" = 'account123';
      END;
  
  END DATALINKTEST;
  </code></pre></li>
  </ul>
  
  <p>Even the above stored procedure generates a "ORA-24777: Use of non-migratable database link not allowed" when called from a Windows Service. However when called from a console app or directly via SQL Developer, it works fine.</p>
  
  <p>I have a feeling the issue lies somewhere with the type of session Oracle is making for the Windows Service. When I did a select on v$session table, I noticed that the Service sessions had a null SQL_ADDRESS and SQL_ID whereas the Console App and SQL Developer had a SQL_ADDRESS and SQL_ID</p>
  
  <p>Thanks in advance,
  Gabe B</p>