[Solved] SQL How to update current row

Creating tables and queries
Post Reply
gkick
Posts: 324
Joined: Wed Aug 07, 2019 5:24 pm
Location: Chile

[Solved] SQL How to update current row

Post by gkick »

Hello,

Have a timestamp for record created, one for record changed, a field created by default user name and need another one for record changed by.
The normal sql syntax UPDATE "tblxxx" SET "yyyy" = "zzz" needs a WHERE clause so that only the selected record is updated. There does not seem to be a record number property and according to the HSQL man the rownum() can not be used for = or > condition.

Anyone done something similar ?


Thks
Last edited by gkick on Tue Nov 26, 2019 10:03 pm, edited 1 time in total.
Libre Office 6.4.6 on Windows 10 HSQL 2.51 backend
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: SQL How to update current row

Post by Villeroy »

Your table should have a primary key to identify a distinct record.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
gkick
Posts: 324
Joined: Wed Aug 07, 2019 5:24 pm
Location: Chile

Re: SQL How to update current row

Post by gkick »

Ahh, thanks that's it, store the pk to a variable and use it in the where clause, thanks !!!
Libre Office 6.4.6 on Windows 10 HSQL 2.51 backend
Post Reply