Subject | CASE syntax |
---|---|
Author | Sergio |
Post date | 2008-03-07T22:46:04Z |
Hi all. FB 1.5.3 SS. When I use the following SELECT everything is OK:
SELECT
...somefields...,
CASE
WHEN (SELECT FIRST 1 T1.MyField FROM
SomeTable T1 WHERE T1.MyIndex = T.MyIndex ORDER BY T1.OrderField DESC) = 0
THEN 'some string'
WHEN (SELECT FIRST 1 T1.MyField FROM
SomeTable T1 WHERE T1.MyIndex = T.MyIndex ORDER BY T1.OrderField DESC) = 1
THEN 'another string'
:
:
ELSE
'blablabla'
END FieldAlias
FROM
MyTable T
WHERE
...some conditions...
ORDER BY
1,
2
But when I use the following:
SELECT
...somefields...
CASE (SELECT FIRST 1 T1.MyField FROM SomeTable T1
WHERE T1.MyIndex = T.MyIndex ORDER BY T1.OrderField DESC)
WHEN 0 THEN 'some string'
WHEN 1 THEN 'another string'
:
:
ELSE
'blablabla'
END FieldAlias
FROM
MyTable T
WHERE
...some conditions...
ORDER BY
1,
2
I receive an error: "Invalid token. invalid request BLR at offset 219.
context already in use (BLR error)." What's wrong?
Regards,
Sergio
PD: Excellent forum!!!
SELECT
...somefields...,
CASE
WHEN (SELECT FIRST 1 T1.MyField FROM
SomeTable T1 WHERE T1.MyIndex = T.MyIndex ORDER BY T1.OrderField DESC) = 0
THEN 'some string'
WHEN (SELECT FIRST 1 T1.MyField FROM
SomeTable T1 WHERE T1.MyIndex = T.MyIndex ORDER BY T1.OrderField DESC) = 1
THEN 'another string'
:
:
ELSE
'blablabla'
END FieldAlias
FROM
MyTable T
WHERE
...some conditions...
ORDER BY
1,
2
But when I use the following:
SELECT
...somefields...
CASE (SELECT FIRST 1 T1.MyField FROM SomeTable T1
WHERE T1.MyIndex = T.MyIndex ORDER BY T1.OrderField DESC)
WHEN 0 THEN 'some string'
WHEN 1 THEN 'another string'
:
:
ELSE
'blablabla'
END FieldAlias
FROM
MyTable T
WHERE
...some conditions...
ORDER BY
1,
2
I receive an error: "Invalid token. invalid request BLR at offset 219.
context already in use (BLR error)." What's wrong?
Regards,
Sergio
PD: Excellent forum!!!