[Libpqxx-general] how to create dynamic queries?
Peter Geoghegan
peter.geoghegan86 at gmail.com
Mon Sep 21 11:51:55 UTC 2009
Hi,
2009/9/21 Lanre Sarumi <lsarumi at dwarfgoat.com>:
> just use std::stringstream. That way you don't have to worry about mixing
> data types.
>
> std::stringstream sql;
>
> sql<<"INSERT INTO korama.tracks ( file_path, title ) VALUES ('"
> <<tran.esc(iter->path())
> <<"','" <<tran.esc(iter->path())
> <<"')";
>
> tran.exec(sql.str());
>
You can just do "trans.exec(sql);". exec is overloaded for stringstream,
Regards,
Peter Geoghegan
More information about the Libpqxx-general
mailing list