[Libpqxx-general] how to create dynamic queries?
Lanre Sarumi
lsarumi at dwarfgoat.com
Mon Sep 21 10:34:20 UTC 2009
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());
Caleb Cushing 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.
>
More information about the Libpqxx-general
mailing list