[Interest] Postgresql RETURNING clause.... possible to get it?
Jason Dolan
jason at pcc.com
Mon Feb 16 14:39:22 CET 2015
It should be as simple as:
QSqlQuery query;
query.prepare("INSERT INTO rooms (coordinate) VALUES (ST_SetSRID(ST_MakePoint(:lon, :lat), 4326)) returning id”);
query.bindValue(“:lon”, x);
query.bindValue(“:lat”, y);
uint roomsId = 0;
if(query.exec() && query.first())
roomsId = query.value(0).toUInt();
> On Feb 16, 2015, at 8:15 AM, Guido Seifert <wargand at gmx.de> wrote:
>
> Hiya,
> I have a sql (postgres) statement:
>
>> INSERT INTO rooms (coordinate) VALUES (ST_SetSRID(ST_MakePoint(:lon, :lat), 4326)) returning id;
>
> with id being a serial.
>
> Sure, I can get the id with lastInsertId(), but I wonder, if and how it is possible to get the id value
> from a QSqlQuery.
>
> Guido
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
More information about the Interest
mailing list