UPDATE SET using column-name-list Syntax error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

UPDATE SET using column-name-list Syntax error

javaj1811@elxala.com
Hi,

According to the documentation UPDATE SET admits column-name-list as
argument
but I cannot get it working. Here some tries

DROP TABLE IF EXISTS test; CREATE TABLE test(a,b,c);

-- ok
UPDATE test SET a = "vala", b = "valb" ;
UPDATE test SET a = (SELECT "vala"), b = (SELECT "valb") ;

-- not ok
UPDATE test SET (a, b) = "vala", "valb" ;
Error: near "(": syntax error
UPDATE test SET (a, b) = (SELECT "vala", "valb") ;
Error: near "(": syntax error

What am I doing wrong ? or is this syntax really supported ?

I am specially interested in the syntax using SELECT since it could
optimize the update
reducing the number of needed SELECT's

thanks,
Alejandro

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: UPDATE SET using column-name-list Syntax error

Richard Hipp-3
On 12/10/17, [hidden email] <[hidden email]> wrote:

>
> According to the documentation UPDATE SET admits column-name-list as
> argument
> but I cannot get it working. Here some tries
>
> DROP TABLE IF EXISTS test; CREATE TABLE test(a,b,c);
>
> -- ok
> UPDATE test SET a = "vala", b = "valb" ;
> UPDATE test SET a = (SELECT "vala"), b = (SELECT "valb") ;
>
> -- not ok
> UPDATE test SET (a, b) = "vala", "valb" ;
> Error: near "(": syntax error
> UPDATE test SET (a, b) = (SELECT "vala", "valb") ;
> Error: near "(": syntax error
>
> What am I doing wrong ? or is this syntax really supported ?

It is supported beginning with SQLite 3.15.0 (2016-10-14).  What
version of SQLite are you running?
--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: UPDATE SET using column-name-list Syntax error

curmudgeon
In reply to this post by javaj1811@elxala.com
>UPDATE test SET (a, b) = "vala", "valb" ;

Should that not be (a, b) = (‘vala’, ‘valb’);


>UPDATE test SET (a, b) = (SELECT "vala", "valb") ;

Should that not be (a, b) = ((SELECT ‘vala’), ‘valb’);


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: UPDATE SET using column-name-list Syntax error

javaj1811@elxala.com
In reply to this post by Richard Hipp-3
Richard Hipp wrote:

> On 12/10/17, [hidden email] <[hidden email]> wrote:
>> According to the documentation UPDATE SET admits column-name-list as
>> argument
>> but I cannot get it working. Here some tries
>>
>> DROP TABLE IF EXISTS test; CREATE TABLE test(a,b,c);
>>
>> -- ok
>> UPDATE test SET a = "vala", b = "valb" ;
>> UPDATE test SET a = (SELECT "vala"), b = (SELECT "valb") ;
>>
>> -- not ok
>> UPDATE test SET (a, b) = "vala", "valb" ;
>> Error: near "(": syntax error
>> UPDATE test SET (a, b) = (SELECT "vala", "valb") ;
>> Error: near "(": syntax error
>>
>> What am I doing wrong ? or is this syntax really supported ?
> It is supported beginning with SQLite 3.15.0 (2016-10-14).  What
> version of SQLite are you running?
Certantly! my application uses sqlite 3.17 2017-02-08 which is pretty
new and support it
but I did the check in the command line actually with an older version
(3.8.8.1 2015-01-20)
I will update this executable as well to avoid such wrong checks in future.

thank you!

PD:

-- not ok anyway (bad syntax from me)

UPDATE test SET (a, b) = "vala", "valb" ;
Error: 2 columns assigned 1 values

-- both ok
UPDATE test SET (a, b) = ("vala", "valb") ;
UPDATE test SET (a, b) = (SELECT "vala", "valb") ;






_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users