<?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: Input vs Load Table - Fixed Width File in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaa-p/13826268#M4857111</link>
    <description>&lt;P&gt;Rather than &lt;CODE&gt;LOAD TABLE&lt;/CODE&gt;, you could use an &lt;CODE&gt;INSERT ... FROM SELECT&lt;/CODE&gt; that uses &lt;CODE&gt;OPENSTRING&lt;/CODE&gt; over the file. This is somewhat dependent on the size of the file - it won't be efficient for very large files. However, Once you have the file's contents available to a query, you can then use &lt;CODE&gt;SUBSTRING()&lt;/CODE&gt; to chunk off the appropriate pieces and use those sub-expressions for the &lt;CODE&gt;INSERT&lt;/CODE&gt;.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Apr 2012 13:37:13 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2012-04-27T13:37:13Z</dc:date>
    <item>
      <title>Input vs Load Table - Fixed Width File</title>
      <link>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaq-p/13826267</link>
      <description>&lt;P&gt;I have some fixed-width files that I need to extract data from.  Each record is a new line, but the columns are fixed-width.&lt;BR /&gt;
&lt;/P&gt;
&lt;P&gt;I have a statement that works correctly when I run it in ISQL using the &lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="n"&gt;input&lt;/SPAN&gt; &lt;SPAN class="n"&gt;into&lt;/SPAN&gt; &lt;SPAN class="n"&gt;mytable&lt;/SPAN&gt; &lt;SPAN class="n"&gt;from&lt;/SPAN&gt; &lt;SPAN class="s"&gt;'c:\\myfile.txt'&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;format&lt;/SPAN&gt; &lt;SPAN class="n"&gt;fixed&lt;/SPAN&gt; &lt;SPAN class="n"&gt;column&lt;/SPAN&gt; &lt;SPAN class="n"&gt;widths&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;5&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;1&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;3&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;7&lt;/SPAN&gt;&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;I would like to capture the task in a procedure so I can run it multiple times against various files without running ISQL.&lt;BR /&gt;
&lt;/P&gt;
&lt;P&gt;The input statement is only available in ISQL, so what are my options for loading the fixed-width type of files from within a procedure?  I am guessing LOAD TABLE but how specifically to get LOAD TABLE to parse the fixed-widths and any other advice is appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2012 13:04:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaq-p/13826267</guid>
      <dc:creator>former_SQLA_member1694868</dc:creator>
      <dc:date>2012-04-27T13:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: Input vs Load Table - Fixed Width File</title>
      <link>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaa-p/13826268#M4857111</link>
      <description>&lt;P&gt;Rather than &lt;CODE&gt;LOAD TABLE&lt;/CODE&gt;, you could use an &lt;CODE&gt;INSERT ... FROM SELECT&lt;/CODE&gt; that uses &lt;CODE&gt;OPENSTRING&lt;/CODE&gt; over the file. This is somewhat dependent on the size of the file - it won't be efficient for very large files. However, Once you have the file's contents available to a query, you can then use &lt;CODE&gt;SUBSTRING()&lt;/CODE&gt; to chunk off the appropriate pieces and use those sub-expressions for the &lt;CODE&gt;INSERT&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2012 13:37:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaa-p/13826268#M4857111</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-04-27T13:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Input vs Load Table - Fixed Width File</title>
      <link>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaa-p/13826270#M4857113</link>
      <description>&lt;P&gt;The files are about 1.1GB per, but I'm willing to take the hit on the time processing if I don't have to spend time converting them to csv or accessing ISQL each time.  I'll give this a shot.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2012 14:34:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaa-p/13826270#M4857113</guid>
      <dc:creator>former_SQLA_member1694868</dc:creator>
      <dc:date>2012-04-27T14:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Input vs Load Table - Fixed Width File</title>
      <link>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaa-p/13826271#M4857114</link>
      <description>&lt;P&gt;The big hit will be the transaction log. By default LOAD TABLE merely writes the LOAD TABLE statement to the log, not the contents of the file.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2012 15:27:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaa-p/13826271#M4857114</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-04-27T15:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Input vs Load Table - Fixed Width File</title>
      <link>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaa-p/13826272#M4857115</link>
      <description>&lt;P&gt;So what about using LOAD TABLE to load the unseparated contents (line by line) into a temporary table (say, with two columns: line number and line contents) and then use SUBSTRING() to separate the values and insert them into the real table?&lt;/P&gt;</description>
      <pubDate>Sun, 29 Apr 2012 06:56:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaa-p/13826272#M4857115</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2012-04-29T06:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Input vs Load Table - Fixed Width File</title>
      <link>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaa-p/13826273#M4857116</link>
      <description>&lt;P&gt;You could certainly do that, Volker, to work around the issues of the fixed-format file. It doesn't avoid the transaction log overhead, however, of the subsequent INSERT statement.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Apr 2012 19:30:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaa-p/13826273#M4857116</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-04-29T19:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Input vs Load Table - Fixed Width File</title>
      <link>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaa-p/13826274#M4857117</link>
      <description>&lt;P&gt;Yes, I'm aware of that. My suggestion comes simply from the facts that&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;the OPENSTRING approach would have the same impact on the log,&lt;/LI&gt;
