powered by simpleCommunicator - 2.0.48     © 2025 Programmizd 02
Форумы / Firebird, InterBase [игнор отключен] [закрыт для гостей] / Interbase 2020 Error: expression evaluation not supported
16 сообщений из 16, страница 1 из 1
Interbase 2020 Error: expression evaluation not supported
    #40121060
Delphi159
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
здравствуйте.
Этот код правильно работает на Firebird 3, а на Interbase 2020 выдает ощибку:

Error at line 1. Dynamic SQL Error: expression evaluation not supported

Если переписать без coalesce тогда получаю ощибку :

Error at line 1. Dynamic SQL Error. SQL error code = -104. Invalid command. Data type unknown


Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
select i.goods_id, 
    sum(case when  i.recdate < :d then coalesce(i.qty,0) end) as income,
    0 as sale,
    0 as writeoff
      from income i
        where cast(i.recdate as date) <= :d         
union all
select s.goods_id, 
    0,
    sum(case when s.recdate < :d then coalesce(s.qty,0) end) as sale,
    0
      from sales s
        where cast(s.recdate as date) <= :d
union all
select
    w.goods_id,
    0, 
    0,
    sum(case when w.recDate< :d then coalesce(w.Qty,0) end) as writeoff,
       from writeoff w
         where cast(w.recDate as date) <= :d 
    group by goods_id
...
Рейтинг: 0 / 0
Interbase 2020 Error: expression evaluation not supported
    #40121065
Мимопроходящий
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
оберни параметры в COALESCE()
Posted via ActualForum NNTP Server 1.5
...
Рейтинг: 0 / 0
Interbase 2020 Error: expression evaluation not supported
    #40121103
Delphi159
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Мимопроходящий, отдельно все 3 части union-а правильно работают, например
Код: sql
1.
2.
3.
4.
5.
6.
select i.goods_id, 
    sum(i.qty) as income,
    0 as sale,
    0 as writeoff
      from income i
        where cast(i.recdate as date) <= :d   


а если вместе в union-е
Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
select i.goods_id, 
    sum(i.qty) as income,
    0 as sale,
    0 as writeoff
      from income i
        where cast(i.recdate as date) <= :d         
union all
select s.goods_id, 
    0,
    sum(s.qty) as sale,
    0
      from sales s
        where cast(s.recdate as date) <= :d
union all
select
    w.goods_id,
    0, 
    0,
    sum(w.Qty)  as writeoff,
       from writeoff w
         where cast(w.recDate as date) <= :d 
    group by goods_id


тогда выдается ощибка: авторInvalid command. Data type unknown


пробовал и без cast, результат тот-же самий:
Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
select i.goods_id, 
    sum(i.qty) as income,
    0 as sale,
    0 as writeoff
      from income i
        where i.recdate<= :d         
union all
select s.goods_id, 
    0,
    sum(s.qty) as sale,
    0
      from sales s
        where s.recdate<= :d
union all
select
    w.goods_id,
    0, 
    0,
    sum(w.Qty)  as writeoff,
       from writeoff w
         where w.recDate<= :d 
    group by goods_id
...
Рейтинг: 0 / 0
Interbase 2020 Error: expression evaluation not supported
    #40121107
Шавлюк Евгений
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Вот тебе подсказали же
Мимопроходящий
оберни параметры в COALESCE()

cast(:d as date)
...
Рейтинг: 0 / 0
Interbase 2020 Error: expression evaluation not supported
    #40121118
Delphi159
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Мимопроходящий, Шавлюк Евгений, так что ли?
Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
select i.goods_id, 
    sum(i.qty) as income,
    0 as sale,
    0 as writeoff
      from income i
        where i.recdate<= coalesce(:d,0)         
union all
select s.goods_id, 
    0,
    sum(s.qty) as sale,
    0
      from sales s
        where s.recdate<= coalesce(:d,0)
union all
select
    w.goods_id,
    0, 
    0,
    sum(w.Qty)  as writeoff,
       from writeoff w
         where w.recDate<= coalesce(:d, 0) 
    group by goods_id



Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
select i.goods_id, 
    sum(i.qty) as income,
    0 as sale,
    0 as writeoff
      from income i
        where i.recdate<= cast(:d as date)         
union all
select s.goods_id, 
    0,
    sum(s.qty) as sale,
    0
      from sales s
        where s.recdate<= cast(:d as date)
