Phoenix.pm: PERL-SQL question

Doug Miles doug.miles at bpxinternet.com
Wed Jan 30 10:53:36 CST 2002


N wrote:

> Hi
> I have a SQL loading question.  have a flat text file
> that is generated every day, the contents of which I
> need loaded into a SQL database. The file is comma
> delimited and each value in the text file corresponds
> to a field in my SQL database. When i extract the
> elements and run the loader against the file, I get
> the following error:
> Could not execute sql statement: at
> C:\Perl\perfloader.pl line 31, <NISHANT> line 6
>   The number at the end ie: 6 corresponds to the
> number of entries in the flat text file.
> I have attached my loader program and the text file as
> well and was wondering if any body knew what the issue
> was.
> Also, I have a text file, the values that are
> delimited by "|" and  Iam having difficulty using the
> split command to extract the elements.
> Thank you
> Rgds
> Nishant
> PS: I use a system DSN connection against the SQL db
> 


I would add:

print "$sql_insert\n";

at line 31.  Then take that query that is displayed, and cut and paste 
it into whatever sql tool you have to see if it executes that way. 
Also, along the lines with what shay said earlier, you should be able to 
do everyting in one while loop.  You shouldn't neet the foreach loop at 
all.  This will simplify the program.  Also, do you have any program 
that actually works making this database connection?  If not, maybe 
there is an issue with the way you are connecting and/or executing the 
query.  I'm not a windows guy, so I'm not familiar with the way you are 
doing it.  If that doesn't work, maybe you should try DBI and DBD::ODBC 
or something.







More information about the Phoenix-pm mailing list