Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

How to insert a file into a CLOB object?

by vel4ever (Initiate)
on Sep 04, 2013 at 15:23 UTC ( [id://1052373]=perlquestion: print w/replies, xml ) Need Help??

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' };

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1052373]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-25 13:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found