union all
select
    w.goods_id,
    0, 
    0,
    sum(w.Qty)  as writeoff,
       from writeoff w
         where w.recDate<= cast(:d as date) 
    group by goods_id





авторError at line 1. Dynamic SQL Error. SQL error code = -104. Invalid command. Data type unknown
...
Рейтинг: 0 / 0
Interbase 2020 Error: expression evaluation not supported
    #40121128
Шавлюк Евгений
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Delphi159,

Ты пытаешься дату привести к числу 0. Не делай так.
Или coalesce(:d, current_date) and cast(:d as date)
...
Рейтинг: 0 / 0
Interbase 2020 Error: expression evaluation not supported
    #40121144
Delphi159
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Шавлюк Евгений
Delphi159,

Ты пытаешься дату привести к числу 0. Не делай так.

Да, конечно. :)

Шавлюк Евгений
Delphi159,
Или coalesce(:d, current_date) and cast(:d as date)

date же в 1 диалекте не поддержывается, а в 3-ем выводит тот же 'Data type unknown'
Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
select i.goods_id, 
    sum(i.qty) as income,
    0 as sale,
    0 as writeoff
      from income i
        where i.recdate<= coalesce(:d, '01,01,2050')         
union all
select s.goods_id, 
    0,
    sum(s.qty) as sale,
    0
      from sales s
        where s.recdate<= coalesce(:d,'01,01,2050')
union all
select
    w.goods_id,
    0, 
    0,
    sum(w.Qty)  as writeoff,
       from writeoff w
         where w.recDate<= coalesce(:d, '01,01,2050') 
    group by goods_id
...
Рейтинг: 0 / 0
Interbase 2020 Error: expression evaluation not supported
    #40121146
Delphi159
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Шавлюк Евгений, и без параметра не работает:
Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
select i.goods_id, 
    sum(i.qty) as income,
    0 as sale,
    0 as writeoff
      from income i
        where i.recdate<= '01.01.2050'         
union all
select s.goods_id, 
    0,
    sum(s.qty) as sale,
    0
      from sales s
        where s.recdate<= '01.01.2050'
union all
select
    w.goods_id,
    0, 
    0,
    sum(w.Qty)  as writeoff,
       from writeoff w
         where w.recDate<=  '01.01.2050' 
    group by goods_id



или например уберу дату из where-clause:

Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
select i.goods_id, 
    sum(i.qty) as income,
    0 as sale,
    0 as writeoff
      from income i
        where i.goods_id>1000     
union all
select s.goods_id, 
    0,
    sum(s.qty) as sale,
    0
      from sales s
        where s.goods_id>1000   
union all
select
    w.goods_id,
    0, 
    0,
    sum(w.Qty)  as writeoff,
       from writeoff w
         where w.goods_id>1000   
    group by goods_id
...
Рейтинг: 0 / 0
Interbase 2020 Error: expression evaluation not supported
    #40121147
Шавлюк Евгений
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Delphi159
Код: sql
1.
coalesce(:d, '01,01,2050') 


Запятая тут умышленно?
В данном случае параметр будет приведен к строке, а не к дате.
...
Рейтинг: 0 / 0
Interbase 2020 Error: expression evaluation not supported
    #40121154
Delphi159
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Шавлюк Евгений
Delphi159
Код: sql
1.
coalesce(:d, '01,01,2050') 


Запятая тут умышленно?

Нет, точка. :)
'01.01.2050'
тем более что и без даты не работает ( where goods_id>1000)
...
Рейтинг: 0 / 0
Interbase 2020 Error: expression evaluation not supported
    #40121155
Delphi159
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Шавлюк Евгений,

формат даты правильный
...
Рейтинг: 0 / 0
Interbase 2020 Error: expression evaluation not supported
    #40121156
Dimitry Sibiryakov
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Приведи нули в первом подзапросе к какому-нибудь конкретному типу.
Posted via ActualForum NNTP Server 1.5
...
Рейтинг: 0 / 0
Interbase 2020 Error: expression evaluation not supported
    #40121169
Delphi159
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Dimitry Sibiryakov,
вы имели ввиду так?
Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
select i.goods_id, 
    sum(i.qty) as income,
    cast(0 as float) as sale,
    cast(0 as float) as writeoff
      from income i
        where i.goods_id>1000     
