<?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: Uploading multiple CSV files using sybase in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/uploading-multiple-csv-files-using-sybase/qaa-p/10828687#M3962484</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;I'm not sure such 'dynamic' syntax is supported, but there are workarounds:&lt;/P&gt;&lt;P&gt;1) If the file names are fixed, but only now and then some of them are missing, then you may list all of them and use the &lt;SPAN class="cmdname" style="font-weight: bold;"&gt;ON FILE ERROR&lt;/SPAN&gt; &lt;STRONG&gt;CONTINUE&lt;/STRONG&gt; option; this way, if a files is missing IQ will continue to the next one without giving an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the file names are also dynamic, there are also ways to do this:&lt;/P&gt;&lt;P&gt;2) create the LOAD statement outside IQ and execute it using dbisql&lt;/P&gt;&lt;P&gt;- or&lt;/P&gt;&lt;P&gt;3) create the LOAD statement dynamically inside and use execute immediate. To get the list of files you may use a REMOTE SERVER of class &lt;STRONG&gt;directory&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(from online documentation)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Create a remote server by using the CREATE SERVER statement.&lt;/P&gt;&lt;P&gt;CREATE SERVER my_dir_server CLASS 'DIRECTORY' USING 'ROOT=c:\Program Files;READONLY=yes;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Create an external login by using the CREATE EXTERNLOGIN statement&lt;/P&gt;&lt;P&gt;CREATE EXTERNLOGIN DBA TO my_dir_server;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Create a proxy table for the directory by using the CREATE EXISTING TABLE statement.&lt;/P&gt;&lt;P&gt;CREATE EXISTING TABLE my_program_files AT 'my_dir_server;;;.';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this example, my_program_files is the name of the proxy table, and my_dir_server is the name of the directory access server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. Display rows in the proxy table.&lt;/P&gt;&lt;P&gt;SELECT * FROM my_program_files ORDER BY file_name;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use a cursor on a select on this remote table and build the FROM part of the LOAD statement. Concatenate everything and use execute immediate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Jan 2015 11:25:43 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2015-01-22T11:25:43Z</dc:date>
    <item>
      <title>Uploading multiple CSV files using sybase</title>
      <link>https://community.sap.com/t5/technology-q-a/uploading-multiple-csv-files-using-sybase/qaq-p/10828686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to load data from multiple CSV files into a table, I used the load table statement but my problem is that it works if the path and filename are hard-coded but I nee to use a variable because the number of files might vary from week to week, so I need to check how many files then upload all without getting an error.&amp;nbsp; This is what I used which does not work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create or replace variable @filecap varchar(100);&lt;/P&gt;&lt;P&gt;Set @filecap = '*.csv';&lt;BR /&gt;commit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;load table "pmoss".umt_tariff_rule_upd (key_tariffrule, scheme_code, scheme_name, tariff_code, tariff_desc, rule, t_rule, rule_desc, medtype1, medtype1_desc,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; medtype1_desc_new, medtype2, medtype2_desc, medtype2_desc_new, source, date_load, date_closed, is_current '\x0D')&lt;BR /&gt;from 'C:/publish/adhoc/Medicine Classification Test/'&amp;amp;@filecap,&amp;nbsp;&amp;nbsp; &lt;BR /&gt;'C:/publish/adhoc/Medicine Classification Test/'&amp;amp;@filecap, &lt;BR /&gt;'C:/publish/adhoc/Medicine Classification Test/'&amp;amp;@filecap escapes off;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Jan 2015 10:43:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/uploading-multiple-csv-files-using-sybase/qaq-p/10828686</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-01-22T10:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading multiple CSV files using sybase</title>
      <link>https://community.sap.com/t5/technology-q-a/uploading-multiple-csv-files-using-sybase/qaa-p/10828687#M3962484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;I'm not sure such 'dynamic' syntax is supported, but there are workarounds:&lt;/P&gt;&lt;P&gt;1) If the file names are fixed, but only now and then some of them are missing, then you may list all of them and use the &lt;SPAN class="cmdname" style="font-weight: bold;"&gt;ON FILE ERROR&lt;/SPAN&gt; &lt;STRONG&gt;CONTINUE&lt;/STRONG&gt; option; this way, if a files is missing IQ will continue to the next one without giving an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the file names are also dynamic, there are also ways to do this:&lt;/P&gt;&lt;P&gt;2) create the LOAD statement outside IQ and execute it using dbisql&lt;/P&gt;&lt;P&gt;- or&lt;/P&gt;&lt;P&gt;3) create the LOAD statement dynamically inside and use execute immediate. To get the list of files you may use a REMOTE SERVER of class &lt;STRONG&gt;directory&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(from online documentation)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Create a remote server by using the CREATE SERVER statement.&lt;/P&gt;&lt;P&gt;CREATE SERVER my_dir_server CLASS 'DIRECTORY' USING 'ROOT=c:\Program Files;READONLY=yes;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Create an external login by using the CREATE EXTERNLOGIN statement&lt;/P&gt;&lt;P&gt;CREATE EXTERNLOGIN DBA TO my_dir_server;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Create a proxy table for the directory by using the CREATE EXISTING TABLE statement.&lt;/P&gt;&lt;P&gt;CREATE EXISTING TABLE my_program_files AT 'my_dir_server;;;.';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this example, my_program_files is the name of the proxy table, and my_dir_server is the name of the directory access server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. Display rows in the proxy table.&lt;/P&gt;&lt;P&gt;SELECT * FROM my_program_files ORDER BY file_name;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use a cursor on a select on this remote table and build the FROM part of the LOAD statement. Concatenate everything and use execute immediate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Jan 2015 11:25:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/uploading-multiple-csv-files-using-sybase/qaa-p/10828687#M3962484</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-01-22T11:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading multiple CSV files using sybase</title>
      <link>https://community.sap.com/t5/technology-q-a/uploading-multiple-csv-files-using-sybase/qaa-p/10828688#M3962485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your response.&amp;nbsp; I used the ON FILE ERROR CONTINUE option and it worked fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought that there was a way of maybe counting the files in the folder as the TotalFiles variable then have a loop loading data into the table acording to the total number of files.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Phelisa&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Jan 2015 12:22:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/uploading-multiple-csv-files-using-sybase/qaa-p/10828688#M3962485</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-01-22T12:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading multiple CSV files using sybase</title>
      <link>https://community.sap.com/t5/technology-q-a/uploading-multiple-csv-files-using-sybase/qaa-p/10828689#M3962486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The LOAD TABLE command takes variables for the file name.&amp;nbsp; The alternate syntax was release in the IQ 15 days, if memory serves.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check out the syntax.&amp;nbsp; Notice the "filename-variable" in the FROM/USING clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H3 class="refhead" style="font-size: 11px; color: #d00000; margin-top: 8pt; margin-bottom: 6pt;"&gt;Syntax&lt;/H3&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt; [ &lt;STRONG&gt;INTO&lt;/STRONG&gt; ] &lt;STRONG&gt;TABLE&lt;/STRONG&gt; [ &lt;EM&gt;owner&lt;/EM&gt;.]&lt;EM&gt;table-name&lt;/EM&gt; ... ( &lt;EM&gt;load&lt;/EM&gt;-&lt;EM&gt;specification&lt;/EM&gt; [, …] ) ...&amp;nbsp; &lt;/P&gt;
&lt;P&gt;{ &lt;STRONG&gt;FROM&lt;/STRONG&gt; | &lt;STRONG&gt;USING&lt;/STRONG&gt; [ &lt;STRONG&gt;CLIENT&lt;/STRONG&gt; ] &lt;STRONG&gt;FILE&lt;/STRONG&gt; }&amp;nbsp; { '&lt;EM&gt;filename&lt;/EM&gt;-&lt;EM&gt;string&lt;/EM&gt;' | &lt;EM&gt;filename&lt;/EM&gt;-&lt;EM&gt;variable&lt;/EM&gt; } [, …] ... [ &lt;STRONG&gt;CHECK CONSTRAINTS&lt;/STRONG&gt; { &lt;STRONG&gt;ON&lt;/STRONG&gt; | &lt;STRONG&gt;OFF&lt;/STRONG&gt; } ] &lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Jan 2015 14:41:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/uploading-multiple-csv-files-using-sybase/qaa-p/10828689#M3962486</guid>
      <dc:creator>markmumy</dc:creator>
      <dc:date>2015-01-22T14:41:07Z</dc:date>
    </item>
  </channel>
</rss>

