Subject Re: [firebird-support] CTE
Author Mark Rotteveel
On Wed, 26 Feb 2014 11:43:24 +0100, "checkmail" <check_mail@...>
wrote:
> Hello,
>
> I get an error message during executing the following statement:
>
> with mat as (
>
> select a.teilenr, c.vkpreis, a.matteilenr, c.bezeichnung from tmaterial
a
> left join tteile c on a.teilenr = c.teilenr
>
> where a.kundennr = 24823 )
>
> update tteile set tteile.minvk = mat.vkpreis * 0.90 where teilenr =
> mat.teilenr
>
> I know, I can do the following (update XX where (select.)
>
> Why complain firebird the update..?

If you post a question that you get an error, then please include the
actual error in your question. That is 1) easier for people answering your
question and 2) allows for search engines like google to help other people
find your question in the future.

It is (with FlameRobin):
SQL Message : -104
Invalid token

Engine Code : 335544569
Engine Message :
Dynamic SQL Error
SQL error code = -104
Token unknown - line 5, column 1
UPDATE

The problem is that the Firebird syntax only allows the use of WITH with a
SELECT; it is not supported with other query types (contrary to some other
database systems). But even if it were allowed, your current syntax would
be invalid.

Your current query is akin to having a view called mat and then trying:

update tteile set tteile.minvk = mat.vkpreis * 0.90 where teilenr =
mat.teilenr

That fails as you never actually select from mat.

Mark