union all
select s.goods_id, 
    0,
    sum(s.qty) as sale,
    0
      from sales s
        where s.goods_id>1000   
union all
select
    w.goods_id,
    0, 
    0,
    sum(w.Qty)  as writeoff, 
       from writeoff w
         where w.goods_id>1000   
    group by goods_id


авторError at line 1. Dynamic SQL Error. SQL error code = -104. Invalid command. Data type unknown

p.s. все qty поля типа float, recdate поля - timestamp.
...
Рейтинг: 0 / 0
Interbase 2020 Error: expression evaluation not supported
    #40121171
Фотография Старый плюшевый мишка
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Delphi159

все qty поля типа float


И вот тут у меня остатки волосиков встали дыбом. Для полноты картины не хватает smallint-ов, а то маловато граблей разложено.

В отличие от Дельфи, SQL не всё равно какого типа 0 при замещении им полей в union. Smallint, Integer, Float, Double Precision, Numeric, Decimal... Не понимает IB в каком формате 0 совать. В FB интеллект повыше, не ленится оно приглядеться к формату данных полей таблиц и вопить только если они разные в подзапросах. Короче, все константы в union должны быть кастованы прямым текстом к конкретному типу. Я давненько не брал в руки шашек, но вроде в каких-то случаях и параметры тоже.
...
Рейтинг: 0 / 0
Interbase 2020 Error: expression evaluation not supported
    #40121190
Delphi159
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Старый плюшевый мишкаДля полноты картины не хватает smallint-ов, а то маловато граблей разложено.

Старый плюшевый мишка, Вы правы. Это самая первая база, около 12 лет назад писал, Сейчас поля quantity имеют тип Decimal(18,4).

Вкратце, везде использовал cast-ы и сейчас отдельно внутрення часть (derived table) правильно работает:
Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
select i.goods_id, 
    sum(i.qty) as inc,
    cast(0 as float) as sale,
    cast(0 as float) as writeoff
      from income i
        where cast(i.recdate as date) <= :d    
union all
select s.goods_id, 
    cast(0 as float),
    sum(s.qty) as sale,
    cast(0 as float)
      from sales s
        where cast(s.recdate as date) <= :d   
union all
select
    w.goods_id,
    cast(0 as float), 
    cast(0 as float),
    sum(w.Qty)  as writeoff, 
       from writeoff w
         where cast(i.recdate as date) <= :d   
    group by goods_id



а целый запрос:

Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
select                                                                          
      Goods_id,
      coalesce(sum(inc),0) as incomes,
      coalesce(sum(sale),0) as sales,
      coalesce(sum(writeoff),0) as writeoff,
      sum(coalesce(inc,0)-coalesce(sale,0)-coalesce(writeoff,0)) as endqnt
    from(
select i.goods_id, 
    sum(i.qty) as inc,
    cast(0 as float) as sale,
    cast(0 as float) as writeoff
      from income i
        where cast(i.recdate as date) <= :d    
union all
select s.goods_id, 
    cast(0 as float),
    sum(s.qty) as sale,
    cast(0 as float)
      from sales s
        where cast(s.recdate as date) <= :d   
union all
select
    w.goods_id,
    cast(0 as float), 
    cast(0 as float),
    sum(w.Qty)  as writeoff, 
       from writeoff w
         where cast(i.recdate as date) <= :d   
    group by goods_id) dt1
   group by  goods_id)



ругается таким образом:
авторError at line 1. Sql error code=-206. Column unknown INC
...
Рейтинг: 0 / 0
Interbase 2020 Error: expression evaluation not supported
    #40121216
Фотография Старый плюшевый мишка
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Delphi159,

ТщательнЕе надо быть, аккуратнее и собраннее. Я бы на его месте тоже ругался. Потому что все алиасы полей присутствуют только в первом компоненте юниона, а во втором и третьем по одному, остальные - трактуй, сервер, как хочешь.

ЗЫ Если следующим будет - с INC справился, теперь ругается на sale или на writeoff, потеряю веру в человечество и уйду в запой.
...
Рейтинг: 0 / 0
16 сообщений из 16, страница 1 из 1
Форумы / Firebird, InterBase [игнор отключен] [закрыт для гостей] / Interbase 2020 Error: expression evaluation not supported
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]