&lt;LI&gt;and an approach to INSERT from a temporary table filled with LOAD TABLE might be more common usage.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I do not claim that it is a better approach...&lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2012 03:33:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaa-p/13826274#M4857117</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2012-04-30T03:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: Input vs Load Table - Fixed Width File</title>
      <link>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaa-p/13826269#M4857112</link>
      <description>&lt;P&gt;Here is some code in case anyone needs it:&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="n"&gt;insert&lt;/SPAN&gt; &lt;SPAN class="n"&gt;into&lt;/SPAN&gt; &lt;SPAN class="n"&gt;usr&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;SourceTable&lt;/SPAN&gt; &lt;SPAN class="n"&gt;with&lt;/SPAN&gt; &lt;SPAN class="n"&gt;auto&lt;/SPAN&gt; &lt;SPAN class="n"&gt;name&lt;/SPAN&gt;

&lt;SPAN class="n"&gt;WITH&lt;/SPAN&gt; &lt;SPAN class="n"&gt;IMPORTED&lt;/SPAN&gt; &lt;SPAN class="n"&gt;AS&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt;
    &lt;SPAN class="nb"&gt;select&lt;/SPAN&gt; &lt;SPAN class="n"&gt;MYROW&lt;/SPAN&gt; &lt;SPAN class="n"&gt;from&lt;/SPAN&gt; &lt;SPAN class="n"&gt;openstring&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt; 
        &lt;SPAN class="n"&gt;FILE&lt;/SPAN&gt; &lt;SPAN class="s"&gt;'C:\\\\myfile.txt'&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;
        &lt;SPAN class="n"&gt;WITH&lt;/SPAN&gt;
        &lt;SPAN class="p"&gt;(&lt;/SPAN&gt;
        &lt;SPAN class="n"&gt;MYROW&lt;/SPAN&gt; &lt;SPAN class="n"&gt;long&lt;/SPAN&gt; &lt;SPAN class="n"&gt;varchar&lt;/SPAN&gt;
        &lt;SPAN class="p"&gt;)&lt;/SPAN&gt;
        &lt;SPAN class="n"&gt;OPTION&lt;/SPAN&gt; &lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;DELIMITED&lt;/SPAN&gt; &lt;SPAN class="n"&gt;BY&lt;/SPAN&gt; &lt;SPAN class="s"&gt;'STRINGNEVERTOBEFOUND'&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;
        &lt;SPAN class="n"&gt;as&lt;/SPAN&gt; &lt;SPAN class="n"&gt;ImportedSub&lt;/SPAN&gt;
&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;SELECT&lt;/SPAN&gt; 
  &lt;SPAN class="n"&gt;SUBSTRING&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;IMPORTED&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;MYROW&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;0&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;13&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="n"&gt;AS&lt;/SPAN&gt; &lt;SPAN class="n"&gt;Col1&lt;/SPAN&gt;
&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;SUBSTRING&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;IMPORTED&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;MYROW&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;13&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;5&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="n"&gt;AS&lt;/SPAN&gt; &lt;SPAN class="n"&gt;Col2&lt;/SPAN&gt;
&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;SUBSTRING&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;IMPORTED&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;MYROW&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;18&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;7&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="n"&gt;AS&lt;/SPAN&gt; &lt;SPAN class="n"&gt;Col3&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;FROM&lt;/SPAN&gt; &lt;SPAN class="n"&gt;IMPORTED&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 01 May 2012 12:02:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/input-vs-load-table-fixed-width-file/qaa-p/13826269#M4857112</guid>
      <dc:creator>former_SQLA_member1694868</dc:creator>
      <dc:date>2012-05-01T12:02:33Z</dc:date>
    </item>
  </channel>
</rss>

