Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Petr is exactly right, the LOAD statement is an ISQL or DB-Access extension, so you can't execute it through DBI. If you have a look at the manual, you'll see it is also invalid syntax for SPL, ESQL/C and so on.</p> <p>It's not clear whether you have to use perl to execute the script, or perl is just a convenient way of generating the SQL.</p> <p>If the former, and you want a pure-perl method, you have to prepare an INSERT statement (there's just one table involved by the look of it?), and slurp through the file, using <code>split</code> to break it up into columns and executing the prepared insert.</p> <p>Otherwise, you can generate the SQL using perl and execute it through DB-Access, either directly with <code>system</code> or by wrapping both in either a shell script or DOS batch file.</p> <p>System call version</p> <pre><code>foreach (@files) { my $stmt = "LOAD FROM $_ INSERT INTO table;\n"; system("echo $stmt | dbaccess $database") || die "Statement $stmt failed: $!\n"; } </code></pre> <p>In a batch script version, you could write all the SQL into a single script, ie:</p> <pre><code>perl -e 'while(@ARGV){shift; print "LOAD FROM '$_' INSERT INTO table;\n"}' file1 [ file2 ... ] &gt; loadfiles.sql isql database loadfiles.sql </code></pre> <p>NB, the comment about quotes on the filename is only relevant if the filename contains spaces or metacharacters, the usual issue.</p> <p>Also, one key difference in behaviour between isql and dbaccess is that when executed in this manner, dbaccess does not stop on error, but isql will. To make dbaccess stop processing on error, set DBACCNOIGN=1 in the environment.</p> <p>Hope that's helpful.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload