<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Batch Job or Automated Code for finding and killing SDE locks on a particular table. in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/batch-job-or-automated-code-for-finding-and/m-p/393755#M22536</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think there may be&amp;nbsp; two ways to do this on .NET&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You still have to create a batch program. In fact maybe two of them, one for the info and one for the kill (that you will create on the fly)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Create a .NET program&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Execute your SQL command to get the Table ID&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-run the sdemon -o info command using the bat file&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; you have to use the System.Diagnostics.Process&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; you also need to use process startinfo and a StreamReader to get the result (the process IDs with Tables)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; read each line of the result and find the the processid until for the TableID you have, when you find it, compose your command. I don't think you can execute SDE commands directly with the Diagnostics Process, so you will have to create a batch file with the command and run it when is created.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Use a shell execute command from the program. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run your shell command and send the results to a file (&amp;gt;file.txt")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have not tried it to see if it will run SDE commands, but I don't see why not. I have not used this in C#, just VB.net, so I don't know the libraries you need to include.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;read your file, and get the info you need for your kill command&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;compose your kill command&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run another shell execute statement within the program.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can save the executable program and put it in the scheduler.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Apr 2010 16:26:05 GMT</pubDate>
    <dc:creator>MarielaDel_Rio</dc:creator>
    <dc:date>2010-04-21T16:26:05Z</dc:date>
    <item>
      <title>Batch Job or Automated Code for finding and killing SDE locks on a particular table.</title>
      <link>https://community.esri.com/t5/data-management-questions/batch-job-or-automated-code-for-finding-and/m-p/393754#M22535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dear All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a batch job in place which truncates the existing table and loads the new data (using sdeimport) . Of late, i have been getting errors like 'table has been locked', while data loading.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, I have decided to modify the job.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Firstly, I need to find the locks on my table. And then kill the process. I have figured out how to do it manually as shown below. But i need to automate it. Please help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. to find out the registration_id for that table&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;select registration_id,table_name,owner from sde.table_registry where table_name='myTable'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. match for above registration_id in below results' sde_id&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sdemon -o info -I locks&amp;nbsp; --- to find out table lock information&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. sdemon -o kill -t sde_id&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How to automate the same to schedule it as a scheduled job?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It need not be a batch program. I can also have .net program too. Please help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Muzammil&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Apr 2010 07:51:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/batch-job-or-automated-code-for-finding-and/m-p/393754#M22535</guid>
      <dc:creator>MuzammilAK</dc:creator>
      <dc:date>2010-04-15T07:51:19Z</dc:date>
    </item>
    <item>
      <title>Batch Job or Automated Code for finding and killing SDE locks on a particular table.</title>
      <link>https://community.esri.com/t5/data-management-questions/batch-job-or-automated-code-for-finding-and/m-p/393755#M22536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think there may be&amp;nbsp; two ways to do this on .NET&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You still have to create a batch program. In fact maybe two of them, one for the info and one for the kill (that you will create on the fly)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Create a .NET program&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Execute your SQL command to get the Table ID&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-run the sdemon -o info command using the bat file&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; you have to use the System.Diagnostics.Process&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; you also need to use process startinfo and a StreamReader to get the result (the process IDs with Tables)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; read each line of the result and find the the processid until for the TableID you have, when you find it, compose your command. I don't think you can execute SDE commands directly with the Diagnostics Process, so you will have to create a batch file with the command and run it when is created.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Use a shell execute command from the program. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run your shell command and send the results to a file (&amp;gt;file.txt")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have not tried it to see if it will run SDE commands, but I don't see why not. I have not used this in C#, just VB.net, so I don't know the libraries you need to include.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;read your file, and get the info you need for your kill command&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;compose your kill command&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run another shell execute statement within the program.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can save the executable program and put it in the scheduler.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Apr 2010 16:26:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/batch-job-or-automated-code-for-finding-and/m-p/393755#M22536</guid>
      <dc:creator>MarielaDel_Rio</dc:creator>
      <dc:date>2010-04-21T16:26:05Z</dc:date>
    </item>
  </channel>
</rss>

