<?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>Question Re: Directory Access Server Delete in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/directory-access-server-delete/qaa-p/13836494#M4867337</link>
    <description>&lt;P&gt;Directory Access Servers are pretty picky about the type of cursors allowed on them.  You can get around the issue by using a cursor in a stored procedure that only calls fetch next :&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="n"&gt;create&lt;/SPAN&gt; &lt;SPAN class="n"&gt;procedure&lt;/SPAN&gt; &lt;SPAN class="n"&gt;DelFiles&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt; &lt;SPAN class="n"&gt;in&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@expire&lt;/SPAN&gt; &lt;SPAN class="n"&gt;integer&lt;/SPAN&gt; &lt;SPAN class="p"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;begin&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;declare&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@fn&lt;/SPAN&gt; &lt;SPAN class="n"&gt;varchar&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;128&lt;/SPAN&gt;&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;declare&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@cur&lt;/SPAN&gt; &lt;SPAN class="n"&gt;cursor&lt;/SPAN&gt; &lt;SPAN class="k"&gt;for&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;select&lt;/SPAN&gt; &lt;SPAN class="n"&gt;file_name&lt;/SPAN&gt; &lt;SPAN class="n"&gt;from&lt;/SPAN&gt; &lt;SPAN class="n"&gt;DBA&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;MyDir&lt;/SPAN&gt; 
                        &lt;SPAN class="n"&gt;where&lt;/SPAN&gt; &lt;SPAN class="n"&gt;create_date_time&lt;/SPAN&gt; &lt;SPAN class="o"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="n"&gt;dateadd&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt; &lt;SPAN class="n"&gt;minute&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;1&lt;/SPAN&gt; &lt;SPAN class="o"&gt;*&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@expire&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;now&lt;/SPAN&gt;&lt;SPAN class="p"&gt;()&lt;/SPAN&gt; &lt;SPAN class="p"&gt;);&lt;/SPAN&gt;
&lt;SPAN class="nb"&gt;open&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@cur&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;fetch&lt;/SPAN&gt; &lt;SPAN class="k"&gt;next&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@cur&lt;/SPAN&gt; &lt;SPAN class="n"&gt;into&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@fn&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="k"&gt;while&lt;/SPAN&gt; &lt;SPAN class="n"&gt;sqlcode&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="mi"&gt;0&lt;/SPAN&gt; &lt;SPAN class="n"&gt;loop&lt;/SPAN&gt;
  &lt;SPAN class="nb"&gt;delete&lt;/SPAN&gt; &lt;SPAN class="n"&gt;from&lt;/SPAN&gt; &lt;SPAN class="n"&gt;DBA&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;MyDir&lt;/SPAN&gt; &lt;SPAN class="n"&gt;where&lt;/SPAN&gt; &lt;SPAN class="n"&gt;file_name&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@fn&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="n"&gt;fetch&lt;/SPAN&gt; &lt;SPAN class="k"&gt;next&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@cur&lt;/SPAN&gt; &lt;SPAN class="n"&gt;into&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@fn&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;end&lt;/SPAN&gt; &lt;SPAN class="n"&gt;loop&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="nb"&gt;close&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@cur&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;end&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;In this example, I've allowed you to pass in a parameter specifying how many minutes old a file should be to be deleted.&lt;/P&gt;</description>
    <pubDate>Tue, 11 Sep 2012 15:05:44 GMT</pubDate>
    <dc:creator>regdomaratzki</dc:creator>
    <dc:date>2012-09-11T15:05:44Z</dc:date>
    <item>
      <title>Directory Access Server Delete</title>
      <link>https://community.sap.com/t5/technology-q-a/directory-access-server-delete/qaq-p/13836493</link>
      <description>&lt;P&gt;I have two folders that the database writes files to using the directory access features.  The destination folder is a landing point for documents requested by a webpage.  Once they are viewed by the webpage they are no longer useful and can be cleaned up at some point.&lt;BR /&gt;
