On 06/07/2017 16:04, Paul Sanderson wrote:
The SQLite syntax diagrams are my first point of call when looking at an
error in my code like this.

https://sqlite.org/lang_update.html

"AS" and an alias are clearly not part of the statement.

And that is how (with testing) I eventually worked out that I was on the wrong track. Thank you, Paul.



Paul
www.sandersonforensics.com
skype: r3scue193
twitter: @sandersonforens
Tel +44 (0)1326 572786
http://sandersonforensics.com/forum/content.php?195-SQLite-Forensic-Toolkit
-Forensic Toolkit for SQLite
email from a work address for a fully functional demo licence

On 6 July 2017 at 06:03, Keith Medcalf <kmedc...@dessus.com> wrote:


Do you know of any implementation of SQL that accepts an AS clause for the
updated table?  I don't think any do.

Some versions have a FROM extension and you CAN specify an alias for the
updated table in that clause, however, as far as I know the update table
cannot be aliased and the "set <column> = ..." the <column> must always be
a column in the updated table and while you may be allowed to "adorn" it in
some implementations, any adornments are ignored (or trigger an error
message if they are not the same as the updated table).

--
˙uʍop-ǝpısdn sı ɹoʇıuoɯ ɹnoʎ 'sıɥʇ pɐǝɹ uɐɔ noʎ ɟı

-----Original Message-----
From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org]
On Behalf Of John McMahon
Sent: Wednesday, 5 July, 2017 21:17
To: SQLite Users
Subject: [sqlite] syntax error near AS

Hi

Wondering if someone else can spot the syntax error in the following
statement. "locns" is an attached database. There are four "AS" terms in
the statement, they all alias tables.

Ok, found it. It seems that an alias for an "UPDATE" table name is not
permitted. Is there a particular reason for this?
I would think it a convenience especially when using long table names
and attached databases.

John

sqlite>     UPDATE locns.xxx_last_delivery AS tgt
    ... >      SET
    ... >         tgt.del_date =  (
    ... >              SELECT src.last_del_d
    ... >              FROM   main.updates AS src
    ... >              WHERE  src.custnum = tgt.custnum),
    ... >         tgt.del_qty = (
    ... >              SELECT src.last_del_q
    ... >              FROM   main.updates AS src
    ... >              WHERE  src.custnum = tgt.custnum)
    ... >      WHERE
    ... >         tgt.custnum  = (
    ... >              SELECT src.custnum
    ... >              FROM   main.updates AS src
    ... >              WHERE  src.last_del_d IS NOT NULL
    ... >              AND    src.last_del_d > tgt.del_date)
    ... >  ;
Error: near "AS": syntax error

--
Regards
     John McMahon
        li...@jspect.fastmail.fm


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


--
Regards
   John McMahon
        j...@jspect.fastmail.com.au
        04 2933 4203


--
Regards
   John McMahon
      li...@jspect.fastmail.fm


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to