It would have been helpful if you posted the schema for the table, but from what you wrote, I'll assume you have a table that's defined something like:

create table tbl_name ( product_id int, model_number int, description char[] );

If your description is really a "character array", may I suggest that you change it to type "text" instead.

Your new table would look like:

create table new_tbl_name ( product_id int, model_number int, description text );

Your array problems should go away, since you're not even dealing with an array anymore.

Just for your information, if you want to put data into a column that is an array of another type, you have to use the { } notation. It's kind of like the [ ] array constructor in perl.

Here's an example: (Assume we're using the tbl_name table);

my $text = join('', <STDIN>); my $pg_array = join ('', map { "'$_', " } split ('', $text)); $pg_array =~ s/, $//; $pg_array = "{ $pg_array }"; $dbh->do(" insert into tbl_name (product_id, model_number, description) values ($prod_id, $mod_num, $pg_array) ");

Really, though -- don't use character arrays for text. Just use a text field.


In reply to Re: DBD::Pg INSERT enlightenment by beppu
in thread DBD::Pg INSERT enlightenment by penguinfuz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.