UPDATE Syntax
От | Ulrich Goebel |
---|---|
Тема | UPDATE Syntax |
Дата | |
Msg-id | 811db0e2-1ae3-9908-a421-4a4ba74fcc96@fam-goebel.de обсуждение исходный текст |
Ответы |
Re: UPDATE Syntax - solved
|
Список | pgsql-general |
Hi, in a Python Script I build an UPDATE using the syntax: update tbl set (col1, col2, ...) = (val1, val2, ...) where id = xx That works as long in the two lists are more then one column and values. If I have just one column and value, I get an error message: ========================================================================== cg=# select id, name, vorname, status from tbl_person; id | name | vorname | status ----+--------+---------+-------- 3 | Goebel | Ulrich | a (1 row) cg=# cg=# cg=# cg=# update tbl_person set status = 'a' where id=3; UPDATE 1 cg=# cg=# cg=# cg=# update tbl_person set (status) = ('a') where id=3; ERROR: source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression LINE 1: update tbl_person set (status) = ('a') where id=3; ^ cg=# cg=# cg=# cg=# update tbl_person set (status, name) = ('a', 'Goebel') where id=3; UPDATE 1 cg=# ========================================================================== In fact in the script I have both cases: one ore more columns. Is there another way but to code a case differentiation to avoid this error message? Well, I could use the other syntax: update tbl set col1=val1, col2=val2, ... where id=xx but I just like the former... Thank's Ulrich -- Ulrich Goebel Am Büchel 57, 53173 Bonn
В списке pgsql-general по дате отправления: