in reply to DBD::Pg INSERT enlightenment
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBD::Pg INSERT enlightenment
by penguinfuz (Pilgrim) on Feb 06, 2001 at 07:37 UTC | |
by beppu (Hermit) on Feb 06, 2001 at 08:33 UTC | |
by penguinfuz (Pilgrim) on Feb 06, 2001 at 10:14 UTC | |
by beppu (Hermit) on Feb 06, 2001 at 12:30 UTC | |
by repson (Chaplain) on Feb 06, 2001 at 13:47 UTC |