Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy won't this ISQL command run through Perl's DBI?
    primarykey
    data
    text
    <p>A while back I was looking for a <a href="https://stackoverflow.com/questions/1074364/informix-7-3-isql-insert-statement-text-blob-clob-field-insert-error">way to insert values into a text field through isql</a> and eventually found some load command that worked out for me.</p> <p>It doesn't work when I try to execute it from Perl. I get a syntax error. I have tried two separate methods and both are not working so far.</p> <p>I have the SQL statement variable print out at the end of each loop cycle so I know that the syntax is correct, but just not getting across correctly.</p> <p>Here's the latest snip of code I was testing:</p> <pre><code>foreach(@files) { $STMT = &lt;&lt;EOF; load from $_ insert into some_table EOF $sth = $db1-&gt;prepare($STMT); $sth-&gt;execute; } </code></pre> <p><code>@files</code> is an array whose elements are a full path/location of a pipe-delimited text file (ex. /home/xx/xx/xx/something.txt)</p> <p>The number of columns in the table match the number of fields in the text file and the type-checking is fine (I've loaded test files manually without fail)</p> <p>The error I get back is:</p> <pre><code>DBD::Informix::db prepare failed: SQL: -201: A syntax error has occurred. </code></pre> <p>Any idea what might be causing this?<br> <hr> <b>EDIT to RET's &amp; Petr's answers</b></p> <pre><code>$STMT = "'LOAD FROM $_ INSERT INTO table'"; system("echo $STMT | isql $db") </code></pre> <p>I had to change it to this, because the die command would force an unnatural death and the statement had to be wrapped in single quotes.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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