Re: inserting composite types

[email protected] ("David E. Wheeler")
Newsgroups perl.dbd.pg
Message-ID <[email protected]>
On Nov 10, 2010, at 9:42 AM, Rolf Schaufelberger wrote:

> my $pp = $s->resultset('PdfFormatParam')->create({id=>10000,
>                                                  image  => "(1,2,3,4,)",
>                                                  bg_tpl => '(xx.pdf, 1,2,() )',
>                                                  });
> 
> gives 
> 
> DBIx::Class::ResultSet::create(): DBI Exception: DBD::Pg::st execute failed: FEHLER:  fehlerhafte Record-Konstante: »(«
> DETAIL:  Unecpected end of input. [for Statement "INSERT INTO pdf_format_param ( bg_tpl, id, image) VALUES ( ?, ?, ? )" with ParamValues: 1='(xx.pdf, 1,2,() )', 2='10000', 3='(1,2,3,4,)'] at /home/rs/perl/xx.pl line 28
> 
> How do I have to quote this to get this working?

Try

    image  => "(1,2,3,4,NULL)"

Really, though, you should be using ROW() with placeholders.

    $dbh->do(q{
        INSERT INTO whatever VALUES (ROW(?, ?, ?, ?, ?)::image)
    }, undef, 1, 2, 3, 4, undef);

But your ORM isn't gonna do that.

Best,

David
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.