&lt;/P&gt;
&lt;P&gt;My initial plan was to have an event that ran each night to delete files from this folder that had a create date older than 30 minutes prior.&lt;/P&gt;
&lt;P&gt;This query displays the records I would want to delete correctly:&lt;/P&gt;
&lt;PRE&gt;SELECT *

FROM ClientDataLand

WHERE create_date_time

&amp;lt;= DATEADD(MINUTE,-30,NOW())
&lt;/PRE&gt;

&lt;P&gt;The problem is that generates Error code -728 -- Update operation attempted on non-updatable remote query.&lt;/P&gt;
&lt;P&gt;So how could one delete from a directory access server based on conditions, such as the create time?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 13:21:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/directory-access-server-delete/qaq-p/13836493</guid>
      <dc:creator>former_SQLA_member1694868</dc:creator>
      <dc:date>2012-09-11T13:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: Directory Access Server Delete</title>
      <link>https://community.sap.com/t5/technology-q-a/directory-access-server-delete/qaa-p/13836494#M4867337</link>
      <description>&lt;P&gt;Directory Access Servers are pretty picky about the type of cursors allowed on them.  You can get around the issue by using a cursor in a stored procedure that only calls fetch next :&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="n"&gt;create&lt;/SPAN&gt; &lt;SPAN class="n"&gt;procedure&lt;/SPAN&gt; &lt;SPAN class="n"&gt;DelFiles&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt; &lt;SPAN class="n"&gt;in&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@expire&lt;/SPAN&gt; &lt;SPAN class="n"&gt;integer&lt;/SPAN&gt; &lt;SPAN class="p"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;begin&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;declare&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@fn&lt;/SPAN&gt; &lt;SPAN class="n"&gt;varchar&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;128&lt;/SPAN&gt;&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;declare&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@cur&lt;/SPAN&gt; &lt;SPAN class="n"&gt;cursor&lt;/SPAN&gt; &lt;SPAN class="k"&gt;for&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;select&lt;/SPAN&gt; &lt;SPAN class="n"&gt;file_name&lt;/SPAN&gt; &lt;SPAN class="n"&gt;from&lt;/SPAN&gt; &lt;SPAN class="n"&gt;DBA&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;MyDir&lt;/SPAN&gt; 
                        &lt;SPAN class="n"&gt;where&lt;/SPAN&gt; &lt;SPAN class="n"&gt;create_date_time&lt;/SPAN&gt; &lt;SPAN class="o"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="n"&gt;dateadd&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt; &lt;SPAN class="n"&gt;minute&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;1&lt;/SPAN&gt; &lt;SPAN class="o"&gt;*&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@expire&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;now&lt;/SPAN&gt;&lt;SPAN class="p"&gt;()&lt;/SPAN&gt; &lt;SPAN class="p"&gt;);&lt;/SPAN&gt;
&lt;SPAN class="nb"&gt;open&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@cur&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;fetch&lt;/SPAN&gt; &lt;SPAN class="k"&gt;next&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@cur&lt;/SPAN&gt; &lt;SPAN class="n"&gt;into&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@fn&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="k"&gt;while&lt;/SPAN&gt; &lt;SPAN class="n"&gt;sqlcode&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="mi"&gt;0&lt;/SPAN&gt; &lt;SPAN class="n"&gt;loop&lt;/SPAN&gt;
  &lt;SPAN class="nb"&gt;delete&lt;/SPAN&gt; &lt;SPAN class="n"&gt;from&lt;/SPAN&gt; &lt;SPAN class="n"&gt;DBA&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;MyDir&lt;/SPAN&gt; &lt;SPAN class="n"&gt;where&lt;/SPAN&gt; &lt;SPAN class="n"&gt;file_name&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@fn&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="n"&gt;fetch&lt;/SPAN&gt; &lt;SPAN class="k"&gt;next&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@cur&lt;/SPAN&gt; &lt;SPAN class="n"&gt;into&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@fn&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;end&lt;/SPAN&gt; &lt;SPAN class="n"&gt;loop&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="nb"&gt;close&lt;/SPAN&gt; &lt;SPAN class="nv"&gt;@cur&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;end&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;In this example, I've allowed you to pass in a parameter specifying how many minutes old a file should be to be deleted.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 15:05:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/directory-access-server-delete/qaa-p/13836494#M4867337</guid>
      <dc:creator>regdomaratzki</dc:creator>
      <dc:date>2012-09-11T15:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: Directory Access Server Delete</title>
      <link>https://community.sap.com/t5/technology-q-a/directory-access-server-delete/qaa-p/13836496#M4867339</link>
      <description>&lt;P&gt;Works like a charm.  Thanks Reg.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 21:33:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/directory-access-server-delete/qaa-p/13836496#M4867339</guid>
      <dc:creator>former_SQLA_member1694868</dc:creator>
      <dc:date>2012-09-11T21:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: Directory Access Server Delete</title>
      <link>https://community.sap.com/t5/technology-q-a/directory-access-server-delete/qaa-p/13836495#M4867338</link>
      <description>&lt;P&gt;Just to add: Nick Elson has answered a similar question in the general NG (thread "proxy table usable columns for delete" from 2012-08-09) - explaining the cause:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Q:&lt;/STRONG&gt; one issue / question i am having . . .is it possible to issue deletes against the files querying by
