[Libpqxx-general] how to create dynamic queries?

Maurice Gittens mainmanmauricio at gmail.com
Mon Sep 21 07:01:04 UTC 2009


Hi Caleb,


On Mon, Sep 21, 2009 at 12:32 AM, Caleb Cushing <xenoterracide at gmail.com>wrote:

>            tran.exec("INSERT INTO korama.tracks ( file_path, title ) VALUES
> ('"
>                + tran.esc(iter->path())
>                + "','"
>                + tran.esc(iter->path())
>                + "');"
>            );
> trying to insert the path() (using boost::filesystem) into the
> database but I can't get it to compile. I've tried various variations
> of concatenating the strings in exec... none work, and each withe
> different errors. any help would be appreciated.
>
>

operator+ is not implemented for const char*.

Trying something like:

           tran.exec(std::string("INSERT INTO korama.tracks ( file_path,
title ) VALUES ('")
               + tran.esc(iter->path())
               + "','"
               + tran.esc(iter->path())
               + "');"
           );

will probably do the trick,

Kind regards,
Maurice


 --
> Caleb Cushing
>
> http://xenoterracide.blogspot.com
> _______________________________________________
> Libpqxx-general mailing list
> Libpqxx-general at pgfoundry.org
> http://pgfoundry.org/mailman/listinfo/libpqxx-general
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://pgfoundry.org/pipermail/libpqxx-general/attachments/20090921/5ff75126/attachment.html>


More information about the Libpqxx-general mailing list