eraymond has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I am completely new to working with utf8 characters in perl. I have a .csv file that contains utf8 characters, that I need to use to perform select/insert statements into a Oracle database. My problem is that I am getting the error:
ORA-01756: quoted string not properly terminated (DBD ERROR: OCIStmtPr +epare)select lit_item_id from journal where jrnl_issn='0365-6691' and jrnl_full_title='Archivos de la Sociedad Española de Oftal +mología'
The unicode characters are creating a unwanted tag close. I have read the perldoc on utf8::encode and tried several ways but I am probably not utilizing the module properly. Has anyone else had to perform this type of task and been successful?
  • Comment on How do I get a flatfile containing UTF8 characters inserted using the DBI module?
  • Download Code

Replies are listed 'Best First'.
Re: How do I get a flatfile containing UTF8 characters inserted using the DBI module?
by jZed (Prior) on Feb 15, 2005 at 23:20 UTC
    If you use DBD::CSV you can access the CSV file with the same DBI/SQL statements you'd use to access Oracle so you can just SELECT what you want from the CSV and then loop through a fetch INSERTing into Oracle as you go. You'll want the latest DBD::File (a prereq for DBD::CSV) since it fixes a bug in UTF8 handling (it's found in the latest DBI release). You'll almost certainly want to use placeholders for your INSERT.
      Thanks, I will give it a go. I was trying to stray from inserting into the table without knowing exactly what data it will be inserting. I was creating a separate .sql file to check then run after it looked good. Thanks.