create_date_time, the only column that appears to be usable in the delete where clause is the file_name column.  this is sql anywhere 12.01.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;A:&lt;/STRONG&gt; I am able to reproduce this and I believe this is a 'by design' limitation.
So the bare SQL Delete Statement will not work.  It seems to come down
to the implementation not being set driven. The server is effectively doing this
in Full Passthrough mode and the OS function to do a delete does not take
such search criteria.  That only accepts the filename.&lt;/P&gt;
&lt;P&gt;One could write procedural logic to select for that criteria and fetch the file
name via a cursor and use that to issue the correct delete operation.
(see: execute immediate for that last part
 &lt;A href="http://dcx.sybase.com/index.html#1201/en/dbreference/execute-immediate-statement.html"&gt;http://dcx.sybase.com/index.html#1201/en/dbreference/execute-immediate-statement.html&lt;/A&gt; ) &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Obviously, the suggested solution is exactly what Reg has implemented:)&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2012 06:02:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/directory-access-server-delete/qaa-p/13836495#M4867338</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2012-09-12T06:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Directory Access Server Delete</title>
      <link>https://community.sap.com/t5/technology-q-a/directory-access-server-delete/qaa-p/13836497#M4867340</link>
      <description>&lt;P&gt;I don't understand why do I need to use execute immediate for the delete ? Is this necessary for the cursor ?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2012 06:15:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/directory-access-server-delete/qaa-p/13836497#M4867340</guid>
      <dc:creator>thomas_duemesnil</dc:creator>
      <dc:date>2012-09-12T06:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: Directory Access Server Delete</title>
      <link>https://community.sap.com/t5/technology-q-a/directory-access-server-delete/qaa-p/13836498#M4867341</link>
      <description>&lt;P&gt;I second that question.)&lt;BR /&gt;
Possibly even a positioned delete would do? - As to Nick's explanation, I would think it's just that the DELETE on a directory access table needs a single filename as parameter, not any other condition, so the cursor shouldn't be a problem here... but I don't know myself.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2012 07:07:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/directory-access-server-delete/qaa-p/13836498#M4867341</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2012-09-12T07:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: Directory Access Server Delete</title>
      <link>https://community.sap.com/t5/technology-q-a/directory-access-server-delete/qaa-p/13836499#M4867342</link>
      <description>&lt;P&gt;I only had execute immediate here because I'd copied the SQL from another sample.  The following SQL works as well, so I've edited my answer, and I don't see why a positioned delete wouldn't work either, although I haven't tested it myself.&lt;/P&gt;
&lt;PRE class="codehilite"&gt;&lt;CODE&gt;delete from DBA.MyDir where file_name = @fn;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Sep 2012 09:44:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/directory-access-server-delete/qaa-p/13836499#M4867342</guid>
      <dc:creator>regdomaratzki</dc:creator>
      <dc:date>2012-09-12T09:44:00Z</dc:date>
    </item>
  </channel>
</rss>

