On Mon, Sep 15, 2014 at 10:21 AM, Dennis Jenkins
<dennis.jenkins...@gmail.com> wrote:
> This construct does not work in postgresql 9.3.5 (unless I have a typo).
>
> However, I would love for it to work in both Postgresql and Sqlite.
>
>
> djenkins@ostara ~ $ psql -Upostgres -dcapybara_regtest
> psql (9.3.5)
> Type "help" for help.
>
> capybara_regtest=# create table test1 (col1 integer, col2 integer, col3
> text);
> CREATE TABLE
> capybara_regtest=# insert into test1 values (1, 2, 'hello');
> INSERT 0 1
> capybara_regtest=# update test1 set (col1, col2, col3) = (select 4, 5,
> 'bye');
> ERROR:  syntax error at or near "select"
> LINE 1: update test1 set (col1, col2, col3) = (select 4, 5, 'bye');
>                                                ^
> capybara_regtest=# \q
>

Hum, my test transcript:

$ psql
psql (9.3.5)
Type "help" for help.

tsh009=# create table test1 (col1 integer, col2 integer, col3 text);
CREATE TABLE
tsh009=# insert into test1 values(1,2,'hello');
INSERT 0 1
tsh009=# update test1 set (col1, col2, col3) = (4,5,'bye');
UPDATE 1
tsh009=# update test1 set (col1, col2, col3) = (select 6,7,'what');
ERROR:  syntax error at or near "select"
LINE 1: update test1 set (col1, col2, col3) = (select 6,7,'what');
                                               ^
tsh009=#


So I can't use SELECT, but I could use just plain values. This seems
to verify what is said on:
http://www.postgresql.org/docs/9.3/interactive/sql-update.html
<quote>
According to the standard, the column-list syntax should allow a list
of columns to be assigned from a single row-valued expression, such as
a sub-select:
...
This is not currently implemented — the source must be a list of
independent expressions.
</quote>

I would like the SET of multiple fields in a single UPDATE command,
like what worked in the above transcript.

-- 
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! <><
John McKown
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to