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

I am using DBI to insert few records into Oracle database. I have a column in the table which holds CLOB data type. I have the data to be inserted in a flat file (.txt,.xml). How to prepare the insert statement for this and execute?
  • Comment on How to insert a file into a CLOB object?

Replies are listed 'Best First'.
Re: How to insert a file into a CLOB object?
by kennethk (Abbot) on Sep 04, 2013 at 15:42 UTC
    See Simple_Usage in DBD::Oracle. From the link:
    $sth->bind_param($field_num, $lob_value, { ora_type => ORA_CLOB });
    after
    use DBD::Oracle qw(:ora_types);
    to import ORA_CLOB. There seems to be some conflicting data with regards to using SQLT_CHR instead, but I've successfully used the above.

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Re: How to insert a file into a CLOB object?
by daxim (Curate) on Sep 04, 2013 at 15:37 UTC
    What do the data look like? If they are encoded like I think they are, simply:
    use File::Slurp qw(read_file); my $lob = read_file 'data.txt', { binmode => ':raw' };