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 <[email protected]> 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
> [email protected]
> http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest