Cumulative aggregates produce a token unknown error
I have a problem with Firebird (embedded - version 3.0) database with cumulative aggregates. I have the following table:
+----+---------+
|ID |Salary +
+----+---------+
|1 |10.00 |
+----+---------+
|2 |20.00 |
+----+---------+
|3 |35.00 |
+----+---------+
|4 |10.00 |
+----+---------+
I would like to add a third column (cum_sum) that will contain a cumulative sum, i.e .:
+----+---------+---------+
|ID +Salary +cum_sum |
+----+---------+---------+
|1 |10.00 |10.00 |
+----+---------+---------+
|2 |20.00 |30.00 |
+----+---------+---------+
|3 |35.00 |65.00 |
+----+---------+---------+
|4 |10.00 |75.00 |
+----+---------+---------+
When I try to use the following code:
select id, salary, sum(salary) over (order by salary) cum_sum
from employee
order by salary
I get a message:
Invalid token.
Dynamic SQL Error.
SQL error code = -104.
Token unknown - line 1, column 37.
Where is the problem?
sum firebird
|
show 2 more comments
I have a problem with Firebird (embedded - version 3.0) database with cumulative aggregates. I have the following table:
+----+---------+
|ID |Salary +
+----+---------+
|1 |10.00 |
+----+---------+
|2 |20.00 |
+----+---------+
|3 |35.00 |
+----+---------+
|4 |10.00 |
+----+---------+
I would like to add a third column (cum_sum) that will contain a cumulative sum, i.e .:
+----+---------+---------+
|ID +Salary +cum_sum |
+----+---------+---------+
|1 |10.00 |10.00 |
+----+---------+---------+
|2 |20.00 |30.00 |
+----+---------+---------+
|3 |35.00 |65.00 |
+----+---------+---------+
|4 |10.00 |75.00 |
+----+---------+---------+
When I try to use the following code:
select id, salary, sum(salary) over (order by salary) cum_sum
from employee
order by salary
I get a message:
Invalid token.
Dynamic SQL Error.
SQL error code = -104.
Token unknown - line 1, column 37.
Where is the problem?
sum firebird
Which Firebird version are you using? Window functions were introduced in Firebird 3. Also not that your error message is incomplete, Firebird normally also reports the invalid token (in this case(
).
– Mark Rotteveel
Nov 28 '18 at 16:30
I had read over the fact you say you are using Firebird 3 Embedded. I suggest you double check, because the error suggests otherwise. Try executingselect rdb$get_context('SYSTEM', 'ENGINE_VERSION') from rdb$database
to retrieve the actual version.
– Mark Rotteveel
Nov 28 '18 at 16:35
Minor nitpick: the expected output suggest you want to useorder by id
both in the window and in the main select.
– Mark Rotteveel
Nov 28 '18 at 16:53
this query is but verbatim copy of one from Firebird 3.0.0 Release Notes (page 77), so I think it can not give error in FB3. Either different server version or different query or different error it must be.
– Arioch 'The
Nov 28 '18 at 17:03
@Arioch'The You're right, but I can reproduce the exact same error message with Firebird 2.5 (that is why I knew the invalid token was(
).
– Mark Rotteveel
Nov 28 '18 at 17:08
|
show 2 more comments
I have a problem with Firebird (embedded - version 3.0) database with cumulative aggregates. I have the following table:
+----+---------+
|ID |Salary +
+----+---------+
|1 |10.00 |
+----+---------+
|2 |20.00 |
+----+---------+
|3 |35.00 |
+----+---------+
|4 |10.00 |
+----+---------+
I would like to add a third column (cum_sum) that will contain a cumulative sum, i.e .:
+----+---------+---------+
|ID +Salary +cum_sum |
+----+---------+---------+
|1 |10.00 |10.00 |
+----+---------+---------+
|2 |20.00 |30.00 |
+----+---------+---------+
|3 |35.00 |65.00 |
+----+---------+---------+
|4 |10.00 |75.00 |
+----+---------+---------+
When I try to use the following code:
select id, salary, sum(salary) over (order by salary) cum_sum
from employee
order by salary
I get a message:
Invalid token.
Dynamic SQL Error.
SQL error code = -104.
Token unknown - line 1, column 37.
Where is the problem?
sum firebird
I have a problem with Firebird (embedded - version 3.0) database with cumulative aggregates. I have the following table:
+----+---------+
|ID |Salary +
+----+---------+
|1 |10.00 |
+----+---------+
|2 |20.00 |
+----+---------+
|3 |35.00 |
+----+---------+
|4 |10.00 |
+----+---------+
I would like to add a third column (cum_sum) that will contain a cumulative sum, i.e .:
+----+---------+---------+
|ID +Salary +cum_sum |
+----+---------+---------+
|1 |10.00 |10.00 |
+----+---------+---------+
|2 |20.00 |30.00 |
+----+---------+---------+
|3 |35.00 |65.00 |
+----+---------+---------+
|4 |10.00 |75.00 |
+----+---------+---------+
When I try to use the following code:
select id, salary, sum(salary) over (order by salary) cum_sum
from employee
order by salary
I get a message:
Invalid token.
Dynamic SQL Error.
SQL error code = -104.
Token unknown - line 1, column 37.
Where is the problem?
sum firebird
sum firebird
edited Nov 28 '18 at 16:56
Mark Rotteveel
61.5k1478122
61.5k1478122
asked Nov 28 '18 at 15:56
Mirosław RychterMirosław Rychter
182
182
Which Firebird version are you using? Window functions were introduced in Firebird 3. Also not that your error message is incomplete, Firebird normally also reports the invalid token (in this case(
).
– Mark Rotteveel
Nov 28 '18 at 16:30
I had read over the fact you say you are using Firebird 3 Embedded. I suggest you double check, because the error suggests otherwise. Try executingselect rdb$get_context('SYSTEM', 'ENGINE_VERSION') from rdb$database
to retrieve the actual version.
– Mark Rotteveel
Nov 28 '18 at 16:35
Minor nitpick: the expected output suggest you want to useorder by id
both in the window and in the main select.
– Mark Rotteveel
Nov 28 '18 at 16:53
this query is but verbatim copy of one from Firebird 3.0.0 Release Notes (page 77), so I think it can not give error in FB3. Either different server version or different query or different error it must be.
– Arioch 'The
Nov 28 '18 at 17:03
@Arioch'The You're right, but I can reproduce the exact same error message with Firebird 2.5 (that is why I knew the invalid token was(
).
– Mark Rotteveel
Nov 28 '18 at 17:08
|
show 2 more comments
Which Firebird version are you using? Window functions were introduced in Firebird 3. Also not that your error message is incomplete, Firebird normally also reports the invalid token (in this case(
).
– Mark Rotteveel
Nov 28 '18 at 16:30
I had read over the fact you say you are using Firebird 3 Embedded. I suggest you double check, because the error suggests otherwise. Try executingselect rdb$get_context('SYSTEM', 'ENGINE_VERSION') from rdb$database
to retrieve the actual version.
– Mark Rotteveel
Nov 28 '18 at 16:35
Minor nitpick: the expected output suggest you want to useorder by id
both in the window and in the main select.
– Mark Rotteveel
Nov 28 '18 at 16:53
this query is but verbatim copy of one from Firebird 3.0.0 Release Notes (page 77), so I think it can not give error in FB3. Either different server version or different query or different error it must be.
– Arioch 'The
Nov 28 '18 at 17:03
@Arioch'The You're right, but I can reproduce the exact same error message with Firebird 2.5 (that is why I knew the invalid token was(
).
– Mark Rotteveel
Nov 28 '18 at 17:08
Which Firebird version are you using? Window functions were introduced in Firebird 3. Also not that your error message is incomplete, Firebird normally also reports the invalid token (in this case
(
).– Mark Rotteveel
Nov 28 '18 at 16:30
Which Firebird version are you using? Window functions were introduced in Firebird 3. Also not that your error message is incomplete, Firebird normally also reports the invalid token (in this case
(
).– Mark Rotteveel
Nov 28 '18 at 16:30
I had read over the fact you say you are using Firebird 3 Embedded. I suggest you double check, because the error suggests otherwise. Try executing
select rdb$get_context('SYSTEM', 'ENGINE_VERSION') from rdb$database
to retrieve the actual version.– Mark Rotteveel
Nov 28 '18 at 16:35
I had read over the fact you say you are using Firebird 3 Embedded. I suggest you double check, because the error suggests otherwise. Try executing
select rdb$get_context('SYSTEM', 'ENGINE_VERSION') from rdb$database
to retrieve the actual version.– Mark Rotteveel
Nov 28 '18 at 16:35
Minor nitpick: the expected output suggest you want to use
order by id
both in the window and in the main select.– Mark Rotteveel
Nov 28 '18 at 16:53
Minor nitpick: the expected output suggest you want to use
order by id
both in the window and in the main select.– Mark Rotteveel
Nov 28 '18 at 16:53
this query is but verbatim copy of one from Firebird 3.0.0 Release Notes (page 77), so I think it can not give error in FB3. Either different server version or different query or different error it must be.
– Arioch 'The
Nov 28 '18 at 17:03
this query is but verbatim copy of one from Firebird 3.0.0 Release Notes (page 77), so I think it can not give error in FB3. Either different server version or different query or different error it must be.
– Arioch 'The
Nov 28 '18 at 17:03
@Arioch'The You're right, but I can reproduce the exact same error message with Firebird 2.5 (that is why I knew the invalid token was
(
).– Mark Rotteveel
Nov 28 '18 at 17:08
@Arioch'The You're right, but I can reproduce the exact same error message with Firebird 2.5 (that is why I knew the invalid token was
(
).– Mark Rotteveel
Nov 28 '18 at 17:08
|
show 2 more comments
1 Answer
1
active
oldest
votes
You get this error if you are using Firebird 2.5 or earlier. Window functions were introduced in Firebird 3. You will need to upgrade to Firebird 3 if you want to run the query as shown in your question.
As you claim to use Firebird 3 Embedded, I suggest that you carefully check
if your Firebird embedded version is actually version 3 (eg use
select rdb$get_context('SYSTEM', 'ENGINE_VERSION') from rdb$database
; this works for Firebird 2.1 and higher and will report an error for earlier versions).
You may have loaded a different version of Firebird. This can happen if you have a different version of the embedded library earlier on the search path. This can also happen if you have a Firebird 2.5 fbembed.dll and a Firebird 3 fbclient.dll in the same location. In Firebird 3, embedded was unified with the normal client, and no longer has a separate library (it requires additional libraries, the engine plugin, instead). However most Firebird drivers will first attempt to load fbembed.dll before falling back to fbclient.dll.
if you are actually connecting with Firebird embedded, and not accidentally to a Firebird server instance of a different version (eg
select rdb$get_context('SYSTEM', 'NETWORK_PROTOCOL') from rdb$database
will reportNULL
for embedded, but a value for other connection methods).
This can happen if you use the wrong connection string or otherwise incorrectly configured your driver.
Otherwise, if you can't upgrade, you will need to use the more painful option of writing a stored procedure (or block) that does this for you, or resort to equally painful recursive CTE-based solutions (that have other limitations that might get in the way).
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53523419%2fcumulative-aggregates-produce-a-token-unknown-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You get this error if you are using Firebird 2.5 or earlier. Window functions were introduced in Firebird 3. You will need to upgrade to Firebird 3 if you want to run the query as shown in your question.
As you claim to use Firebird 3 Embedded, I suggest that you carefully check
if your Firebird embedded version is actually version 3 (eg use
select rdb$get_context('SYSTEM', 'ENGINE_VERSION') from rdb$database
; this works for Firebird 2.1 and higher and will report an error for earlier versions).
You may have loaded a different version of Firebird. This can happen if you have a different version of the embedded library earlier on the search path. This can also happen if you have a Firebird 2.5 fbembed.dll and a Firebird 3 fbclient.dll in the same location. In Firebird 3, embedded was unified with the normal client, and no longer has a separate library (it requires additional libraries, the engine plugin, instead). However most Firebird drivers will first attempt to load fbembed.dll before falling back to fbclient.dll.
if you are actually connecting with Firebird embedded, and not accidentally to a Firebird server instance of a different version (eg
select rdb$get_context('SYSTEM', 'NETWORK_PROTOCOL') from rdb$database
will reportNULL
for embedded, but a value for other connection methods).
This can happen if you use the wrong connection string or otherwise incorrectly configured your driver.
Otherwise, if you can't upgrade, you will need to use the more painful option of writing a stored procedure (or block) that does this for you, or resort to equally painful recursive CTE-based solutions (that have other limitations that might get in the way).
add a comment |
You get this error if you are using Firebird 2.5 or earlier. Window functions were introduced in Firebird 3. You will need to upgrade to Firebird 3 if you want to run the query as shown in your question.
As you claim to use Firebird 3 Embedded, I suggest that you carefully check
if your Firebird embedded version is actually version 3 (eg use
select rdb$get_context('SYSTEM', 'ENGINE_VERSION') from rdb$database
; this works for Firebird 2.1 and higher and will report an error for earlier versions).
You may have loaded a different version of Firebird. This can happen if you have a different version of the embedded library earlier on the search path. This can also happen if you have a Firebird 2.5 fbembed.dll and a Firebird 3 fbclient.dll in the same location. In Firebird 3, embedded was unified with the normal client, and no longer has a separate library (it requires additional libraries, the engine plugin, instead). However most Firebird drivers will first attempt to load fbembed.dll before falling back to fbclient.dll.
if you are actually connecting with Firebird embedded, and not accidentally to a Firebird server instance of a different version (eg
select rdb$get_context('SYSTEM', 'NETWORK_PROTOCOL') from rdb$database
will reportNULL
for embedded, but a value for other connection methods).
This can happen if you use the wrong connection string or otherwise incorrectly configured your driver.
Otherwise, if you can't upgrade, you will need to use the more painful option of writing a stored procedure (or block) that does this for you, or resort to equally painful recursive CTE-based solutions (that have other limitations that might get in the way).
add a comment |
You get this error if you are using Firebird 2.5 or earlier. Window functions were introduced in Firebird 3. You will need to upgrade to Firebird 3 if you want to run the query as shown in your question.
As you claim to use Firebird 3 Embedded, I suggest that you carefully check
if your Firebird embedded version is actually version 3 (eg use
select rdb$get_context('SYSTEM', 'ENGINE_VERSION') from rdb$database
; this works for Firebird 2.1 and higher and will report an error for earlier versions).
You may have loaded a different version of Firebird. This can happen if you have a different version of the embedded library earlier on the search path. This can also happen if you have a Firebird 2.5 fbembed.dll and a Firebird 3 fbclient.dll in the same location. In Firebird 3, embedded was unified with the normal client, and no longer has a separate library (it requires additional libraries, the engine plugin, instead). However most Firebird drivers will first attempt to load fbembed.dll before falling back to fbclient.dll.
if you are actually connecting with Firebird embedded, and not accidentally to a Firebird server instance of a different version (eg
select rdb$get_context('SYSTEM', 'NETWORK_PROTOCOL') from rdb$database
will reportNULL
for embedded, but a value for other connection methods).
This can happen if you use the wrong connection string or otherwise incorrectly configured your driver.
Otherwise, if you can't upgrade, you will need to use the more painful option of writing a stored procedure (or block) that does this for you, or resort to equally painful recursive CTE-based solutions (that have other limitations that might get in the way).
You get this error if you are using Firebird 2.5 or earlier. Window functions were introduced in Firebird 3. You will need to upgrade to Firebird 3 if you want to run the query as shown in your question.
As you claim to use Firebird 3 Embedded, I suggest that you carefully check
if your Firebird embedded version is actually version 3 (eg use
select rdb$get_context('SYSTEM', 'ENGINE_VERSION') from rdb$database
; this works for Firebird 2.1 and higher and will report an error for earlier versions).
You may have loaded a different version of Firebird. This can happen if you have a different version of the embedded library earlier on the search path. This can also happen if you have a Firebird 2.5 fbembed.dll and a Firebird 3 fbclient.dll in the same location. In Firebird 3, embedded was unified with the normal client, and no longer has a separate library (it requires additional libraries, the engine plugin, instead). However most Firebird drivers will first attempt to load fbembed.dll before falling back to fbclient.dll.
if you are actually connecting with Firebird embedded, and not accidentally to a Firebird server instance of a different version (eg
select rdb$get_context('SYSTEM', 'NETWORK_PROTOCOL') from rdb$database
will reportNULL
for embedded, but a value for other connection methods).
This can happen if you use the wrong connection string or otherwise incorrectly configured your driver.
Otherwise, if you can't upgrade, you will need to use the more painful option of writing a stored procedure (or block) that does this for you, or resort to equally painful recursive CTE-based solutions (that have other limitations that might get in the way).
edited Nov 28 '18 at 16:54
answered Nov 28 '18 at 16:33
Mark RotteveelMark Rotteveel
61.5k1478122
61.5k1478122
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53523419%2fcumulative-aggregates-produce-a-token-unknown-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Which Firebird version are you using? Window functions were introduced in Firebird 3. Also not that your error message is incomplete, Firebird normally also reports the invalid token (in this case
(
).– Mark Rotteveel
Nov 28 '18 at 16:30
I had read over the fact you say you are using Firebird 3 Embedded. I suggest you double check, because the error suggests otherwise. Try executing
select rdb$get_context('SYSTEM', 'ENGINE_VERSION') from rdb$database
to retrieve the actual version.– Mark Rotteveel
Nov 28 '18 at 16:35
Minor nitpick: the expected output suggest you want to use
order by id
both in the window and in the main select.– Mark Rotteveel
Nov 28 '18 at 16:53
this query is but verbatim copy of one from Firebird 3.0.0 Release Notes (page 77), so I think it can not give error in FB3. Either different server version or different query or different error it must be.
– Arioch 'The
Nov 28 '18 at 17:03
@Arioch'The You're right, but I can reproduce the exact same error message with Firebird 2.5 (that is why I knew the invalid token was
(
).– Mark Rotteveel
Nov 28 '18 at 17:08