Re: Another flat-file insert question

From: Leegold (leegold_at_fastmail.fm)
Date: 05/17/04


To: dbi-users@perl.org
Date: Mon, 17 May 2004 15:42:00 -0400

Another possibly slightly ignorent question,
though I have learned a lot from this group
please be sure of that.

When I insert a record, the new record is appended.
But given my code below it's added on to the last line/record
of the file instead of being on it's own line.
eg. I get,
 f1|f2|f3f1|f2|f3
<eof>
vs. what I'd expect
 f1|f2|f3
 f1|f2|f3
<eof>
Is the fix just to make sure the last record has one "/n"
ie. one <eoln> before i insert?

Again I could write "file processing" perl code since it's
a flat-file, But is there an SQL or a DBI method that I am
not using or a higher level clean way to remedy?
----------------------------------------
#!/usr/bin/perl -w
use strict;
use DBI;

my $file_name='C:\Documents and
Settings\LGOLD\Desktop\threesharp\datatest.threesharp';
my $table_name='pips';
my $dbh = DBI->connect('dbi:AnyData(RaiseError=1):');
$dbh->func( $table_name, 'ThreeSharp', $file_name, 'ad_catalog');
$dbh->do("INSERT INTO $table_name VALUES ('ocm28999999', 'AZSO alert
notice', 'Bugtussle, KY')");

-- 
http://www.fastmail.fm - mmm... Fastmail...


Relevant Pages

  • Re: [crosspost] Perl -> C
    ... > void getkeyfromfile ... below) and will be promoted to int in the computations below anyway. ... EOF I would suggest doing the input in the caller, ... as your Perl code did. ...
    (comp.lang.c)
  • Re: help with perl code
    ... > i have written some perl code like this ... > EOF ... > print $telnetcmd; ... > Execution of ./test.pl aborted due to compilation errors. ...
    (comp.lang.perl.misc)
  • Re: help with perl code
    ... >> i have written some perl code like this ... > You're missing the '=' sign. ... > EOF ... > I can read your mind, and you should be ashamed of yourself. ...
    (comp.lang.perl.misc)