<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: delete code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 02:09:18 GMT</pubDate>
    <description>DZone Snippets: delete code</description>
    <item>
      <title>'Delete a Twitter entry' dissected</title>
      <link>http://snippets.dzone.com/posts/show/5145</link>
      <description>The following code was copied from my Twitter home page, it shows how to delete a twitter entry on the server.&lt;br /&gt;&lt;br /&gt;raw HTML code with embedded JavaScript code.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="/status/destroy/719423092" onclick="if (confirm('Sure you want to delete this update? There is NO undo!')) &lt;br /&gt;{var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = &lt;br /&gt;'POST'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); &lt;br /&gt;m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);var s = &lt;br /&gt;document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); &lt;br /&gt;s.setAttribute('value', 'd0057265c3784d2a6dc6cdb2c26083f638152151'); f.appendChild(s);f.submit(); };return false;" &lt;br /&gt;title="Delete this update?"&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;same code as above but with comments.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;a href="/status/destroy/719423092" onclick="&lt;br /&gt;&lt;br /&gt;                     // if the user clicks the 'OK' button the confirm function will return true&lt;br /&gt;if (confirm('Sure you want to delete this update? There is NO undo!')) { &lt;br /&gt;&lt;br /&gt;  // -- dhtml: creating html elements on-the-fly -------------------------------&lt;br /&gt;  var f = document.createElement('form'); // create the dhtml 'form' (&lt;form/&gt;) element&lt;br /&gt;  f.style.display = 'none';               // hide the form&lt;br /&gt;  this.parentNode.appendChild(f);         // append the form element to the parent of the current node (&lt;a/&gt;)&lt;br /&gt;  f.method = 'POST';                      // add the method to the form&lt;br /&gt;  f.action = this.href;                   // add the action using the href of the current node (&lt;a/&gt;)&lt;br /&gt;    &lt;br /&gt;  var m = document.createElement('input');   // create the input (&lt;input/&gt;) 'element' &lt;br /&gt;  m.setAttribute('type', 'hidden');          // set the input type to 'hidden'&lt;br /&gt;  m.setAttribute('name', '_method');         // set the input name to '_method'&lt;br /&gt;  m.setAttribute('value', 'delete');         // set the input value to 'delete'&lt;br /&gt;  f.appendChild(m);                          // append the input element to the form element&lt;br /&gt;  &lt;br /&gt;  var s = document.createElement('input');   // create another input element&lt;br /&gt;  s.setAttribute('type', 'hidden');          // set the type to 'hidden'&lt;br /&gt;  s.setAttribute('name', 'authenticity_token'); // set the name to 'authenticity_token'&lt;br /&gt;  &lt;br /&gt;                                     // set the input element's value using a unique id.&lt;br /&gt;  s.setAttribute('value', 'd0057265c3784d2a6dc6cdb2c26083f638152151'); &lt;br /&gt;  &lt;br /&gt;  f.appendChild(s);                  // apend the input element to the form element&lt;br /&gt;  // -- end of dhtml: creating html elements on-the-fly -------------------------------&lt;br /&gt;  &lt;br /&gt;  f.submit(); // post the form data back to the server to delete the record, &lt;br /&gt;              // just as if the user had pressed the submit button.&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;  return false; // returning false cancels the default &lt;a href="..."&gt; request. &lt;br /&gt;                 // However if JavaScript had been disabled for some reason the &lt;br /&gt;                 // &lt;a href="..."&gt; would have acted normally, meaning the record &lt;br /&gt;                 // would have been deleted from following the URL request directly.&lt;br /&gt; "&lt;br /&gt;&lt;/code&gt; &lt;br /&gt;Note: Twitter needs JavaScript for the web page to work properly, I've tried and it is not possible to delete a record without JavaScript.  The authenticity_token has been altered by me to prevent any malicious activity on my Twitter account.&lt;br /&gt;</description>
      <pubDate>Sat, 16 Feb 2008 13:17:07 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5145</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Empty a Directory with PHP</title>
      <link>http://snippets.dzone.com/posts/show/5004</link>
      <description>// ggarciaa at gmail dot com (04-July-2007 01:57)&lt;br /&gt;// I needed to empty a directory, but keeping it&lt;br /&gt;// so I slightly modified the contribution from&lt;br /&gt;// stefano at takys dot it (28-Dec-2005 11:57)&lt;br /&gt;// A short but powerfull recursive function&lt;br /&gt;// that works also if the dirs contain hidden files&lt;br /&gt;//&lt;br /&gt;// $dir = the target directory&lt;br /&gt;// $DeleteMe = if true delete also $dir, if false leave it alone&lt;br /&gt;//&lt;br /&gt;// SureRemoveDir('EmptyMe', false);&lt;br /&gt;// SureRemoveDir('RemoveMe', true);&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;function SureRemoveDir($dir, $DeleteMe) {&lt;br /&gt;    if(!$dh = @opendir($dir)) return;&lt;br /&gt;    while (false !== ($obj = readdir($dh))) {&lt;br /&gt;        if($obj=='.' || $obj=='..') continue;&lt;br /&gt;        if (!@unlink($dir.'/'.$obj)) SureRemoveDir($dir.'/'.$obj, true);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    closedir($dh);&lt;br /&gt;    if ($DeleteMe){&lt;br /&gt;        @rmdir($dir);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 18 Jan 2008 13:58:47 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5004</guid>
      <author>demods ()</author>
    </item>
    <item>
      <title>Mark directories to be deleted based on their date-stamp</title>
      <link>http://snippets.dzone.com/posts/show/4934</link>
      <description>This Ruby code selects file directories which are older than a certain date and outputs an XML file naming all the directories to be removed.  It does this by reading a directory listing formatted within the XML file 'dir.xml', all directories are named by a date-stamp, which is used to determine if the directory should be removed.&lt;br /&gt;&lt;br /&gt;This example is used to maintain the webcamera (named 'pear') which saves it's images to a date-stamped directory daily. Any directory which is older than 14 days will be marked for deletion.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  def directory_housekeeping()&lt;br /&gt;    lifespan = 14&lt;br /&gt;    format_mask = 'm_d_y'&lt;br /&gt;    separator = format_mask.match(/[\_*\-]/).to_s&lt;br /&gt;    &lt;br /&gt;    earliest_date = Time.now + (60 * 60 * 24) * -lifespan&lt;br /&gt;    cut_off_date = Date.new(y=earliest_date.year,m=earliest_date.month,d=earliest_date.day)&lt;br /&gt;        &lt;br /&gt;    a_format = Array.new&lt;br /&gt;    a_format[0] = format_mask.match(/^[y,m,d]*/).to_s&lt;br /&gt;    a_format[1] = format_mask.match(separator + '[y,m,d]*').to_s.gsub(separator,'')&lt;br /&gt;    a_format[2] = format_mask.match('[y,m,d]$').to_s&lt;br /&gt;    &lt;br /&gt;    file = File.new('../housekeeping/webcam_pear/dir.xml')&lt;br /&gt;    ddoc = REXML::Document.new(file)&lt;br /&gt;    file.close&lt;br /&gt;    &lt;br /&gt;    file_delete = File.new('../housekeeping/webcam_pear/files2delete.xml', 'w')&lt;br /&gt;    doc_delete = Document.new()&lt;br /&gt;    doc_delete.add_element('files')&lt;br /&gt;    &lt;br /&gt;    ddoc.root.elements.each('file') do |file_node|&lt;br /&gt;      sfile = file_node.text&lt;br /&gt;      idate = Array.new&lt;br /&gt;      idate[0] = sfile.match(/^\d*/).to_s.to_i&lt;br /&gt;      idate[1] = sfile.match(/\_\d*/).to_s.gsub(separator,'').to_i&lt;br /&gt;      idate[2] = sfile.match(/\_\d*\d$/).to_s.gsub(separator,'').to_i&lt;br /&gt;&lt;br /&gt;      h = Hash.new&lt;br /&gt;      0.upto(2) {|i| h[a_format[i]] = idate[i]}&lt;br /&gt;&lt;br /&gt;      file_date = Date.new(y=h['y'], m=h['m'], d=h['d'])&lt;br /&gt;&lt;br /&gt;      if file_date &lt; cut_off_date&lt;br /&gt;        o_file2delete = Element.new('file')&lt;br /&gt;        o_file2delete.text = file_date.strftime(dformat)&lt;br /&gt;        doc_delete.root.add_element o_file2delete&lt;br /&gt;      end&lt;br /&gt;    end&lt;br /&gt;    file_delete.puts doc_delete&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;file: dir.xml&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;dir&gt;&lt;br /&gt;  &lt;file&gt;11_4_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;11_5_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;11_6_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;11_7_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;11_8_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;11_9_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_10_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_11_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_1_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_12_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_13_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_14_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_15_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_16_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_17_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_18_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_19_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_20_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_21_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_2_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_22_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_23_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_24_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_25_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_26_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_27_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_28_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_3_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_4_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_5_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_6_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_7_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_8_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_9_2007&lt;/file&gt;&lt;br /&gt; &lt;/dir&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;file: files2delete.xml&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;files&gt;&lt;br /&gt;  &lt;file&gt;11_4_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;11_5_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;11_6_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;11_7_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;11_8_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;11_9_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_10_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_11_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_1_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_12_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_13_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_14_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_15_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_2_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_3_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_4_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_5_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_6_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_7_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_8_2007&lt;/file&gt;&lt;br /&gt;  &lt;file&gt;12_9_2007&lt;/file&gt;&lt;br /&gt; &lt;/files&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 30 Dec 2007 17:33:47 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4934</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Using Ruby to delete a file directory </title>
      <link>http://snippets.dzone.com/posts/show/4913</link>
      <description>In this example the file we want to delete is a non-empty directory called sample. &lt;br /&gt;&lt;code&gt;&lt;br /&gt;  require 'fileutils' &lt;br /&gt;&lt;br /&gt;  FileUtils.rm_r 'sample'&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 22 Dec 2007 14:06:52 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4913</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Hash#deep_delete</title>
      <link>http://snippets.dzone.com/posts/show/4725</link>
      <description>&lt;code&gt;&lt;br /&gt;&lt;br /&gt;class Object&lt;br /&gt;   def deep_clone&lt;br /&gt;      Marshal.load(Marshal.dump(self))&lt;br /&gt;   end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;class Hash&lt;br /&gt;&lt;br /&gt;   # From: http://www.sameshirteveryday.com/2007/09/23/ruby-get-full-history-all-parents-of-a-hash-node&lt;br /&gt;   # Author: Alex Gorbatchev&lt;br /&gt;   # for further recursive hash methods see: &lt;br /&gt;   # - http://snippets.dzone.com/posts/show/1908&lt;br /&gt;   # - http://snippets.dzone.com/posts/show/4706&lt;br /&gt;   &lt;br /&gt;   def nested_key(desired_key, &amp;block)&lt;br /&gt;&lt;br /&gt;      return false unless Hash === self&lt;br /&gt;      #return false unless self.is_a?(Hash)&lt;br /&gt;&lt;br /&gt;      self.each_pair do |k,v|  &lt;br /&gt;         if k == desired_key or v.nested_key(desired_key, &amp;block)  &lt;br /&gt;            yield(k,v)  &lt;br /&gt;            return true  &lt;br /&gt;         end  &lt;br /&gt;      end  &lt;br /&gt;&lt;br /&gt;      return false  &lt;br /&gt;   end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   def deep_values(key)   # cf. http://snippets.dzone.com/posts/show/1908 &lt;br /&gt;&lt;br /&gt;      hash = self.deep_clone&lt;br /&gt;      ret = []&lt;br /&gt;&lt;br /&gt;      begin&lt;br /&gt;&lt;br /&gt;         ar = []&lt;br /&gt;         result = hash.nested_key(key) { |k, v| ar &lt;&lt; k }&lt;br /&gt;         break unless result&lt;br /&gt;         ar = ar.reverse&lt;br /&gt;&lt;br /&gt;         hk = ""&lt;br /&gt;         ar.size.times { |i| hk &lt;&lt; "[ar[#{i}]]" }&lt;br /&gt;         #str = "hash" &lt;&lt; hk &lt;&lt; " rescue nil"&lt;br /&gt;         str = "hash" &lt;&lt; hk &lt;br /&gt;&lt;br /&gt;         # get value for hash key hk&lt;br /&gt;         ret &lt;&lt; eval(str)&lt;br /&gt;&lt;br /&gt;         # delete the hash key&lt;br /&gt;         key_to_delete = [ar.pop]&lt;br /&gt;&lt;br /&gt;         hk = ""&lt;br /&gt;         ar.size.times { |i| hk &lt;&lt; "[ar[#{i}]]" }&lt;br /&gt;         str = "hash" &lt;&lt; hk&lt;br /&gt;         str = str &lt;&lt; ".delete(key_to_delete.first)"&lt;br /&gt;         eval(str)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      end while result&lt;br /&gt;&lt;br /&gt;      hash.clear  # optional&lt;br /&gt;      ret&lt;br /&gt;&lt;br /&gt;   end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   def deep_delete(key)&lt;br /&gt;&lt;br /&gt;      hash = self&lt;br /&gt;&lt;br /&gt;      begin&lt;br /&gt;&lt;br /&gt;         ar = []&lt;br /&gt;         result = hash.nested_key(key) { |k, v| ar &lt;&lt; k }&lt;br /&gt;         break unless result&lt;br /&gt;         ar = ar.reverse&lt;br /&gt;&lt;br /&gt;         # delete the hash key&lt;br /&gt;         key_to_delete = [ar.pop]&lt;br /&gt;&lt;br /&gt;         hk = ""&lt;br /&gt;         ar.size.times { |i| hk &lt;&lt; "[ar[#{i}]]" }&lt;br /&gt;         str = "hash" &lt;&lt; hk&lt;br /&gt;         str = str &lt;&lt; ".delete(key_to_delete.first)"&lt;br /&gt;         eval(str)&lt;br /&gt;&lt;br /&gt;      end while result&lt;br /&gt;&lt;br /&gt;   end&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;puts&lt;br /&gt;hash = {  &lt;br /&gt;  :level_1 =&gt; {  &lt;br /&gt;    :level_2 =&gt; {  :search =&gt; 'test1',&lt;br /&gt;      :level_3 =&gt; {  &lt;br /&gt;        :search =&gt; 'test2', :level_4 =&gt; {:search =&gt; 'test3'}&lt;br /&gt;      }  &lt;br /&gt;    }  &lt;br /&gt;  }  &lt;br /&gt;}  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;require 'pp'&lt;br /&gt;&lt;br /&gt;p hash&lt;br /&gt;puts&lt;br /&gt;&lt;br /&gt;pp hash&lt;br /&gt;puts&lt;br /&gt;&lt;br /&gt;hash.nested_key(:search) { |k, v| puts "#{k}  ::  #{v.inspect}" }&lt;br /&gt;&lt;br /&gt;# prints out...&lt;br /&gt;# search  ::  "test1"&lt;br /&gt;# level_2  ::  {:search=&gt;"test1", :level_3=&gt;{:search=&gt;"test2", :level_4=&gt;{:search=&gt;"test3"}}}&lt;br /&gt;# level_1  ::  {:level_2=&gt;{:search=&gt;"test1", :level_3=&gt;{:search=&gt;"test2", :level_4=&gt;{:search=&gt;"test3"}}}}&lt;br /&gt;&lt;br /&gt;puts&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;puts "DEEP VALUES"&lt;br /&gt;p hash.deep_values(:search)   #=&gt; ["test1", "test2", "test3"]&lt;br /&gt;puts&lt;br /&gt;&lt;br /&gt;puts "DEEP VALUES DELETED"&lt;br /&gt;hash.deep_delete(:search)&lt;br /&gt;p hash   #=&gt; {:level_1=&gt;{:level_2=&gt;{:level_3=&gt;{:level_4=&gt;{}}}}}&lt;br /&gt;puts&lt;br /&gt;&lt;br /&gt;puts "DEEP VALUES"&lt;br /&gt;p hash.deep_values(:search)   #=&gt; []&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 01 Nov 2007 15:42:50 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4725</guid>
      <author>ntk ()</author>
    </item>
    <item>
      <title>Deleting an xml node from a REXML::document</title>
      <link>http://snippets.dzone.com/posts/show/4574</link>
      <description>// Reads an XML file, then deletes the root element's 1st child element.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require 'rexml/document'&lt;br /&gt;include REXML&lt;br /&gt;&lt;br /&gt;file = File.new('journal250907.xml')&lt;br /&gt;doc = Document.new(file)&lt;br /&gt;&lt;br /&gt;puts doc&lt;br /&gt;&lt;br /&gt;o_element = Element.new('abc')&lt;br /&gt;o_element.text = "123"&lt;br /&gt;&lt;br /&gt;o_node = doc.elements['journal/entry']&lt;br /&gt;&lt;br /&gt;o_node.parent.delete(o_node)&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 26 Sep 2007 18:13:10 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4574</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>DELETE - SQL</title>
      <link>http://snippets.dzone.com/posts/show/4498</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;DELETE ... &lt;br /&gt;    [ FROM ... ] &lt;br /&gt;    [ ... JOIN ... ] &lt;br /&gt;    [ WHERE ... ] &lt;br /&gt;&lt;br /&gt;// FULL Syntax follows:&lt;br /&gt;DELETE [ FROM ] &lt;br /&gt;    {&lt;br /&gt;       [ database. ] [ owner. ] table_name &lt;br /&gt;         [&lt;br /&gt;           WITH (  INDEX ( Index_1,   [ index_2,  ...,  n ] ) &lt;br /&gt;                      | FASTFIRSTROW &lt;br /&gt;                      | HOLDLOCK &lt;br /&gt;                      | PAGLOCK &lt;br /&gt;                      | READCOMMITTED &lt;br /&gt;                      | REPEATABLEREAD &lt;br /&gt;                      | ROWLOCK &lt;br /&gt;                      | SERIALIZABLE &lt;br /&gt;                      | TABLOCK &lt;br /&gt;                      | TABLOCKX &lt;br /&gt;                      [   ...   n  |  ...,  n ] &lt;br /&gt;                     )&lt;br /&gt;       ]&lt;br /&gt;     |&lt;br /&gt;       OPENQUERY( server, 'query' ) &lt;br /&gt;     |&lt;br /&gt;       OPENROWSET( 'provider_name', &lt;br /&gt;                                 { 'datasource';'user_id';'password',  |  'provider_string', }&lt;br /&gt;                                 { [ catalog. ] [ schema. ] object  |  'query' }&lt;br /&gt;                               ) &lt;br /&gt;     |&lt;br /&gt;       view_name &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    [&lt;br /&gt;      FROM &lt;br /&gt;      {&lt;br /&gt;          derived_table &lt;br /&gt;            [ [ AS ] table_alias ]&lt;br /&gt;            [ ( column_alias_1,   [ column_alias_2,   ...,  n ]  )  ]&lt;br /&gt;        |&lt;br /&gt;          CONTAINSTABLE ( table, column  |  *, 'search_conditions' ) &lt;br /&gt;            [ [ AS ] table_alias ]&lt;br /&gt;        |&lt;br /&gt;          FREETEXTTABLE ( table, column  |  *, 'free_text_string' ) &lt;br /&gt;            [ [ AS ] table_alias ]&lt;br /&gt;        |&lt;br /&gt;          table_name [ [ AS ] table_alias ]&lt;br /&gt;            [&lt;br /&gt;               WITH (  INDEX ( Index_1,   [ index_2,   ...,  n ]  ) &lt;br /&gt;                          | FASTFIRSTROW &lt;br /&gt;                          | HOLDLOCK &lt;br /&gt;                          | NOLOCK &lt;br /&gt;                          | PAGLOCK &lt;br /&gt;                          | READCOMMITTED &lt;br /&gt;                          | READPAST &lt;br /&gt;                          | READUNCOMMITTED &lt;br /&gt;                          | REPEATABLEREAD &lt;br /&gt;                          | ROWLOCK &lt;br /&gt;                          | SERIALIZABLE &lt;br /&gt;                          | TABLOCK &lt;br /&gt;                          | TABLOCKX &lt;br /&gt;                          | UPDLOCK &lt;br /&gt;                          [ ...   n  |  ...,  n ] &lt;br /&gt;                         )&lt;br /&gt;            ]&lt;br /&gt;        |&lt;br /&gt;          view_name [ [ AS ] table_alias ]&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      [&lt;br /&gt;          INNER JOIN  |  LEFT [ OUTER ] JOIN  |  RIGHT [ OUTER ] JOIN &lt;br /&gt;            {&lt;br /&gt;               derived_table [ ON search_conditions ]&lt;br /&gt;             |&lt;br /&gt;               OPENQUERY( server, 'query' ) [ ON search_conditions ]&lt;br /&gt;             |&lt;br /&gt;               OPENROWSET&lt;br /&gt;                               ( 'provider_name', &lt;br /&gt;                                 { 'datasource';'user_id';'password',  |  'provider_string', }&lt;br /&gt;                                 { [ catalog. ] [ schema. ] object  |  'query' }&lt;br /&gt;                               ) [ ON search_conditions ]&lt;br /&gt;             | &lt;br /&gt;               table_name [ ON search_conditions ]&lt;br /&gt;             | &lt;br /&gt;               view_name [ ON search_conditions ]&lt;br /&gt;            }&lt;br /&gt;            [   ...,  n ]&lt;br /&gt;          |&lt;br /&gt;          CROSS JOIN  |  FULL [ OUTER ] JOIN &lt;br /&gt;            {&lt;br /&gt;               derived_table &lt;br /&gt;             | &lt;br /&gt;               OPENQUERY( server, 'query' ) &lt;br /&gt;             |&lt;br /&gt;               OPENROWSET&lt;br /&gt;                               ( 'provider_name', &lt;br /&gt;                                 { 'datasource';'user_id';'password',  |  'provider_string', }&lt;br /&gt;                                 { [ catalog. ] [ schema. ] object  |  'query' }&lt;br /&gt;                               ) &lt;br /&gt;             | &lt;br /&gt;               table_name &lt;br /&gt;             | &lt;br /&gt;               view_name &lt;br /&gt;            }&lt;br /&gt;            [   ...,  n ]&lt;br /&gt;       ]&lt;br /&gt;   ] &lt;br /&gt;&lt;br /&gt;   [&lt;br /&gt;      {&lt;br /&gt;         WHERE search_conditions &lt;br /&gt;       |&lt;br /&gt;         WHERE CURRENT OF [ GLOBAL ] cursor_name &lt;br /&gt;       |&lt;br /&gt;         WHERE CURRENT OF cursor_variable_name &lt;br /&gt;      }&lt;br /&gt;         [&lt;br /&gt;           OPTION (  FAST number_rows &lt;br /&gt;                          | FORCE ORDER &lt;br /&gt;                          | HASH GROUP &lt;br /&gt;                          | ORDER GROUP &lt;br /&gt;                          | HASH JOIN &lt;br /&gt;                          | LOOP JOIN &lt;br /&gt;                          | MERGE JOIN &lt;br /&gt;                          | KEEP PLAN &lt;br /&gt;                          | MAXDOP &lt;br /&gt;                          | ROBUST PLAN &lt;br /&gt;                          | CONCAT UNION &lt;br /&gt;                          | HASH UNION &lt;br /&gt;                          | MERGE UNION &lt;br /&gt;                          [   ...,  n ]&lt;br /&gt;                        )&lt;br /&gt;         ]&lt;br /&gt;   ]&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;//Full explanation follows:&lt;br /&gt;&lt;br /&gt;KEYWORDS	Keywords are denoted with upper case letters. Obey the spelling.&lt;br /&gt;&lt;br /&gt;variables	All user-supplied variables are denoted with lower case letters.&lt;br /&gt;&lt;br /&gt;...,   n	Signifies that there can be more than one value in a comma delimited list. Note that the dots and n are not part of the code and must not appear in the SQL query.&lt;br /&gt;&lt;br /&gt;...   n	Signifies that there can be more than one value in a blank space delimited list. Note that the dots and n are not part of the code and must not appear in the SQL query.&lt;br /&gt;&lt;br /&gt;{  } 	Signifies that all, or some portion, of the code elements between the braces are required elements and must appear in the SQL query. Note that these braces are not part of the code and must not appear in the SQL query.&lt;br /&gt;&lt;br /&gt;[  ] 	Signifies that the code elements between the square brackets can optionally appear in the SQL query, but are not required. Note that these brackets are not part of the code and must not appear in the SQL query.&lt;br /&gt;&lt;br /&gt;|	The or symbol signifies that you may use only one of the code elements or values from the possible choices. Note that the or symbol is not part of the code and must not appear in the SQL query.</description>
      <pubDate>Thu, 06 Sep 2007 10:30:33 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4498</guid>
      <author>dubby (Dave)</author>
    </item>
    <item>
      <title>SQL SERVER: Delete Duplicate Rows with Primary Id</title>
      <link>http://snippets.dzone.com/posts/show/4482</link>
      <description>Deletes duplicates (leaving one instance) where the table has a primary key. Good for tables with Id, DupColumn, DupColumn...&lt;br /&gt;&lt;br /&gt;(This is MS-SQL specific)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;DELETE&lt;br /&gt;FROM 	TableName&lt;br /&gt;WHERE 	Id NOT IN&lt;br /&gt;	(SELECT 	MAX(Id)&lt;br /&gt;        FROM   		TableName&lt;br /&gt;        GROUP BY 	DuplicateColumName1, DuplicateColumName2)&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 31 Aug 2007 19:12:09 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4482</guid>
      <author>cornerblue (CornerBLUE, Inc.)</author>
    </item>
    <item>
      <title>Delete empty directories (UNIX)</title>
      <link>http://snippets.dzone.com/posts/show/3012</link>
      <description>// Shell command to delete empty directories. May have to run several times to get everything.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;find . -type d -empty | xargs rmdir -&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 18 Nov 2006 03:21:34 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3012</guid>
      <author>jasonbentley (Jason Bentley)</author>
    </item>
    <item>
      <title>Confirm Delete with javascript</title>
      <link>http://snippets.dzone.com/posts/show/2608</link>
      <description>// confirm() returns true or false&lt;br /&gt;// submit() is only called on true and submits the form&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;h1&gt;Howto Confirm Delete&lt;/h1&gt;&lt;br /&gt;&lt;form action="delete.html" method="post"&gt;&lt;br /&gt;&lt;input type="button" onclick="if (confirm('sure?')) submit();" value="delete"&gt;&lt;br /&gt;&lt;/form&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 16 Sep 2006 21:07:45 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2608</guid>
      <author>ovhaag (Oliver Haag)</author>
    </item>
  </channel>
</rss>
